Allow name argument to flavor-access-add
Administrator cannot use the flavor name in arguments of "nova flavor-access-add" and "nova flavor-access-remove". This patch fixes this problem. Change-Id: I68b267dc071382f1978efc2088cd8e837455e8b4 Related-Bug: #1205298
This commit is contained in:
parent
61a8063954
commit
97da33fcf5
@ -212,7 +212,12 @@ class ManagerWithFind(Manager):
|
||||
list_kwargs['detailed'] = detailed
|
||||
|
||||
if 'is_public' in list_argspec.args and 'is_public' in kwargs:
|
||||
list_kwargs['is_public'] = kwargs['is_public']
|
||||
is_public = kwargs['is_public']
|
||||
list_kwargs['is_public'] = is_public
|
||||
if is_public is None:
|
||||
tmp_kwargs = kwargs.copy()
|
||||
del tmp_kwargs['is_public']
|
||||
searches = tmp_kwargs.items()
|
||||
|
||||
listing = self.list(**list_kwargs)
|
||||
|
||||
|
@ -591,11 +591,13 @@ class FakeHTTPClient(base_client.HTTPClient):
|
||||
#
|
||||
|
||||
def get_flavors(self, **kw):
|
||||
return (200, {}, {'flavors': [
|
||||
{'id': 1, 'name': '256 MB Server'},
|
||||
{'id': 2, 'name': '512 MB Server'},
|
||||
{'id': 'aa1', 'name': '128 MB Server'}
|
||||
]})
|
||||
status, header, flavors = self.get_flavors_detail(**kw)
|
||||
for flavor in flavors['flavors']:
|
||||
for k in flavor.keys():
|
||||
if k not in ['id', 'name']:
|
||||
del flavor[k]
|
||||
|
||||
return (200, {}, flavors)
|
||||
|
||||
def get_flavors_detail(self, **kw):
|
||||
flavors = {'flavors': [
|
||||
|
@ -225,6 +225,7 @@ def find_resource(manager, name_or_id, **find_args):
|
||||
resource = getattr(manager, 'resource_class', None)
|
||||
name_attr = resource.NAME_ATTR if resource else 'name'
|
||||
kwargs = {name_attr: name_or_id}
|
||||
kwargs.update(find_args)
|
||||
return manager.find(**kwargs)
|
||||
except exceptions.NotFound:
|
||||
msg = "No %s with a name or ID of '%s' exists." % \
|
||||
|
@ -1378,7 +1378,7 @@ def _find_image(cs, image):
|
||||
def _find_flavor_for_admin(cs, flavor):
|
||||
"""Get a flavor for administrator by name, ID, or RAM size."""
|
||||
try:
|
||||
return utils.find_resource(cs.flavors, flavor, is_public='None')
|
||||
return utils.find_resource(cs.flavors, flavor, is_public=None)
|
||||
except exceptions.NotFound:
|
||||
return cs.flavors.find(ram=flavor)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user