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
This commit is contained in:
parent
630985649f
commit
00ccdd3831
@ -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)
|
||||
|
@ -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 ...
|
||||
|
@ -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):
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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'),
|
||||
|
@ -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 = \
|
||||
|
Loading…
Reference in New Issue
Block a user