Make set/unset commands in compute/image/common return normally when nothing specified

After this patch, all set/unset commands will return normally
when nothing specified.

Change-Id: Id94d0329faa1a674006a9aae901f834b41917317
Close-bug: #1588588
This commit is contained in:
Tang Chen 2016-06-21 15:15:18 +08:00
parent 7cda2b2a06
commit 9c62af8a42
6 changed files with 16 additions and 24 deletions

View File

@ -142,11 +142,6 @@ class SetQuota(command.Command):
if value is not None: if value is not None:
compute_kwargs[k] = value compute_kwargs[k] = value
if (compute_kwargs == {} and volume_kwargs == {}
and network_kwargs == {}):
sys.stderr.write("No quotas updated\n")
return
if parsed_args.project: if parsed_args.project:
project = utils.find_resource( project = utils.find_resource(
identity_client.projects, identity_client.projects,

View File

@ -279,9 +279,6 @@ class SetFlavor(command.Command):
flavor = _find_flavor(compute_client, parsed_args.flavor) flavor = _find_flavor(compute_client, parsed_args.flavor)
if not parsed_args.property and not parsed_args.project:
raise exceptions.CommandError(_("Nothing specified to be set."))
result = 0 result = 0
if parsed_args.property: if parsed_args.property:
try: try:
@ -368,9 +365,6 @@ class UnsetFlavor(command.Command):
flavor = _find_flavor(compute_client, parsed_args.flavor) flavor = _find_flavor(compute_client, parsed_args.flavor)
if not parsed_args.property and not parsed_args.project:
raise exceptions.CommandError(_("Nothing specified to be unset."))
result = 0 result = 0
if parsed_args.property: if parsed_args.property:
try: try:

View File

@ -691,10 +691,6 @@ class SetImage(command.Command):
image.properties.update(kwargs['properties']) image.properties.update(kwargs['properties'])
kwargs['properties'] = image.properties kwargs['properties'] = image.properties
if not kwargs:
LOG.warning(_('no arguments specified'))
return
image = image_client.images.update(image.id, **kwargs) image = image_client.images.update(image.id, **kwargs)
finally: finally:
# Clean up open files - make sure data isn't a string # Clean up open files - make sure data isn't a string

View File

@ -542,8 +542,12 @@ class TestFlavorSet(TestFlavor):
('flavor', self.flavor.id), ('flavor', self.flavor.id),
] ]
parsed_args = self.check_parser(self.cmd, arglist, verifylist) parsed_args = self.check_parser(self.cmd, arglist, verifylist)
self.assertRaises(exceptions.CommandError, self.cmd.take_action, result = self.cmd.take_action(parsed_args)
parsed_args)
self.flavors_mock.find.assert_called_with(name=parsed_args.flavor,
is_public=None)
self.flavor_access_mock.add_tenant_access.assert_not_called()
self.assertIsNone(result)
class TestFlavorShow(TestFlavor): class TestFlavorShow(TestFlavor):
@ -717,5 +721,8 @@ class TestFlavorUnset(TestFlavor):
('flavor', self.flavor.id), ('flavor', self.flavor.id),
] ]
parsed_args = self.check_parser(self.cmd, arglist, verifylist) parsed_args = self.check_parser(self.cmd, arglist, verifylist)
self.assertRaises(exceptions.CommandError, self.cmd.take_action,
parsed_args) result = self.cmd.take_action(parsed_args)
self.assertIsNone(result)
self.flavor_access_mock.remove_tenant_access.assert_not_called()

View File

@ -475,8 +475,8 @@ class TestImageSet(TestImage):
result = self.cmd.take_action(parsed_args) result = self.cmd.take_action(parsed_args)
# Verify update() was not called, if it was show the args self.images_mock.update.assert_called_with(image_fakes.image_id,
self.assertEqual(self.images_mock.update.call_args_list, []) **{})
self.assertIsNone(result) self.assertIsNone(result)
def test_image_set_options(self): def test_image_set_options(self):

View File

@ -1,6 +1,6 @@
--- ---
upgrade: upgrade:
- All ``set`` and ``unset`` commands in network, identity, image, and volume now - All ``set`` and ``unset`` commands now return normally when nothing
return normally when nothing specified to modify. This will become the default specified to modify. This will become the default behavior of OSC
behavior of OSC ``set`` and ``unset`` commands. ``set`` and ``unset`` commands.
[Bug `1588588 <https://bugs.launchpad.net/python-openstackclient/+bug/1588588>`_] [Bug `1588588 <https://bugs.launchpad.net/python-openstackclient/+bug/1588588>`_]