Merge "Allow admin user to get all tenant's floating IPs"
This commit is contained in:
commit
ee80b107d7
@ -25,9 +25,16 @@ cs = fakes.FakeClient()
|
||||
class FloatingIPsTest(utils.TestCase):
|
||||
|
||||
def test_list_floating_ips(self):
|
||||
fl = cs.floating_ips.list()
|
||||
fips = cs.floating_ips.list()
|
||||
cs.assert_called('GET', '/os-floating-ips')
|
||||
[self.assertIsInstance(f, floating_ips.FloatingIP) for f in fl]
|
||||
for fip in fips:
|
||||
self.assertIsInstance(fip, floating_ips.FloatingIP)
|
||||
|
||||
def test_list_floating_ips_all_tenants(self):
|
||||
fips = cs.floating_ips.list(all_tenants=True)
|
||||
cs.assert_called('GET', '/os-floating-ips?all_tenants=1')
|
||||
for fip in fips:
|
||||
self.assertIsInstance(fip, floating_ips.FloatingIP)
|
||||
|
||||
def test_delete_floating_ip(self):
|
||||
fl = cs.floating_ips.list()[0]
|
||||
|
@ -1037,6 +1037,10 @@ class ShellTest(utils.TestCase):
|
||||
self.run_command('floating-ip-list')
|
||||
self.assert_called('GET', '/os-floating-ips')
|
||||
|
||||
def test_floating_ip_list_all_tenants(self):
|
||||
self.run_command('floating-ip-list --all-tenants')
|
||||
self.assert_called('GET', '/os-floating-ips?all_tenants=1')
|
||||
|
||||
def test_floating_ip_create(self):
|
||||
self.run_command('floating-ip-create')
|
||||
self.assert_called('GET', '/os-floating-ips/1')
|
||||
|
@ -28,11 +28,14 @@ class FloatingIP(base.Resource):
|
||||
class FloatingIPManager(base.ManagerWithFind):
|
||||
resource_class = FloatingIP
|
||||
|
||||
def list(self):
|
||||
def list(self, all_tenants=False):
|
||||
"""
|
||||
List floating ips for a tenant
|
||||
List floating ips
|
||||
"""
|
||||
return self._list("/os-floating-ips", "floating_ips")
|
||||
url = '/os-floating-ips'
|
||||
if all_tenants:
|
||||
url += '?all_tenants=1'
|
||||
return self._list(url, "floating_ips")
|
||||
|
||||
def create(self, pool=None):
|
||||
"""
|
||||
|
@ -2031,9 +2031,13 @@ def do_floating_ip_delete(cs, args):
|
||||
args.address)
|
||||
|
||||
|
||||
def do_floating_ip_list(cs, _args):
|
||||
"""List floating ips for this tenant."""
|
||||
_print_floating_ip_list(cs.floating_ips.list())
|
||||
@utils.arg('--all-tenants',
|
||||
action='store_true',
|
||||
default=False,
|
||||
help=_('Display floatingips from all tenants (Admin only).'))
|
||||
def do_floating_ip_list(cs, args):
|
||||
"""List floating ips."""
|
||||
_print_floating_ip_list(cs.floating_ips.list(args.all_tenants))
|
||||
|
||||
|
||||
def do_floating_ip_pool_list(cs, _args):
|
||||
|
Loading…
Reference in New Issue
Block a user