Skip to content

Commit 9c62af8

Browse files
author
Tang Chen
committed
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
1 parent 7cda2b2 commit 9c62af8

6 files changed

Lines changed: 16 additions & 24 deletions

File tree

openstackclient/common/quota.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,6 @@ def take_action(self, parsed_args):
142142
if value is not None:
143143
compute_kwargs[k] = value
144144

145-
if (compute_kwargs == {} and volume_kwargs == {}
146-
and network_kwargs == {}):
147-
sys.stderr.write("No quotas updated\n")
148-
return
149-
150145
if parsed_args.project:
151146
project = utils.find_resource(
152147
identity_client.projects,

openstackclient/compute/v2/flavor.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -279,9 +279,6 @@ def take_action(self, parsed_args):
279279

280280
flavor = _find_flavor(compute_client, parsed_args.flavor)
281281

282-
if not parsed_args.property and not parsed_args.project:
283-
raise exceptions.CommandError(_("Nothing specified to be set."))
284-
285282
result = 0
286283
if parsed_args.property:
287284
try:
@@ -368,9 +365,6 @@ def take_action(self, parsed_args):
368365

369366
flavor = _find_flavor(compute_client, parsed_args.flavor)
370367

371-
if not parsed_args.property and not parsed_args.project:
372-
raise exceptions.CommandError(_("Nothing specified to be unset."))
373-
374368
result = 0
375369
if parsed_args.property:
376370
try:

openstackclient/image/v1/image.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -691,10 +691,6 @@ def take_action(self, parsed_args):
691691
image.properties.update(kwargs['properties'])
692692
kwargs['properties'] = image.properties
693693

694-
if not kwargs:
695-
LOG.warning(_('no arguments specified'))
696-
return
697-
698694
image = image_client.images.update(image.id, **kwargs)
699695
finally:
700696
# Clean up open files - make sure data isn't a string

openstackclient/tests/compute/v2/test_flavor.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -542,8 +542,12 @@ def test_flavor_set_nothing(self):
542542
('flavor', self.flavor.id),
543543
]
544544
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
545-
self.assertRaises(exceptions.CommandError, self.cmd.take_action,
546-
parsed_args)
545+
result = self.cmd.take_action(parsed_args)
546+
547+
self.flavors_mock.find.assert_called_with(name=parsed_args.flavor,
548+
is_public=None)
549+
self.flavor_access_mock.add_tenant_access.assert_not_called()
550+
self.assertIsNone(result)
547551

548552

549553
class TestFlavorShow(TestFlavor):
@@ -717,5 +721,8 @@ def test_flavor_unset_nothing(self):
717721
('flavor', self.flavor.id),
718722
]
719723
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
720-
self.assertRaises(exceptions.CommandError, self.cmd.take_action,
721-
parsed_args)
724+
725+
result = self.cmd.take_action(parsed_args)
726+
self.assertIsNone(result)
727+
728+
self.flavor_access_mock.remove_tenant_access.assert_not_called()

openstackclient/tests/image/v1/test_image.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -475,8 +475,8 @@ def test_image_set_no_options(self):
475475

476476
result = self.cmd.take_action(parsed_args)
477477

478-
# Verify update() was not called, if it was show the args
479-
self.assertEqual(self.images_mock.update.call_args_list, [])
478+
self.images_mock.update.assert_called_with(image_fakes.image_id,
479+
**{})
480480
self.assertIsNone(result)
481481

482482
def test_image_set_options(self):
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
upgrade:
3-
- All ``set`` and ``unset`` commands in network, identity, image, and volume now
4-
return normally when nothing specified to modify. This will become the default
5-
behavior of OSC ``set`` and ``unset`` commands.
3+
- All ``set`` and ``unset`` commands now return normally when nothing
4+
specified to modify. This will become the default behavior of OSC
5+
``set`` and ``unset`` commands.
66
[Bug `1588588 <https://bugs.launchpad.net/python-openstackclient/+bug/1588588>`_]

0 commit comments

Comments
 (0)