Add search_opts in func list of ManagerWithFind type classes
In patch I96339778fa69c379863078250d5dfa7172f2c1b2, it called self.list with search_opts, but some subclasses of ManagerWithFind do not have search_opts in function list, this make some list functions and show by name functions fail and throw 'unexpected keyword argument search_opts' error. This patch will fix it. Change-Id: Ic4b65c0e5900a0e3e19155d5d9d42d5063c3137d Closes-Bug: #1738917 Closes-Bug: #1738918
This commit is contained in:
@@ -219,5 +219,5 @@ class ManagerWithFind(Manager):
|
||||
|
||||
return found
|
||||
|
||||
def list(self):
|
||||
def list(self, search_opts=None):
|
||||
raise NotImplementedError
|
||||
|
@@ -42,7 +42,7 @@ class ShareExportLocationsTest(utils.TestCase):
|
||||
|
||||
def test_list_of_export_locations(self):
|
||||
share_id = '1234'
|
||||
cs.share_export_locations.list(share_id)
|
||||
cs.share_export_locations.list(share_id, search_opts=None)
|
||||
cs.assert_called(
|
||||
'GET', '/shares/%s/export_locations' % share_id)
|
||||
|
||||
|
@@ -58,7 +58,7 @@ class ShareGroupTypeAccessManagerTest(utils.TestCase):
|
||||
self.manager, '_list',
|
||||
mock.Mock(return_value=[fake_share_group_type_access]))
|
||||
|
||||
result = self.manager.list(fake.ShareGroupType())
|
||||
result = self.manager.list(fake.ShareGroupType(), search_opts=None)
|
||||
|
||||
self.assertEqual([fake_share_group_type_access], result)
|
||||
mock_list.assert_called_once_with(
|
||||
|
@@ -188,7 +188,7 @@ class ShareGroupTypeManagerTest(utils.TestCase):
|
||||
self.manager, '_list',
|
||||
mock.Mock(return_value=[fake_share_group_type]))
|
||||
|
||||
result = self.manager.list()
|
||||
result = self.manager.list(search_opts=None)
|
||||
|
||||
self.assertEqual([fake_share_group_type], result)
|
||||
mock_list.assert_called_once_with(
|
||||
|
@@ -43,7 +43,8 @@ class ShareInstanceExportLocationsTest(utils.TestCase):
|
||||
|
||||
def test_list_of_export_locations(self):
|
||||
share_instance_id = '1234'
|
||||
cs.share_instance_export_locations.list(share_instance_id)
|
||||
cs.share_instance_export_locations.list(
|
||||
share_instance_id, search_opts=None)
|
||||
cs.assert_called(
|
||||
'GET', '/share_instances/%s/export_locations' % share_instance_id)
|
||||
|
||||
|
@@ -38,7 +38,7 @@ class ShareInstancesTest(utils.TestCase):
|
||||
return share_instances.ShareInstanceManager(api=mock_microversion)
|
||||
|
||||
def test_list(self):
|
||||
cs.share_instances.list()
|
||||
cs.share_instances.list(search_opts=None)
|
||||
cs.assert_called('GET', '/share_instances')
|
||||
|
||||
@ddt.data(('id', 'b4991315-eb7d-43ec-979e-5715d4399827'),
|
||||
|
@@ -95,7 +95,7 @@ class ShareReplicasTest(utils.TestCase):
|
||||
|
||||
def test_list(self):
|
||||
with mock.patch.object(self.manager, '_list', mock.Mock()):
|
||||
self.manager.list()
|
||||
self.manager.list(search_opts=None)
|
||||
self.manager._list.assert_called_once_with(
|
||||
share_replicas.RESOURCES_PATH + '/detail',
|
||||
share_replicas.RESOURCES_NAME)
|
||||
|
@@ -30,7 +30,7 @@ cs = fakes.FakeClient(extensions=extensions)
|
||||
class ShareSnapshotExportLocationsTest(utils.TestCase):
|
||||
def test_list_snapshot(self):
|
||||
snapshot_id = '1234'
|
||||
cs.share_snapshot_export_locations.list(snapshot_id)
|
||||
cs.share_snapshot_export_locations.list(snapshot_id, search_opts=None)
|
||||
cs.assert_called(
|
||||
'GET', '/snapshots/%s/export-locations' % snapshot_id)
|
||||
|
||||
|
@@ -31,7 +31,7 @@ class ShareSnapshotInstanceExportLocationsTest(utils.TestCase):
|
||||
def test_list_snapshot_instance(self):
|
||||
snapshot_instance_id = '1234'
|
||||
cs.share_snapshot_instance_export_locations.list(
|
||||
snapshot_instance_id)
|
||||
snapshot_instance_id, search_opts=None)
|
||||
cs.assert_called(
|
||||
'GET', '/snapshot-instances/%s/export-locations'
|
||||
% snapshot_instance_id)
|
||||
|
@@ -47,7 +47,7 @@ class SnapshotInstancesTest(utils.TestCase):
|
||||
else:
|
||||
url = '/snapshot-instances'
|
||||
self.mock_object(self.manager, '_list', mock.Mock())
|
||||
self.manager.list(detailed=detailed)
|
||||
self.manager.list(detailed=detailed, search_opts=None)
|
||||
self.manager._list.assert_called_once_with(url, 'snapshot_instances')
|
||||
|
||||
@ddt.data(True, False)
|
||||
|
@@ -49,7 +49,7 @@ class TypeAccessTest(utils.TestCase):
|
||||
|
||||
with mock.patch.object(manager, '_list',
|
||||
mock.Mock(return_value=fake_access_list)):
|
||||
access = manager.list(share_type=share_type)
|
||||
access = manager.list(share_type=share_type, search_opts=None)
|
||||
|
||||
manager._list.assert_called_once_with(
|
||||
"/types/3/%s" % action_name, "share_type_access")
|
||||
|
@@ -33,7 +33,7 @@ class ShareExportLocationManager(base.ManagerWithFind):
|
||||
resource_class = ShareExportLocation
|
||||
|
||||
@api_versions.wraps("2.9")
|
||||
def list(self, share):
|
||||
def list(self, share, search_opts=None):
|
||||
"""List all share export locations."""
|
||||
share_id = common_base.getid(share)
|
||||
return self._list("/shares/%s/export_locations" % share_id,
|
||||
|
@@ -34,7 +34,7 @@ class ShareGroupTypeAccessManager(base.ManagerWithFind):
|
||||
|
||||
@api_versions.wraps("2.31")
|
||||
@api_versions.experimental_api
|
||||
def list(self, share_group_type):
|
||||
def list(self, share_group_type, search_opts=None):
|
||||
if share_group_type.is_public:
|
||||
return None
|
||||
share_group_type_id = common_base.getid(share_group_type)
|
||||
|
@@ -131,7 +131,7 @@ class ShareGroupTypeManager(base.ManagerWithFind):
|
||||
|
||||
@api_versions.wraps("2.31")
|
||||
@api_versions.experimental_api
|
||||
def list(self, show_all=True):
|
||||
def list(self, show_all=True, search_opts=None):
|
||||
"""Get a list of all share group types.
|
||||
|
||||
:rtype: list of :class:`ShareGroupType`.
|
||||
|
@@ -33,7 +33,7 @@ class ShareInstanceExportLocationManager(base.ManagerWithFind):
|
||||
resource_class = ShareInstanceExportLocation
|
||||
|
||||
@api_versions.wraps("2.9")
|
||||
def list(self, share_instance):
|
||||
def list(self, share_instance, search_opts=None):
|
||||
"""List all share export locations."""
|
||||
share_instance_id = common_base.getid(share_instance)
|
||||
return self._list(
|
||||
|
@@ -49,12 +49,12 @@ class ShareInstanceManager(base.ManagerWithFind):
|
||||
return self._get("/share_instances/%s" % share_id, "share_instance")
|
||||
|
||||
@api_versions.wraps("2.3", "2.34")
|
||||
def list(self):
|
||||
def list(self, search_opts=None):
|
||||
"""List all share instances."""
|
||||
return self.do_list()
|
||||
|
||||
@api_versions.wraps("2.35") # noqa
|
||||
def list(self, export_location=None):
|
||||
def list(self, export_location=None, search_opts=None):
|
||||
"""List all share instances."""
|
||||
return self.do_list(export_location)
|
||||
|
||||
|
@@ -63,10 +63,11 @@ class ShareReplicaManager(base.ManagerWithFind):
|
||||
|
||||
@api_versions.wraps("2.11")
|
||||
@api_versions.experimental_api
|
||||
def list(self, share=None):
|
||||
def list(self, share=None, search_opts=None):
|
||||
"""List all share replicas or list replicas belonging to a share.
|
||||
|
||||
:param share: either share object or its UUID.
|
||||
:param search_opts: default None
|
||||
:rtype: list of :class:`ShareReplica`
|
||||
"""
|
||||
|
||||
|
@@ -38,7 +38,7 @@ class ShareSnapshotExportLocationManager(base.ManagerWithFind):
|
||||
resource_class = ShareSnapshotExportLocation
|
||||
|
||||
@api_versions.wraps("2.32")
|
||||
def list(self, snapshot=None):
|
||||
def list(self, snapshot=None, search_opts=None):
|
||||
return self._list("/snapshots/%s/export-locations" %
|
||||
common_base.getid(snapshot),
|
||||
'share_snapshot_export_locations')
|
||||
|
@@ -38,7 +38,7 @@ class ShareSnapshotInstanceExportLocationManager(base.ManagerWithFind):
|
||||
resource_class = ShareSnapshotInstanceExportLocation
|
||||
|
||||
@api_versions.wraps("2.32")
|
||||
def list(self, snapshot_instance=None):
|
||||
def list(self, snapshot_instance=None, search_opts=None):
|
||||
return self._list("/snapshot-instances/%s/export-locations" %
|
||||
common_base.getid(snapshot_instance),
|
||||
'share_snapshot_export_locations')
|
||||
|
@@ -45,7 +45,7 @@ class ShareSnapshotInstanceManager(base.ManagerWithFind):
|
||||
"snapshot_instance")
|
||||
|
||||
@api_versions.wraps("2.19")
|
||||
def list(self, detailed=False, snapshot=None):
|
||||
def list(self, detailed=False, snapshot=None, search_opts=None):
|
||||
"""List all snapshot instances."""
|
||||
if detailed:
|
||||
url = '/snapshot-instances/detail'
|
||||
|
@@ -40,11 +40,11 @@ class ShareTypeAccessManager(base.ManagerWithFind):
|
||||
"share_type_access")
|
||||
|
||||
@api_versions.wraps("1.0", "2.6")
|
||||
def list(self, share_type):
|
||||
def list(self, share_type, search_opts=None):
|
||||
return self._do_list(share_type, "os-share-type-access")
|
||||
|
||||
@api_versions.wraps("2.7") # noqa
|
||||
def list(self, share_type):
|
||||
def list(self, share_type, search_opts=None):
|
||||
return self._do_list(share_type, "share_type_access")
|
||||
|
||||
def add_project_access(self, share_type, project):
|
||||
|
@@ -0,0 +1,4 @@
|
||||
---
|
||||
fixes:
|
||||
- Fixed bugs 1738917 and 1738918. Names can now be used in commands
|
||||
pertaining to share group types.
|
Reference in New Issue
Block a user