Add new NeutronFloatingIP object

Because floating IPs in Neutron have UUIDs for ids, a new object for
floating IPs needs to be made that can hold a UUID instead of an integer
in the id field. Fixed IPs also have UUIDs, so the fixed_ip_id field in
the floating IP object also needs to have a UUID.

Change-Id: I939c3b9d9c8f0bf5c9e441d054dc72ef8e8acd70
This commit is contained in:
Ryan Rossiter 2016-04-04 14:21:27 +00:00
parent d57a4e8be9
commit 5cc4c07e0c
2 changed files with 28 additions and 0 deletions

View File

@ -227,3 +227,16 @@ class FloatingIPList(obj_base.ObjectListBase, obj_base.NovaObject):
@obj_base.remotable_classmethod
def destroy(cls, context, ips):
db.floating_ip_bulk_destroy(context, ips)
# We don't want to register this object because it will not be passed
# around on RPC, it just makes our lives a lot easier in the API when
# dealing with floating IP operations
@obj_base.NovaObjectRegistry.register_if(False)
class NeutronFloatingIP(FloatingIP):
# Version 1.0: Initial Version
VERSION = '1.0'
fields = {
'id': fields.UUIDField(),
'fixed_ip_id': fields.UUIDField(nullable=True)
}

View File

@ -20,6 +20,7 @@ from oslo_versionedobjects import base as ovo_base
from nova import exception
from nova import objects
from nova.objects import floating_ip
from nova import test
from nova.tests.unit.objects import test_fixed_ip
from nova.tests.unit.objects import test_network
from nova.tests.unit.objects import test_objects
@ -263,3 +264,17 @@ class TestFloatingIPObject(test_objects._LocalTest,
class TestRemoteFloatingIPObject(test_objects._RemoteTest,
_TestFloatingIPObject):
pass
class TestNeutronFloatingIPObject(test.NoDBTestCase):
def test_create_with_uuid_id(self):
uuid = 'fc9b4956-fd97-11e5-86aa-5e5517507c66'
fip = objects.floating_ip.NeutronFloatingIP(id=uuid)
self.assertEqual(uuid, fip.id)
def test_create_with_uuid_fixed_id(self):
uuid = 'fc9b4c3a-fd97-11e5-86aa-5e5517507c66'
fip = objects.floating_ip.NeutronFloatingIP(fixed_ip_id=uuid)
self.assertEqual(uuid, fip.fixed_ip_id)