Skip to content

Commit 2bd82ab

Browse files
author
Steve Martinelli
committed
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
1 parent 1afb574 commit 2bd82ab

6 files changed

Lines changed: 27 additions & 34 deletions

File tree

doc/source/backwards-incompatible.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,18 @@ List of Backwards Incompatible Changes
9090
* Bug: https://bugs.launchpad.net/python-openstackclient/+bug/1453229
9191
* Commit: https://review.openstack.org/#/c/181514/
9292

93+
7. `image set` commands will no longer return the modified resource
94+
95+
Previously, modifying an image would result in the new image being displayed
96+
to the user. To keep things consistent with other `set` commands, we will
97+
no longer be showing the modified resource.
98+
99+
* In favor of: Use `set` then `show`
100+
* As of: NA
101+
* Removed in: NA
102+
* Bug: NA
103+
* Commit: NA
104+
93105
For Developers
94106
==============
95107

functional/tests/image/v1/test_image.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,9 @@ def setUpClass(cls):
3535
@classmethod
3636
def tearDownClass(cls):
3737
# Rename test
38-
opts = cls.get_show_opts(cls.FIELDS)
39-
raw_output = cls.openstack(
40-
'image set --name ' + cls.OTHER_NAME + ' ' + cls.NAME + opts)
41-
cls.assertOutput(cls.OTHER_NAME + "\n", raw_output)
38+
raw_output = cls.openstack('image set --name ' + cls.OTHER_NAME + ' '
39+
+ cls.NAME)
40+
cls.assertOutput('', raw_output)
4241
# Delete test
4342
raw_output = cls.openstack('image delete ' + cls.OTHER_NAME)
4443
cls.assertOutput('', raw_output)
@@ -56,13 +55,13 @@ def test_image_show(self):
5655
def test_image_set(self):
5756
opts = self.get_show_opts([
5857
"disk_format", "is_public", "min_disk", "min_ram", "name"])
59-
raw_output = self.openstack('image set --min-disk 4 --min-ram 5 ' +
60-
'--disk-format qcow2 --public ' +
61-
self.NAME + opts)
58+
self.openstack('image set --min-disk 4 --min-ram 5 ' +
59+
'--disk-format qcow2 --public ' + self.NAME)
60+
raw_output = self.openstack('image show ' + self.NAME + opts)
6261
self.assertEqual("qcow2\nTrue\n4\n5\n" + self.NAME + '\n', raw_output)
6362

6463
def test_image_metadata(self):
6564
opts = self.get_show_opts(["name", "properties"])
66-
raw_output = self.openstack(
67-
'image set --property a=b --property c=d ' + self.NAME + opts)
65+
self.openstack('image set --property a=b --property c=d ' + self.NAME)
66+
raw_output = self.openstack('image show ' + self.NAME + opts)
6867
self.assertEqual(self.NAME + "\na='b', c='d'\n", raw_output)

openstackclient/image/v1/image.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ def take_action(self, parsed_args):
452452
gc_utils.save_image(data, parsed_args.file)
453453

454454

455-
class SetImage(show.ShowOne):
455+
class SetImage(command.Command):
456456
"""Set image properties"""
457457

458458
log = logging.getLogger(__name__ + ".SetImage")
@@ -629,7 +629,7 @@ def take_action(self, parsed_args):
629629
volume_client.volumes,
630630
parsed_args.volume,
631631
)
632-
response, body = volume_client.volumes.upload_to_image(
632+
volume_client.volumes.upload_to_image(
633633
source_volume.id,
634634
parsed_args.force,
635635
parsed_args.image,
@@ -640,7 +640,6 @@ def take_action(self, parsed_args):
640640
if parsed_args.disk_format
641641
else image.disk_format),
642642
)
643-
info = body['os-volume_upload_image']
644643
elif parsed_args.file:
645644
# Send an open file handle to glanceclient so it will
646645
# do a chunked transfer
@@ -673,10 +672,7 @@ def take_action(self, parsed_args):
673672
kwargs['data'] != sys.stdin):
674673
kwargs['data'].close()
675674

676-
info = {}
677-
info.update(image._info)
678-
info['properties'] = utils.format_dict(info.get('properties', {}))
679-
return zip(*sorted(six.iteritems(info)))
675+
return
680676

681677

682678
class ShowImage(show.ShowOne):

openstackclient/image/v2/image.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ def take_action(self, parsed_args):
521521
gc_utils.save_image(data, parsed_args.file)
522522

523523

524-
class SetImage(show.ShowOne):
524+
class SetImage(command.Command):
525525
"""Set image properties"""
526526

527527
log = logging.getLogger(__name__ + ".SetImage")
@@ -717,9 +717,6 @@ def take_action(self, parsed_args):
717717
kwargs['tags'] = list(set(image.tags).union(set(parsed_args.tags)))
718718

719719
image = image_client.images.update(image.id, **kwargs)
720-
info = {}
721-
info.update(image)
722-
return zip(*sorted(six.iteritems(info)))
723720

724721

725722
class ShowImage(show.ShowOne):

openstackclient/tests/image/v1/test_image.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -499,8 +499,7 @@ def test_image_set_options(self):
499499
]
500500
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
501501

502-
# DisplayCommandBase.take_action() returns two tuples
503-
columns, data = self.cmd.take_action(parsed_args)
502+
self.cmd.take_action(parsed_args)
504503

505504
kwargs = {
506505
'name': 'new-name',
@@ -517,9 +516,6 @@ def test_image_set_options(self):
517516
**kwargs
518517
)
519518

520-
self.assertEqual(image_fakes.IMAGE_columns, columns)
521-
self.assertEqual(image_fakes.IMAGE_data, data)
522-
523519
def test_image_set_bools1(self):
524520
arglist = [
525521
'--protected',
@@ -644,8 +640,7 @@ def test_image_update_volume(self):
644640
]
645641
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
646642

647-
# DisplayCommandBase.take_action() returns two tuples
648-
columns, data = self.cmd.take_action(parsed_args)
643+
self.cmd.take_action(parsed_args)
649644

650645
# VolumeManager.upload_to_image(volume, force, image_name,
651646
# container_format, disk_format)
@@ -664,9 +659,6 @@ def test_image_update_volume(self):
664659
volume='volly',
665660
)
666661

667-
self.assertEqual(image_fakes.IMAGE_columns, columns)
668-
self.assertEqual(image_fakes.IMAGE_data, data)
669-
670662

671663
class TestImageShow(TestImage):
672664

openstackclient/tests/image/v2/test_image.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ def test_image_set_options(self):
676676
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
677677

678678
# DisplayCommandBase.take_action() returns two tuples
679-
columns, data = self.cmd.take_action(parsed_args)
679+
self.cmd.take_action(parsed_args)
680680

681681
kwargs = {
682682
'name': 'new-name',
@@ -690,9 +690,6 @@ def test_image_set_options(self):
690690
self.images_mock.update.assert_called_with(
691691
image_fakes.image_id, **kwargs)
692692

693-
self.assertEqual(image_fakes.IMAGE_columns, columns)
694-
self.assertEqual(image_fakes.IMAGE_data, data)
695-
696693
def test_image_set_bools1(self):
697694
arglist = [
698695
'--protected',

0 commit comments

Comments
 (0)