Merge "Return Customer's Quota Usage through Admin API"

This commit is contained in:
Jenkins 2013-06-25 22:34:42 +00:00 committed by Gerrit Code Review
commit abb57b6934
4 changed files with 25 additions and 3 deletions

View File

@ -14,6 +14,11 @@ class LimitsTest(utils.TestCase):
cs.assert_called('GET', '/limits')
self.assertTrue(isinstance(obj, limits.Limits))
def test_get_limits_for_a_tenant(self):
obj = cs.limits.get(tenant_id=1234)
cs.assert_called('GET', '/limits?tenant_id=1234')
self.assertTrue(isinstance(obj, limits.Limits))
def test_absolute_limits(self):
obj = cs.limits.get()
@ -42,6 +47,7 @@ class LimitsTest(utils.TestCase):
limits.AbsoluteLimit("maxPersonalitySize", 10240),
)
cs.assert_called('GET', '/limits?reserved=1')
abs_limits = list(obj.absolute)
self.assertEqual(len(abs_limits), len(expected))

View File

@ -1313,6 +1313,9 @@ class ShellTest(utils.TestCase):
self.run_command('absolute-limits --reserved')
self.assert_called('GET', '/limits?reserved=1')
self.run_command('absolute-limits --tenant 1234')
self.assert_called('GET', '/limits?tenant_id=1234')
def test_evacuate(self):
self.run_command('evacuate sample-server new_host')
self.assert_called('POST', '/servers/1234/action',

View File

@ -1,5 +1,7 @@
# Copyright 2011 OpenStack Foundation
import urllib
from novaclient import base
@ -70,12 +72,17 @@ class LimitsManager(base.Manager):
resource_class = Limits
def get(self, reserved=False):
def get(self, reserved=False, tenant_id=None):
"""
Get a specific extension.
:rtype: :class:`Limits`
"""
query_string = "?reserved=1" if reserved else ""
opts = {}
if reserved:
opts['reserved'] = 1
if tenant_id:
opts['tenant_id'] = tenant_id
query_string = "?%s" % urllib.urlencode(opts) if opts else ""
return self._get("/limits%s" % query_string, "limits")

View File

@ -2190,6 +2190,12 @@ def do_keypair_show(cs, args):
_print_keypair(keypair)
@utils.arg('--tenant',
#nova db searches by project_id
dest='tenant',
metavar='<tenant>',
nargs='?',
help='Display information from single tenant (Admin only).')
@utils.arg('--reserved',
dest='reserved',
action='store_true',
@ -2197,7 +2203,7 @@ def do_keypair_show(cs, args):
help='Include reservations count.')
def do_absolute_limits(cs, args):
"""Print a list of absolute limits for a user"""
limits = cs.limits.get(args.reserved).absolute
limits = cs.limits.get(args.reserved, args.tenant).absolute
columns = ['Name', 'Value']
utils.print_list(limits, columns)