From 2bd82ab89258110b44135ae4cf2c4678938673d2 Mon Sep 17 00:00:00 2001 From: Steve Martinelli Date: Thu, 24 Sep 2015 12:00:39 -0400 Subject: [PATCH] image set should not show the resource the rest of OSC set commands do not show the resource after it has been updated. unless the update fails then we report back a failure, otherwise the user should assume everything went fine. Change-Id: I2bd4188450c3853b4a1bc25f80fc9450cda32bdd --- doc/source/backwards-incompatible.rst | 12 ++++++++++++ functional/tests/image/v1/test_image.py | 17 ++++++++--------- openstackclient/image/v1/image.py | 10 +++------- openstackclient/image/v2/image.py | 5 +---- openstackclient/tests/image/v1/test_image.py | 12 ++---------- openstackclient/tests/image/v2/test_image.py | 5 +---- 6 files changed, 27 insertions(+), 34 deletions(-) diff --git a/doc/source/backwards-incompatible.rst b/doc/source/backwards-incompatible.rst index e89cc3a680..f9f2ed4485 100644 --- a/doc/source/backwards-incompatible.rst +++ b/doc/source/backwards-incompatible.rst @@ -90,6 +90,18 @@ List of Backwards Incompatible Changes * Bug: https://bugs.launchpad.net/python-openstackclient/+bug/1453229 * Commit: https://review.openstack.org/#/c/181514/ +7. `image set` commands will no longer return the modified resource + + Previously, modifying an image would result in the new image being displayed + to the user. To keep things consistent with other `set` commands, we will + no longer be showing the modified resource. + + * In favor of: Use `set` then `show` + * As of: NA + * Removed in: NA + * Bug: NA + * Commit: NA + For Developers ============== diff --git a/functional/tests/image/v1/test_image.py b/functional/tests/image/v1/test_image.py index 17c0c3dd8f..fe61f83036 100644 --- a/functional/tests/image/v1/test_image.py +++ b/functional/tests/image/v1/test_image.py @@ -35,10 +35,9 @@ class ImageTests(test.TestCase): @classmethod def tearDownClass(cls): # Rename test - opts = cls.get_show_opts(cls.FIELDS) - raw_output = cls.openstack( - 'image set --name ' + cls.OTHER_NAME + ' ' + cls.NAME + opts) - cls.assertOutput(cls.OTHER_NAME + "\n", raw_output) + raw_output = cls.openstack('image set --name ' + cls.OTHER_NAME + ' ' + + cls.NAME) + cls.assertOutput('', raw_output) # Delete test raw_output = cls.openstack('image delete ' + cls.OTHER_NAME) cls.assertOutput('', raw_output) @@ -56,13 +55,13 @@ class ImageTests(test.TestCase): def test_image_set(self): opts = self.get_show_opts([ "disk_format", "is_public", "min_disk", "min_ram", "name"]) - raw_output = self.openstack('image set --min-disk 4 --min-ram 5 ' + - '--disk-format qcow2 --public ' + - self.NAME + opts) + self.openstack('image set --min-disk 4 --min-ram 5 ' + + '--disk-format qcow2 --public ' + self.NAME) + raw_output = self.openstack('image show ' + self.NAME + opts) self.assertEqual("qcow2\nTrue\n4\n5\n" + self.NAME + '\n', raw_output) def test_image_metadata(self): opts = self.get_show_opts(["name", "properties"]) - raw_output = self.openstack( - 'image set --property a=b --property c=d ' + self.NAME + opts) + self.openstack('image set --property a=b --property c=d ' + self.NAME) + raw_output = self.openstack('image show ' + self.NAME + opts) self.assertEqual(self.NAME + "\na='b', c='d'\n", raw_output) diff --git a/openstackclient/image/v1/image.py b/openstackclient/image/v1/image.py index 68c81cd58d..23f5713621 100644 --- a/openstackclient/image/v1/image.py +++ b/openstackclient/image/v1/image.py @@ -452,7 +452,7 @@ class SaveImage(command.Command): gc_utils.save_image(data, parsed_args.file) -class SetImage(show.ShowOne): +class SetImage(command.Command): """Set image properties""" log = logging.getLogger(__name__ + ".SetImage") @@ -629,7 +629,7 @@ class SetImage(show.ShowOne): volume_client.volumes, parsed_args.volume, ) - response, body = volume_client.volumes.upload_to_image( + volume_client.volumes.upload_to_image( source_volume.id, parsed_args.force, parsed_args.image, @@ -640,7 +640,6 @@ class SetImage(show.ShowOne): if parsed_args.disk_format else image.disk_format), ) - info = body['os-volume_upload_image'] elif parsed_args.file: # Send an open file handle to glanceclient so it will # do a chunked transfer @@ -673,10 +672,7 @@ class SetImage(show.ShowOne): kwargs['data'] != sys.stdin): kwargs['data'].close() - info = {} - info.update(image._info) - info['properties'] = utils.format_dict(info.get('properties', {})) - return zip(*sorted(six.iteritems(info))) + return class ShowImage(show.ShowOne): diff --git a/openstackclient/image/v2/image.py b/openstackclient/image/v2/image.py index 7ef1f7806a..7d8b14124a 100644 --- a/openstackclient/image/v2/image.py +++ b/openstackclient/image/v2/image.py @@ -521,7 +521,7 @@ class SaveImage(command.Command): gc_utils.save_image(data, parsed_args.file) -class SetImage(show.ShowOne): +class SetImage(command.Command): """Set image properties""" log = logging.getLogger(__name__ + ".SetImage") @@ -717,9 +717,6 @@ class SetImage(show.ShowOne): kwargs['tags'] = list(set(image.tags).union(set(parsed_args.tags))) image = image_client.images.update(image.id, **kwargs) - info = {} - info.update(image) - return zip(*sorted(six.iteritems(info))) class ShowImage(show.ShowOne): diff --git a/openstackclient/tests/image/v1/test_image.py b/openstackclient/tests/image/v1/test_image.py index a79df8b4a1..d10d3b1577 100644 --- a/openstackclient/tests/image/v1/test_image.py +++ b/openstackclient/tests/image/v1/test_image.py @@ -499,8 +499,7 @@ class TestImageSet(TestImage): ] parsed_args = self.check_parser(self.cmd, arglist, verifylist) - # DisplayCommandBase.take_action() returns two tuples - columns, data = self.cmd.take_action(parsed_args) + self.cmd.take_action(parsed_args) kwargs = { 'name': 'new-name', @@ -517,9 +516,6 @@ class TestImageSet(TestImage): **kwargs ) - self.assertEqual(image_fakes.IMAGE_columns, columns) - self.assertEqual(image_fakes.IMAGE_data, data) - def test_image_set_bools1(self): arglist = [ '--protected', @@ -644,8 +640,7 @@ class TestImageSet(TestImage): ] parsed_args = self.check_parser(self.cmd, arglist, verifylist) - # DisplayCommandBase.take_action() returns two tuples - columns, data = self.cmd.take_action(parsed_args) + self.cmd.take_action(parsed_args) # VolumeManager.upload_to_image(volume, force, image_name, # container_format, disk_format) @@ -664,9 +659,6 @@ class TestImageSet(TestImage): volume='volly', ) - self.assertEqual(image_fakes.IMAGE_columns, columns) - self.assertEqual(image_fakes.IMAGE_data, data) - class TestImageShow(TestImage): diff --git a/openstackclient/tests/image/v2/test_image.py b/openstackclient/tests/image/v2/test_image.py index 46da9c6893..4ce854759b 100644 --- a/openstackclient/tests/image/v2/test_image.py +++ b/openstackclient/tests/image/v2/test_image.py @@ -676,7 +676,7 @@ class TestImageSet(TestImage): parsed_args = self.check_parser(self.cmd, arglist, verifylist) # DisplayCommandBase.take_action() returns two tuples - columns, data = self.cmd.take_action(parsed_args) + self.cmd.take_action(parsed_args) kwargs = { 'name': 'new-name', @@ -690,9 +690,6 @@ class TestImageSet(TestImage): self.images_mock.update.assert_called_with( image_fakes.image_id, **kwargs) - self.assertEqual(image_fakes.IMAGE_columns, columns) - self.assertEqual(image_fakes.IMAGE_data, data) - def test_image_set_bools1(self): arglist = [ '--protected',