quota-update to return an error msg for 0 args
If no arguments are provided while executing neutron quota-update instead of printing the current quota values it will throw an error message "Must specify new values to update quota" Added unit test to verify that the exception is raised when no arguments are provided to quota update Includes release notes. DocImpact Closes-Bug: #1597552 Change-Id: I476991c39eafa16148f0cc3252ae5c26b9c8cbfc
This commit is contained in:
@@ -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):
|
||||
|
@@ -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)
|
||||
|
@@ -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.
|
Reference in New Issue
Block a user