summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--openstackclient/compute/v2/flavor.py6
-rw-r--r--openstackclient/tests/compute/v2/test_flavor.py12
-rw-r--r--releasenotes/notes/bug-1575624-87957ff60ad661a6.yaml5
3 files changed, 17 insertions, 6 deletions
diff --git a/openstackclient/compute/v2/flavor.py b/openstackclient/compute/v2/flavor.py
index 29e0e9d4..04674614 100644
--- a/openstackclient/compute/v2/flavor.py
+++ b/openstackclient/compute/v2/flavor.py
@@ -239,7 +239,8 @@ class SetFlavor(command.Command):
def take_action(self, parsed_args):
compute_client = self.app.client_manager.compute
- flavor = compute_client.flavors.find(name=parsed_args.flavor)
+ flavor = utils.find_resource(compute_client.flavors,
+ parsed_args.flavor)
flavor.set_keys(parsed_args.property)
@@ -289,5 +290,6 @@ class UnsetFlavor(command.Command):
def take_action(self, parsed_args):
compute_client = self.app.client_manager.compute
- flavor = compute_client.flavors.find(name=parsed_args.flavor)
+ flavor = utils.find_resource(compute_client.flavors,
+ parsed_args.flavor)
flavor.unset_keys(parsed_args.property)
diff --git a/openstackclient/tests/compute/v2/test_flavor.py b/openstackclient/tests/compute/v2/test_flavor.py
index 03ca8807..fa29111b 100644
--- a/openstackclient/tests/compute/v2/test_flavor.py
+++ b/openstackclient/tests/compute/v2/test_flavor.py
@@ -288,8 +288,10 @@ class TestFlavorSet(TestFlavor):
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
result = self.cmd.take_action(parsed_args)
-
- self.flavors_mock.find.assert_called_with(name='baremetal')
+ try:
+ self.flavors_mock.find.assert_called_with(name=parsed_args.flavor)
+ except Exception:
+ self.flavors_mock.get.assert_called_with(parsed_args.flavor)
self.assertIsNone(result)
@@ -382,6 +384,8 @@ class TestFlavorUnset(TestFlavor):
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
result = self.cmd.take_action(parsed_args)
-
- self.flavors_mock.find.assert_called_with(name='baremetal')
+ try:
+ self.flavors_mock.find.assert_called_with(name=parsed_args.flavor)
+ except Exception:
+ self.flavors_mock.get.assert_called_with(parsed_args.flavor)
self.assertIsNone(result)
diff --git a/releasenotes/notes/bug-1575624-87957ff60ad661a6.yaml b/releasenotes/notes/bug-1575624-87957ff60ad661a6.yaml
new file mode 100644
index 00000000..95002202
--- /dev/null
+++ b/releasenotes/notes/bug-1575624-87957ff60ad661a6.yaml
@@ -0,0 +1,5 @@
+---
+fixes:
+ - Fixed ``flavor set/unset`` command to properly find a
+ flavor to be set/unset by flavor id.
+ [Bug `1575624 <https://bugs.launchpad.net/bugs/1575624>`_]