Merge "Add new NeutronFloatingIP object"

This commit is contained in:
Jenkins
2016-04-14 16:31:42 +00:00
committed by Gerrit Code Review
2 changed files with 28 additions and 0 deletions
+13
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)
}
@@ -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)