Fix omission of request_ids returned to user
ManagerWithFind's find() and findall() function is exposed to users as ManagerWithFind is parent class of VolumeManager, SnapshotManager, etc. When the find() and findall() function is called by users, they should also return request_ids to users. Change-Id: I87dca61f96ff9cf4dc9a443a46d7f559e8b3026f Closes-Bug: 1545975
This commit is contained in:
parent
bdeb22da28
commit
8c0f84f8ad
@ -348,6 +348,7 @@ class ManagerWithFind(six.with_metaclass(abc.ABCMeta, Manager)):
|
||||
elif num_matches > 1:
|
||||
raise exceptions.NoUniqueMatch
|
||||
else:
|
||||
matches[0].append_request_ids(matches.request_ids)
|
||||
return matches[0]
|
||||
|
||||
def findall(self, **kwargs):
|
||||
@ -370,13 +371,15 @@ class ManagerWithFind(six.with_metaclass(abc.ABCMeta, Manager)):
|
||||
elif 'display_name' in kwargs:
|
||||
search_opts['display_name'] = kwargs['display_name']
|
||||
|
||||
found = []
|
||||
found = common_base.ListWithMeta([], None)
|
||||
searches = kwargs.items()
|
||||
|
||||
listing = self.list(search_opts=search_opts)
|
||||
found.append_request_ids(listing.request_ids)
|
||||
# Not all resources attributes support filters on server side
|
||||
# (e.g. 'human_id' doesn't), so when doing findall some client
|
||||
# side filtering is still needed.
|
||||
for obj in self.list(search_opts=search_opts):
|
||||
for obj in listing:
|
||||
try:
|
||||
if all(getattr(obj, attr) == value
|
||||
for (attr, value) in searches):
|
||||
|
@ -20,7 +20,9 @@ from six import moves
|
||||
from cinderclient import exceptions
|
||||
from cinderclient import utils
|
||||
from cinderclient import base
|
||||
from cinderclient.openstack.common.apiclient import base as common_base
|
||||
from cinderclient.tests.unit import utils as test_utils
|
||||
from cinderclient.tests.unit.v2 import fakes
|
||||
|
||||
UUID = '8e8ec658-c7b0-4243-bdf8-6f7f2952c0d0'
|
||||
|
||||
@ -35,6 +37,9 @@ class FakeResource(object):
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
def append_request_ids(self, resp):
|
||||
pass
|
||||
|
||||
|
||||
class FakeManager(base.ManagerWithFind):
|
||||
|
||||
@ -53,7 +58,7 @@ class FakeManager(base.ManagerWithFind):
|
||||
raise exceptions.NotFound(resource_id)
|
||||
|
||||
def list(self, search_opts):
|
||||
return self.resources
|
||||
return common_base.ListWithMeta(self.resources, fakes.REQUEST_ID)
|
||||
|
||||
|
||||
class FakeDisplayResource(object):
|
||||
@ -66,6 +71,9 @@ class FakeDisplayResource(object):
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
def append_request_ids(self, resp):
|
||||
pass
|
||||
|
||||
|
||||
class FakeDisplayManager(FakeManager):
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user