Merge "Fix omission of request_ids returned to user"

This commit is contained in:
Jenkins
2016-02-27 16:35:16 +00:00
committed by Gerrit Code Review
2 changed files with 14 additions and 3 deletions

View File

@@ -348,6 +348,7 @@ class ManagerWithFind(six.with_metaclass(abc.ABCMeta, Manager)):
elif num_matches > 1: elif num_matches > 1:
raise exceptions.NoUniqueMatch raise exceptions.NoUniqueMatch
else: else:
matches[0].append_request_ids(matches.request_ids)
return matches[0] return matches[0]
def findall(self, **kwargs): def findall(self, **kwargs):
@@ -370,13 +371,15 @@ class ManagerWithFind(six.with_metaclass(abc.ABCMeta, Manager)):
elif 'display_name' in kwargs: elif 'display_name' in kwargs:
search_opts['display_name'] = kwargs['display_name'] search_opts['display_name'] = kwargs['display_name']
found = [] found = common_base.ListWithMeta([], None)
searches = kwargs.items() 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 # Not all resources attributes support filters on server side
# (e.g. 'human_id' doesn't), so when doing findall some client # (e.g. 'human_id' doesn't), so when doing findall some client
# side filtering is still needed. # side filtering is still needed.
for obj in self.list(search_opts=search_opts): for obj in listing:
try: try:
if all(getattr(obj, attr) == value if all(getattr(obj, attr) == value
for (attr, value) in searches): for (attr, value) in searches):

View File

@@ -20,7 +20,9 @@ from six import moves
from cinderclient import exceptions from cinderclient import exceptions
from cinderclient import utils from cinderclient import utils
from cinderclient import base 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 import utils as test_utils
from cinderclient.tests.unit.v2 import fakes
UUID = '8e8ec658-c7b0-4243-bdf8-6f7f2952c0d0' UUID = '8e8ec658-c7b0-4243-bdf8-6f7f2952c0d0'
@@ -35,6 +37,9 @@ class FakeResource(object):
except KeyError: except KeyError:
pass pass
def append_request_ids(self, resp):
pass
class FakeManager(base.ManagerWithFind): class FakeManager(base.ManagerWithFind):
@@ -53,7 +58,7 @@ class FakeManager(base.ManagerWithFind):
raise exceptions.NotFound(resource_id) raise exceptions.NotFound(resource_id)
def list(self, search_opts): def list(self, search_opts):
return self.resources return common_base.ListWithMeta(self.resources, fakes.REQUEST_ID)
class FakeDisplayResource(object): class FakeDisplayResource(object):
@@ -66,6 +71,9 @@ class FakeDisplayResource(object):
except KeyError: except KeyError:
pass pass
def append_request_ids(self, resp):
pass
class FakeDisplayManager(FakeManager): class FakeDisplayManager(FakeManager):