diff --git a/doc/source/backwards-incompatible.rst b/doc/source/backwards-incompatible.rst index 94873c149f..5152641991 100644 --- a/doc/source/backwards-incompatible.rst +++ b/doc/source/backwards-incompatible.rst @@ -114,6 +114,18 @@ List of Backwards Incompatible Changes * Bug: https://launchpad.net/bugs/1506841 * Commit: https://review.openstack.org/#/c/236736/ +9. `flavor set/unset` commands will no longer return the modified resource + + Previously, modifying a flavor would result in the new flavor being displayed + to the user. To keep things consistent with other `set/unset` commands, we + will no longer be showing the modified resource. + + * In favor of: Use `set/unset` then `show` + * As of: NA + * Removed in: NA + * Bug: https://bugs.launchpad.net/python-openstackclient/+bug/1546065 + * Commit: https://review.openstack.org/#/c/280663/ + For Developers ============== diff --git a/functional/tests/compute/v2/test_flavor.py b/functional/tests/compute/v2/test_flavor.py index becf217f6c..d1f5f95dd4 100644 --- a/functional/tests/compute/v2/test_flavor.py +++ b/functional/tests/compute/v2/test_flavor.py @@ -46,11 +46,20 @@ class FlavorTests(test.TestCase): self.assertEqual(self.NAME + "\n", raw_output) def test_flavor_properties(self): - opts = self.get_show_opts(["properties"]) + opts = self.get_show_opts(['properties']) + raw_output = self.openstack( - 'flavor set --property a=b --property c=d ' + self.NAME + opts) + 'flavor set --property a=b --property c=d ' + self.NAME + ) + self.assertEqual('', raw_output) + + raw_output = self.openstack('flavor show ' + self.NAME + opts) self.assertEqual("a='b', c='d'\n", raw_output) - raw_output = self.openstack('flavor unset --property a ' + - self.NAME + opts) + raw_output = self.openstack( + 'flavor unset --property a ' + self.NAME + ) + self.assertEqual('', raw_output) + + raw_output = self.openstack('flavor show ' + self.NAME + opts) self.assertEqual("c='d'\n", raw_output) diff --git a/openstackclient/compute/v2/flavor.py b/openstackclient/compute/v2/flavor.py index 0308d9409b..e106bd65c4 100644 --- a/openstackclient/compute/v2/flavor.py +++ b/openstackclient/compute/v2/flavor.py @@ -242,7 +242,7 @@ class ShowFlavor(command.ShowOne): return zip(*sorted(six.iteritems(flavor))) -class SetFlavor(command.ShowOne): +class SetFlavor(command.Command): """Set flavor properties""" def get_parser(self, prog_name): @@ -263,17 +263,11 @@ class SetFlavor(command.ShowOne): def take_action(self, parsed_args): compute_client = self.app.client_manager.compute - resource_flavor = compute_client.flavors.find(name=parsed_args.flavor) - - resource_flavor.set_keys(parsed_args.property) - - flavor = resource_flavor._info.copy() - flavor['properties'] = utils.format_dict(resource_flavor.get_keys()) - flavor.pop("links", None) - return zip(*sorted(six.iteritems(flavor))) + flavor = compute_client.flavors.find(name=parsed_args.flavor) + flavor.set_keys(parsed_args.property) -class UnsetFlavor(command.ShowOne): +class UnsetFlavor(command.Command): """Unset flavor properties""" def get_parser(self, prog_name): @@ -295,11 +289,5 @@ class UnsetFlavor(command.ShowOne): def take_action(self, parsed_args): compute_client = self.app.client_manager.compute - resource_flavor = compute_client.flavors.find(name=parsed_args.flavor) - - resource_flavor.unset_keys(parsed_args.property) - - flavor = resource_flavor._info.copy() - flavor['properties'] = utils.format_dict(resource_flavor.get_keys()) - flavor.pop("links", None) - return zip(*sorted(six.iteritems(flavor))) + flavor = compute_client.flavors.find(name=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 781e3068ae..77e0bfb726 100644 --- a/openstackclient/tests/compute/v2/test_flavor.py +++ b/openstackclient/tests/compute/v2/test_flavor.py @@ -285,15 +285,12 @@ class TestFlavorSet(TestFlavor): ('property', {'FOO': '"B A R"'}), ('flavor', 'baremetal') ] - parsed_args = self.check_parser(self.cmd, arglist, verifylist) - columns, data = self.cmd.take_action(parsed_args) + result = self.cmd.take_action(parsed_args) self.flavors_mock.find.assert_called_with(name='baremetal') - - self.assertEqual('properties', columns[6]) - self.assertIn('FOO=\'"B A R"\'', data[6]) + self.assertIsNone(result) class TestFlavorShow(TestFlavor): @@ -382,12 +379,9 @@ class TestFlavorUnset(TestFlavor): ('property', ['property']), ('flavor', 'baremetal'), ] - parsed_args = self.check_parser(self.cmd, arglist, verifylist) - columns, data = self.cmd.take_action(parsed_args) + result = self.cmd.take_action(parsed_args) self.flavors_mock.find.assert_called_with(name='baremetal') - - self.assertEqual('properties', columns[6]) - self.assertNotIn('property', data[6]) + self.assertIsNone(result) diff --git a/releasenotes/notes/bug-1546065-41d09ffbd8606513.yaml b/releasenotes/notes/bug-1546065-41d09ffbd8606513.yaml new file mode 100644 index 0000000000..1d7e126686 --- /dev/null +++ b/releasenotes/notes/bug-1546065-41d09ffbd8606513.yaml @@ -0,0 +1,4 @@ +--- +fixes: + - Command ``flavor set/unset`` now outputs nothing. + [Bug `1546065 `_]