Merge "image set should not show the resource"

This commit is contained in:
Jenkins 2015-10-08 20:38:05 +00:00 committed by Gerrit Code Review
commit 9f23f1f13f
6 changed files with 27 additions and 34 deletions

View File

@ -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
==============

View File

@ -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)

View File

@ -454,7 +454,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")
@ -631,7 +631,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,
@ -642,7 +642,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
@ -675,10 +674,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):

View File

@ -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):

View File

@ -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):

View File

@ -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',