Skip to content

Commit 775b1ac

Browse files
Jenkinsopenstack-gerrit
authored andcommitted
Merge "Make set/unset commands in compute/image/common return normally when nothing specified"
2 parents de909e4 + 9c62af8 commit 775b1ac

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
@@ -320,9 +320,6 @@ def take_action(self, parsed_args):
320320

321321
flavor = _find_flavor(compute_client, parsed_args.flavor)
322322

323-
if not parsed_args.property and not parsed_args.project:
324-
raise exceptions.CommandError(_("Nothing specified to be set."))
325-
326323
result = 0
327324
if parsed_args.property:
328325
try:
@@ -409,9 +406,6 @@ def take_action(self, parsed_args):
409406

410407
flavor = _find_flavor(compute_client, parsed_args.flavor)
411408

412-
if not parsed_args.property and not parsed_args.project:
413-
raise exceptions.CommandError(_("Nothing specified to be unset."))
414-
415409
result = 0
416410
if parsed_args.property:
417411
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
@@ -596,8 +596,12 @@ def test_flavor_set_nothing(self):
596596
('flavor', self.flavor.id),
597597
]
598598
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
599-
self.assertRaises(exceptions.CommandError, self.cmd.take_action,
600-
parsed_args)
599+
result = self.cmd.take_action(parsed_args)
600+
601+
self.flavors_mock.find.assert_called_with(name=parsed_args.flavor,
602+
is_public=None)
603+
self.flavor_access_mock.add_tenant_access.assert_not_called()
604+
self.assertIsNone(result)
601605

602606

603607
class TestFlavorShow(TestFlavor):
@@ -771,5 +775,8 @@ def test_flavor_unset_nothing(self):
771775
('flavor', self.flavor.id),
772776
]
773777
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
774-
self.assertRaises(exceptions.CommandError, self.cmd.take_action,
775-
parsed_args)
778+
779+
result = self.cmd.take_action(parsed_args)
780+
self.assertIsNone(result)
781+
782+
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)