diff --git a/nova/objects/floating_ip.py b/nova/objects/floating_ip.py index 719dbe3321e2..9881dfcecfff 100644 --- a/nova/objects/floating_ip.py +++ b/nova/objects/floating_ip.py @@ -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) + } diff --git a/nova/tests/unit/objects/test_floating_ip.py b/nova/tests/unit/objects/test_floating_ip.py index 7cfa286e2743..85a1136d8d42 100644 --- a/nova/tests/unit/objects/test_floating_ip.py +++ b/nova/tests/unit/objects/test_floating_ip.py @@ -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)