diff --git a/neutronclient/neutron/v2_0/quota.py b/neutronclient/neutron/v2_0/quota.py index 061f87371..626af1275 100644 --- a/neutronclient/neutron/v2_0/quota.py +++ b/neutronclient/neutron/v2_0/quota.py @@ -209,6 +209,10 @@ class UpdateQuota(neutronV20.NeutronCommand, show.ShowOne): quota[resource] = self._validate_int( resource, getattr(parsed_args, resource)) + if not quota: + raise exceptions.CommandError( + message=_('Must specify a valid resource with new quota ' + 'value')) return {self.resource: quota} def take_action(self, parsed_args): diff --git a/neutronclient/tests/unit/test_quota.py b/neutronclient/tests/unit/test_quota.py index b9d7b4448..78f4daefe 100644 --- a/neutronclient/tests/unit/test_quota.py +++ b/neutronclient/tests/unit/test_quota.py @@ -92,3 +92,11 @@ class CLITestV20Quota(test_cli20.CLITestV20Base): self.assertIn('subnet', _str) self.assertIn('port', _str) self.assertNotIn('subnetpool', _str) + + def test_update_quota_noargs(self): + resource = 'quota' + cmd = test_quota.UpdateQuota(test_cli20.MyApp(sys.stdout), None) + args = [self.test_id] + self.assertRaises(exceptions.CommandError, self._test_update_resource, + resource, cmd, self.test_id, args=args, + extrafields=None) diff --git a/releasenotes/notes/fix-quota-update-zero-args-d596c4169c2d2e30.yaml b/releasenotes/notes/fix-quota-update-zero-args-d596c4169c2d2e30.yaml new file mode 100644 index 000000000..eb70752a3 --- /dev/null +++ b/releasenotes/notes/fix-quota-update-zero-args-d596c4169c2d2e30.yaml @@ -0,0 +1,9 @@ +--- +fixes: + - | + Fix CLI quota-update to return an error message for no args + + * ``quota-update`` CLI will return an error message + ``Must specify a valid resource with new quota value`` if no + argument is provided while executing it. If arguments are + provided with CLI, no existing behavior is changed.