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:
Jiao Pengju
2017-12-20 19:27:12 +08:00
parent b9ebff14ca
commit 7e4a376426
22 changed files with 29 additions and 23 deletions

View File

@@ -219,5 +219,5 @@ class ManagerWithFind(Manager):
return found
def list(self):
def list(self, search_opts=None):
raise NotImplementedError

View File

@@ -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)

View File

@@ -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(

View File

@@ -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(

View File

@@ -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)

View File

@@ -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'),

View File

@@ -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)

View File

@@ -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)

View File

@@ -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)

View File

@@ -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)

View File

@@ -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")

View File

@@ -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,

View File

@@ -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)

View File

@@ -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`.

View File

@@ -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(

View File

@@ -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)

View File

@@ -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`
"""

View File

@@ -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')

View File

@@ -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')

View File

@@ -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'

View File

@@ -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):

View File

@@ -0,0 +1,4 @@
---
fixes:
- Fixed bugs 1738917 and 1738918. Names can now be used in commands
pertaining to share group types.