summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTang Chen <chen.tang@easystack.cn>2016-02-17 10:07:50 +0800
committerTang Chen <chen.tang@easystack.cn>2016-02-27 03:46:30 +0800
commitf37eda3a27dc88d3186d21eca328cca086ee3647 (patch)
tree141e4e197b367dcc23af2ab4e4ba5aa3dc99c46f
parentb5b5fdd78ad0d191bdf07a56293fecaa43002e75 (diff)
downloadpython-openstackclient-f37eda3a27dc88d3186d21eca328cca086ee3647.tar.gz
Make SetFlavor and UnsetFlavor inherit from cliff.Command
set/unset comamnd classes should inherit from cliff.Command class. Change-Id: I54e5608ac0768d7d94b7f7d516ea1948daefdc1b Partial-Bug: 1546065
-rw-r--r--doc/source/backwards-incompatible.rst12
-rw-r--r--functional/tests/compute/v2/test_flavor.py17
-rw-r--r--openstackclient/compute/v2/flavor.py24
-rw-r--r--openstackclient/tests/compute/v2/test_flavor.py14
-rw-r--r--releasenotes/notes/bug-1546065-41d09ffbd8606513.yaml4
5 files changed, 39 insertions, 32 deletions
diff --git a/doc/source/backwards-incompatible.rst b/doc/source/backwards-incompatible.rst
index 94873c14..51526419 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 becf217f..d1f5f95d 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 0308d940..e106bd65 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)
+ flavor = compute_client.flavors.find(name=parsed_args.flavor)
+ flavor.set_keys(parsed_args.property)
- 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)))
-
-
-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 781e3068..77e0bfb7 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 00000000..1d7e1266
--- /dev/null
+++ b/releasenotes/notes/bug-1546065-41d09ffbd8606513.yaml
@@ -0,0 +1,4 @@
+---
+fixes:
+ - Command ``flavor set/unset`` now outputs nothing.
+ [Bug `1546065 <https://bugs.launchpad.net/python-openstackclient/+bug/1546065>`_]