Merge "Find floating ip by ip address"

This commit is contained in:
Jenkins
2017-03-29 03:16:14 +00:00
committed by Gerrit Code Review
2 changed files with 9 additions and 1 deletions

View File

@@ -48,6 +48,9 @@ class FloatingIP(resource.Resource):
fixed_ip_address = resource.Body('fixed_ip_address')
#: The floating IP address.
floating_ip_address = resource.Body('floating_ip_address')
#: Floating IP object doesn't have name attribute, set ip address to name
#: so that user could find floating IP by UUID or IP address using find_ip
name = floating_ip_address
#: The ID of the network associated with the floating IP.
floating_network_id = resource.Body('floating_network_id')
#: The port ID.

View File

@@ -118,10 +118,15 @@ class TestFloatingIP(base.BaseFunctionalTest):
cls.assertIs(cls.name, sub.name)
return sub
def test_find(self):
def test_find_by_id(self):
sot = self.conn.network.find_ip(self.FIP.id)
self.assertEqual(self.FIP.id, sot.id)
def test_find_by_ip_address(self):
sot = self.conn.network.find_ip(self.FIP.floating_ip_address)
self.assertEqual(self.FIP.floating_ip_address, sot.floating_ip_address)
self.assertEqual(self.FIP.floating_ip_address, sot.name)
def test_find_available_ip(self):
sot = self.conn.network.find_available_ip()
self.assertIsNotNone(sot.id)