Repository: libcloud Updated Branches: refs/heads/trunk 2fb4e6b46 -> 582633929
Enable to pass arguments to ex_list_portforwarding_rules of CloudStack driver Closes #484 Signed-off-by: Tomaz Muraus <to...@apache.org> Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/58263392 Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/58263392 Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/58263392 Branch: refs/heads/trunk Commit: 582633929fc3d7086a3202dbe3bb467fcd2d037c Parents: 2fb4e6b Author: Atsushi Sasaki <atsak...@gmail.com> Authored: Tue Mar 10 16:57:15 2015 +0900 Committer: Tomaz Muraus <to...@apache.org> Committed: Thu May 7 23:05:14 2015 +0200 ---------------------------------------------------------------------- CHANGES.rst | 5 ++ libcloud/compute/drivers/cloudstack.py | 91 ++++++++++++++++++++++++++++- 2 files changed, 95 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/libcloud/blob/58263392/CHANGES.rst ---------------------------------------------------------------------- diff --git a/CHANGES.rst b/CHANGES.rst index a25f890..98ba7a4 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -162,6 +162,11 @@ Compute (LIBCLOUD-679, GITHUB-485) [Atsushi Sasaki] +- Allow user to pass filters via arguments to the + ``ex_list_port_forwarding_rules`` in the CloudStack driver. + (LIBCLOUD-678, GITHUB-484) + [Atsushi Sasaki] + Storage ~~~~~~~ http://git-wip-us.apache.org/repos/asf/libcloud/blob/58263392/libcloud/compute/drivers/cloudstack.py ---------------------------------------------------------------------- diff --git a/libcloud/compute/drivers/cloudstack.py b/libcloud/compute/drivers/cloudstack.py index 8462188..8a4126c 100644 --- a/libcloud/compute/drivers/cloudstack.py +++ b/libcloud/compute/drivers/cloudstack.py @@ -2476,14 +2476,103 @@ class CloudStackNodeDriver(CloudStackDriverMixIn, NodeDriver): method='GET') return res['success'] - def ex_list_port_forwarding_rules(self): + def ex_list_port_forwarding_rules(self, account=None, domain_id=None, + id=None, ipaddress_id=None, + is_recursive=None, keyword=None, + list_all=None, network_id=None, + page=None, page_size=None, + project_id=None): """ Lists all Port Forwarding Rules + :param account: List resources by account. + Must be used with the domainId parameter + :type account: ``str`` + + :param domain_id: List only resources belonging to + the domain specified + :type domain_id: ``str`` + + :param for_display: List resources by display flag (only root + admin is eligible to pass this parameter). + :type for_display: ``bool`` + + :param id: Lists rule with the specified ID + :type id: ``str`` + + :param ipaddress_id: list the rule belonging to + this public ip address + :type ipaddress_id: ``str`` + + :param is_recursive: Defaults to false, but if true, + lists all resources from + the parent specified by the + domainId till leaves. + :type is_recursive: ``bool`` + + :param keyword: List by keyword + :type keyword: ``str`` + + :param list_all: If set to false, list only resources + belonging to the command's caller; + if set to true - list resources that + the caller is authorized to see. + Default value is false + :type list_all: ``bool`` + + :param network_id: list port forwarding rules for ceratin network + :type network_id: ``string`` + + :param page: The page to list the keypairs from + :type page: ``int`` + + :param page_size: The number of results per page + :type page_size: ``int`` + + :param project_id: list objects by project + :type project_id: ``str`` + :rtype: ``list`` of :class:`CloudStackPortForwardingRule` """ + + args = {} + + if account is not None: + args['account'] = account + + if domain_id is not None: + args['domainid'] = domain_id + + if id is not None: + args['id'] = id + + if ipaddress_id is not None: + args['ipaddressid'] = ipaddress_id + + if is_recursive is not None: + args['isrecursive'] = is_recursive + + if keyword is not None: + args['keyword'] = keyword + + if list_all is not None: + args['listall'] = list_all + + if network_id is not None: + args['networkid'] = network_id + + if page is not None: + args['page'] = page + + if page_size is not None: + args['pagesize'] = page_size + + if project_id is not None: + args['projectid'] = project_id + rules = [] result = self._sync_request(command='listPortForwardingRules', + params=args, method='GET') if result != {}: public_ips = self.ex_list_public_ips()