Merge "Fix repr of FloatingIPBulk"

This commit is contained in:
Jenkins 2015-03-31 21:34:37 +00:00 committed by Gerrit Code Review
commit 493a33a024
3 changed files with 15 additions and 8 deletions

@ -16,7 +16,7 @@
from novaclient.tests.unit.fixture_data import client
from novaclient.tests.unit.fixture_data import floatingips as data
from novaclient.tests.unit import utils
from novaclient.v2 import floating_ips_bulk
from novaclient.v2 import floating_ips
class FloatingIPsBulkTest(utils.FixturedTestCase):
@ -27,13 +27,13 @@ class FloatingIPsBulkTest(utils.FixturedTestCase):
def test_list_floating_ips_bulk(self):
fl = self.cs.floating_ips_bulk.list()
self.assert_called('GET', '/os-floating-ips-bulk')
[self.assertIsInstance(f, floating_ips_bulk.FloatingIP)
[self.assertIsInstance(f, floating_ips.FloatingIP)
for f in fl]
def test_list_floating_ips_bulk_host_filter(self):
fl = self.cs.floating_ips_bulk.list('testHost')
self.assert_called('GET', '/os-floating-ips-bulk/testHost')
[self.assertIsInstance(f, floating_ips_bulk.FloatingIP)
[self.assertIsInstance(f, floating_ips.FloatingIP)
for f in fl]
def test_create_floating_ips_bulk(self):

@ -24,6 +24,9 @@ class FloatingIP(base.Resource):
"""
self.manager.delete(self)
def __repr__(self):
return "<FloatingIP: %s>" % self.address
class FloatingIPManager(base.ManagerWithFind):
resource_class = FloatingIP

@ -17,25 +17,29 @@
Bulk Floating IPs interface
"""
from novaclient import base
from novaclient.v2 import floating_ips
class FloatingIP(base.Resource):
class FloatingIPRange(base.Resource):
def __repr__(self):
return "<FloatingIP: %s>" % self.address
return "<FloatingIPRange: %s>" % self.ip_range
class FloatingIPBulkManager(base.ManagerWithFind):
resource_class = FloatingIP
resource_class = FloatingIPRange
def list(self, host=None):
"""
List all floating IPs
"""
if host is None:
return self._list('/os-floating-ips-bulk', 'floating_ip_info')
return self._list('/os-floating-ips-bulk',
'floating_ip_info',
obj_class=floating_ips.FloatingIP)
else:
return self._list('/os-floating-ips-bulk/%s' % host,
'floating_ip_info')
'floating_ip_info',
obj_class=floating_ips.FloatingIP)
def create(self, ip_range, pool=None, interface=None):
"""