From 00ccdd3831ec16478ccb66ef7ac01d84df6e55bd Mon Sep 17 00:00:00 2001 From: Yulia Portnova Date: Wed, 26 Mar 2014 14:37:25 +0200 Subject: [PATCH] Added detail parameter to list methods Added detail parameter to list methods for security_services and share_networks in v1. Closes-bug #1297824 Change-Id: Iac2384bbf69c18f75291cc58509e8e99d0ac93ff --- manilaclient/base.py | 2 +- manilaclient/service_catalog.py | 2 +- manilaclient/shell.py | 4 ++-- manilaclient/v1/security_services.py | 7 +++++-- manilaclient/v1/share_networks.py | 7 +++++-- tests/v1/test_security_services.py | 8 ++++++++ tests/v1/test_share_networks.py | 8 ++++++++ 7 files changed, 30 insertions(+), 8 deletions(-) diff --git a/manilaclient/base.py b/manilaclient/base.py index 4204714b0..277305d18 100644 --- a/manilaclient/base.py +++ b/manilaclient/base.py @@ -258,7 +258,7 @@ class Resource(object): def __getattr__(self, k): if k not in self.__dict__: - #NOTE(bcwaldon): disallow lazy-loading if already loaded once + # NOTE(bcwaldon): disallow lazy-loading if already loaded once if not self.is_loaded(): self.get() return self.__getattr__(k) diff --git a/manilaclient/service_catalog.py b/manilaclient/service_catalog.py index e4d8d83a9..f9bb31cbe 100644 --- a/manilaclient/service_catalog.py +++ b/manilaclient/service_catalog.py @@ -47,7 +47,7 @@ class ServiceCatalog(object): raise manilaclient.exceptions.EndpointNotFound() # We don't always get a service catalog back ... - if not 'serviceCatalog' in self.catalog['access']: + if 'serviceCatalog' not in self.catalog['access']: return None # Full catalog ... diff --git a/manilaclient/shell.py b/manilaclient/shell.py index 4b072bc8d..4c3c662ff 100644 --- a/manilaclient/shell.py +++ b/manilaclient/shell.py @@ -54,7 +54,7 @@ class ManilaClientArgumentParser(argparse.ArgumentParser): exits. """ self.print_usage(sys.stderr) - #FIXME(lzyeval): if changes occur in argparse.ArgParser._check_value + # FIXME(lzyeval): if changes occur in argparse.ArgParser._check_value choose_from = ' (choose from' progparts = self.prog.partition(' ') self.exit(2, "error: %(errmsg)s\nTry '%(mainp)s help %(subp)s'" @@ -350,7 +350,7 @@ class OpenStackManilaShell(object): service_type = DEFAULT_MANILA_SERVICE_TYPE service_type = utils.get_service_type(args.func) or service_type - #FIXME(usrleon): Here should be restrict for project id same as + # FIXME(usrleon): Here should be restrict for project id same as # for os_username or os_password but for compatibility it is not. if not utils.isunauthenticated(args.func): diff --git a/manilaclient/v1/security_services.py b/manilaclient/v1/security_services.py index 96bebcbfc..2269e987f 100644 --- a/manilaclient/v1/security_services.py +++ b/manilaclient/v1/security_services.py @@ -125,7 +125,7 @@ class SecurityServiceManager(base.Manager): """ self._delete(RESOURCE_PATH % security_service) - def list(self, search_opts=None): + def list(self, detailed=False, search_opts=None): """Get a list of all security services. :rtype: list of :class:`SecurityService` @@ -140,6 +140,9 @@ class SecurityServiceManager(base.Manager): else: query_string = '' - path = RESOURCES_PATH + "%s" % query_string + if detailed: + path = RESOURCES_PATH + "/detail" + query_string + else: + path = RESOURCES_PATH + query_string return self._list(path, RESOURCES_NAME) diff --git a/manilaclient/v1/share_networks.py b/manilaclient/v1/share_networks.py index c12b2ffeb..d5e94c87c 100644 --- a/manilaclient/v1/share_networks.py +++ b/manilaclient/v1/share_networks.py @@ -151,7 +151,7 @@ class ShareNetworkManager(base.Manager): """ self._delete(RESOURCE_PATH % share_network) - def list(self, search_opts=None): + def list(self, detailed=False, search_opts=None): """Get a list of all share network. :rtype: list of :class:`NetworkInfo` @@ -166,6 +166,9 @@ class ShareNetworkManager(base.Manager): else: query_string = '' - path = RESOURCES_PATH + "%s" % query_string + if detailed: + path = RESOURCES_PATH + "/detail" + query_string + else: + path = RESOURCES_PATH + query_string return self._list(path, RESOURCES_NAME) diff --git a/tests/v1/test_security_services.py b/tests/v1/test_security_services.py index 08dd38939..5270ac55d 100644 --- a/tests/v1/test_security_services.py +++ b/tests/v1/test_security_services.py @@ -91,6 +91,14 @@ class SecurityServiceTest(unittest.TestCase): security_services.RESOURCES_PATH, security_services.RESOURCES_NAME) + def test_list_detailed(self): + with mock.patch.object(self.manager, '_list', + mock.Mock(return_value=None)): + self.manager.list(detailed=True) + self.manager._list.assert_called_once_with( + security_services.RESOURCES_PATH + '/detail', + security_services.RESOURCES_NAME) + def test_list_with_filters(self): filters = OrderedDict([('all_tenants', 1), ('status', 'ERROR'), diff --git a/tests/v1/test_share_networks.py b/tests/v1/test_share_networks.py index 40f9f9c40..972f110dc 100644 --- a/tests/v1/test_share_networks.py +++ b/tests/v1/test_share_networks.py @@ -70,6 +70,14 @@ class ShareNetworkTest(unittest.TestCase): share_networks.RESOURCES_PATH, share_networks.RESOURCES_NAME) + def test_list_detailed(self): + with mock.patch.object(self.manager, '_list', + mock.Mock(return_value=None)): + self.manager.list(detailed=True) + self.manager._list.assert_called_once_with( + share_networks.RESOURCES_PATH + '/detail', + share_networks.RESOURCES_NAME) + def test_list_with_filters(self): filters = OrderedDict([('all_tenants', 1), ('status', 'ERROR')]) expected_path = \