Enhance get_list_of_xx calls by allowing for filter by network id
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/d70d61dc Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/d70d61dc Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/d70d61dc Branch: refs/heads/trunk Commit: d70d61dc526d1fd0de9f7a8e8fb7ad1dffab0865 Parents: f4c09c9 Author: jr2730 <[email protected]> Authored: Thu Aug 25 15:51:31 2016 -0700 Committer: Aimon Bustardo <[email protected]> Committed: Fri Aug 26 19:50:54 2016 -0500 ---------------------------------------------------------------------- libcloud/loadbalancer/drivers/dimensiondata.py | 45 ++++++++++++++++----- 1 file changed, 36 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/libcloud/blob/d70d61dc/libcloud/loadbalancer/drivers/dimensiondata.py ---------------------------------------------------------------------- diff --git a/libcloud/loadbalancer/drivers/dimensiondata.py b/libcloud/loadbalancer/drivers/dimensiondata.py index 33c0ab4..a73da66 100644 --- a/libcloud/loadbalancer/drivers/dimensiondata.py +++ b/libcloud/loadbalancer/drivers/dimensiondata.py @@ -173,18 +173,26 @@ class DimensionDataLBDriver(Driver): 'listener_ip_address': ex_listener_ip_address} ) - def list_balancers(self): + def list_balancers(self, network_id=None): """ - List all loadbalancers inside a geography. + List all loadbalancers inside a geography or in given network. In Dimension Data terminology these are known as virtual listeners + :param network_id: UUID of Network Domain + if not None returns only balancers in the given network + if None then returns all pools for the organization + :type network_id: ``str`` + :rtype: ``list`` of :class:`LoadBalancer` """ + params = None + if ( network_id is not None ): + params = { "networkDomainId": network_id } return self._to_balancers( self.connection - .request_with_orgId_api_2('networkDomainVip/virtualListener') + .request_with_orgId_api_2('networkDomainVip/virtualListener', params=params) .object) def get_balancer(self, balancer_id): @@ -685,15 +693,25 @@ class DimensionDataLBDriver(Driver): status=State.RUNNING ) - def ex_get_pools(self): + def ex_get_pools(self, network_id=None): """ - Get all of the pools inside the current geography + Get all of the pools inside the current geography or + in given network. + + :param network_id: UUID of Network Domain + if not None returns only balancers in the given network + if None then returns all pools for the organization + :type network_id: ``str`` :return: Returns a ``list`` of type ``DimensionDataPool`` :rtype: ``list`` of ``DimensionDataPool`` """ + params = None + if ( network_id is not None ): + params = { "networkDomainId": network_id } + pools = self.connection \ - .request_with_orgId_api_2('networkDomainVip/pool').object + .request_with_orgId_api_2('networkDomainVip/pool', params=params).object return self._to_pools(pools) def ex_get_pool(self, pool_id): @@ -833,15 +851,24 @@ class DimensionDataLBDriver(Driver): response_code = findtext(result, 'responseCode', TYPES_URN) return response_code in ['IN_PROGRESS', 'OK'] - def ex_get_nodes(self): + def ex_get_nodes(self, network_id=None): """ - Get the nodes within this geography + Get the nodes within this geography or in given network. + + :param network_id: UUID of Network Domain + if not None returns only balancers in the given network + if None then returns all pools for the organization + :type network_id: ``str`` :return: Returns an ``list`` of ``DimensionDataVIPNode`` :rtype: ``list`` of ``DimensionDataVIPNode`` """ + params = None + if ( network_id is not None ): + params = { "networkDomainId": network_id } + nodes = self.connection \ - .request_with_orgId_api_2('networkDomainVip/node').object + .request_with_orgId_api_2('networkDomainVip/node', params=params).object return self._to_nodes(nodes) def ex_get_node(self, node_id):
