Merge "Allow openstack flavor set to update flavor description using name"
This commit is contained in:
commit
0566ad66a9
@ -402,7 +402,7 @@ class SetFlavor(command.Command):
|
|||||||
if compute_client.api_version < api_versions.APIVersion("2.55"):
|
if compute_client.api_version < api_versions.APIVersion("2.55"):
|
||||||
msg = _("--os-compute-api-version 2.55 or later is required")
|
msg = _("--os-compute-api-version 2.55 or later is required")
|
||||||
raise exceptions.CommandError(msg)
|
raise exceptions.CommandError(msg)
|
||||||
compute_client.flavors.update(flavor=parsed_args.flavor,
|
compute_client.flavors.update(flavor=flavor.id,
|
||||||
description=parsed_args.description)
|
description=parsed_args.description)
|
||||||
|
|
||||||
|
|
||||||
|
@ -749,6 +749,42 @@ class TestFlavorSet(TestFlavor):
|
|||||||
self.assertRaises(exceptions.CommandError, self.cmd.take_action,
|
self.assertRaises(exceptions.CommandError, self.cmd.take_action,
|
||||||
parsed_args)
|
parsed_args)
|
||||||
|
|
||||||
|
def test_flavor_set_description_using_name_api_newer(self):
|
||||||
|
arglist = [
|
||||||
|
'--description', 'description',
|
||||||
|
self.flavor.name,
|
||||||
|
]
|
||||||
|
verifylist = [
|
||||||
|
('description', 'description'),
|
||||||
|
('flavor', self.flavor.name),
|
||||||
|
]
|
||||||
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
|
self.app.client_manager.compute.api_version = 2.55
|
||||||
|
with mock.patch.object(novaclient.api_versions,
|
||||||
|
'APIVersion',
|
||||||
|
return_value=2.55):
|
||||||
|
result = self.cmd.take_action(parsed_args)
|
||||||
|
self.flavors_mock.update.assert_called_with(
|
||||||
|
flavor=self.flavor.id, description='description')
|
||||||
|
self.assertIsNone(result)
|
||||||
|
|
||||||
|
def test_flavor_set_description_using_name_api_older(self):
|
||||||
|
arglist = [
|
||||||
|
'--description', 'description',
|
||||||
|
self.flavor.name,
|
||||||
|
]
|
||||||
|
verifylist = [
|
||||||
|
('description', 'description'),
|
||||||
|
('flavor', self.flavor.name),
|
||||||
|
]
|
||||||
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
|
self.app.client_manager.compute.api_version = 2.54
|
||||||
|
with mock.patch.object(novaclient.api_versions,
|
||||||
|
'APIVersion',
|
||||||
|
return_value=2.55):
|
||||||
|
self.assertRaises(exceptions.CommandError, self.cmd.take_action,
|
||||||
|
parsed_args)
|
||||||
|
|
||||||
|
|
||||||
class TestFlavorShow(TestFlavor):
|
class TestFlavorShow(TestFlavor):
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user