Skip to content

Commit

Permalink
Make --tenant a required arg for quota-show
Browse files Browse the repository at this point in the history
Fixes LP 1088519

Previously, novaclient was incorrectly defaulting to the tenant name
as the tenant ID when retrieving quota thresholds via the os-quota-sets
API extension, in an apparent attempt to default to the current tenant
if no specific tenant is explicitly requested.

As a result, the default quotas were always returned, regardless of
whether there were specific overridden quotas for this tenant.

We now require that the --tenant option is always specified for the
quota-show verb, as a sensible default isn't always possible
(because the tenant ID may be opaque to the client, for example when
the auth token is cached in the keyring from a previous call out to
keystone - now the tenant ID is of course generally embedded in the
nova publicURL retrieved from the service catalog, but that is not
guaranteed to be the case, i.e. I don't think we can safely make
assumptions about that URL format).

This change also makes the quota-show verb more consistent with the
quota-update verb, which currently requires that the tenant is
always explicitly specified.

Change-Id: I1706ad993059e70ca0e2f3bcf7b1d06cbcc39f2d
  • Loading branch information
Eoghan Glynn committed Dec 19, 2012
1 parent 8d36500 commit e6e22db
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion novaclient/v1_1/shell.py
Expand Up @@ -2474,7 +2474,7 @@ def do_quota_show(cs, args):
"""List the quotas for a tenant."""

if not args.tenant:
_quota_show(cs.quotas.get(cs.project_id))
raise exceptions.CommandError("you need to specify a Tenant ID ")
else:
_quota_show(cs.quotas.get(args.tenant))

Expand Down
5 changes: 5 additions & 0 deletions tests/v1_1/test_shell.py
Expand Up @@ -650,6 +650,11 @@ def test_quota_show(self):
self.run_command('quota-show --tenant test')
self.assert_called('GET', '/os-quota-sets/test')

def test_quota_show_no_tenant(self):
self.assertRaises(exceptions.CommandError,
self.run_command,
'quota-show')

def test_quota_defaults(self):
self.run_command('quota-defaults --tenant test')
self.assert_called('GET', '/os-quota-sets/test/defaults')
Expand Down

0 comments on commit e6e22db

Please sign in to comment.