From e030fa908f4fb3e0547142bf551c77a84cbb2643 Mon Sep 17 00:00:00 2001 From: "Daniel P. Berrange" Date: Fri, 15 Jan 2016 17:29:21 +0000 Subject: [PATCH] actually register the various objects we define The @base.VersionedObjectRegistry.register annotation is required to get objects registered for use. This exposed a bug in SubnetList not inheriting from the base object type, and a bug in the test suite not passing a value for the mandatory 'instance_info' property. Change-Id: I93b4583b7bb7ae014cdb176a018ab1ac4332fde6 --- os_vif/objects/instance_info.py | 1 + os_vif/objects/network.py | 1 + os_vif/objects/subnet.py | 4 +++- os_vif/objects/vif.py | 1 + os_vif/tests/test_os_vif.py | 10 ++++++++-- 5 files changed, 14 insertions(+), 3 deletions(-) diff --git a/os_vif/objects/instance_info.py b/os_vif/objects/instance_info.py index b9f89015..5ed30eee 100644 --- a/os_vif/objects/instance_info.py +++ b/os_vif/objects/instance_info.py @@ -14,6 +14,7 @@ from oslo_versionedobjects import base from oslo_versionedobjects import fields +@base.VersionedObjectRegistry.register class InstanceInfo(base.VersionedObject): """Represents important information about a Nova instance.""" # Version 1.0: Initial version diff --git a/os_vif/objects/network.py b/os_vif/objects/network.py index bab9eee5..9308a490 100644 --- a/os_vif/objects/network.py +++ b/os_vif/objects/network.py @@ -14,6 +14,7 @@ from oslo_versionedobjects import base from oslo_versionedobjects import fields +@base.VersionedObjectRegistry.register class Network(base.VersionedObject): """Represents a network.""" # Version 1.0: Initial version diff --git a/os_vif/objects/subnet.py b/os_vif/objects/subnet.py index f43c971a..11e4f303 100644 --- a/os_vif/objects/subnet.py +++ b/os_vif/objects/subnet.py @@ -16,6 +16,7 @@ from oslo_versionedobjects import base from oslo_versionedobjects import fields +@base.VersionedObjectRegistry.register class Subnet(base.VersionedObject): """Represents a subnet.""" # Version 1.0: Initial version @@ -48,7 +49,8 @@ class Subnet(base.VersionedObject): return netaddr.IPNetwork(self.cidr) -class SubnetList(base.ObjectListBase): +@base.VersionedObjectRegistry.register +class SubnetList(base.VersionedObject, base.ObjectListBase): # Version 1.0: Initial version VERSION = '1.0' diff --git a/os_vif/objects/vif.py b/os_vif/objects/vif.py index 4430004e..10bb0180 100644 --- a/os_vif/objects/vif.py +++ b/os_vif/objects/vif.py @@ -43,6 +43,7 @@ VIF_DETAILS_VHOSTUSER_MODE = 'vhostuser_mode' _NIC_NAME_LEN = 14 +@base.VersionedObjectRegistry.register class VIF(base.VersionedObject): """Represents a virtual network interface.""" # Version 1.0: Initial version diff --git a/os_vif/tests/test_os_vif.py b/os_vif/tests/test_os_vif.py index da28e1cb..f7a02d26 100644 --- a/os_vif/tests/test_os_vif.py +++ b/os_vif/tests/test_os_vif.py @@ -49,7 +49,10 @@ class TestOSVIF(base.TestCase): return_value={'foobar': plugin}): os_vif.initialize() instance = mock.MagicMock() - vif = objects.vif.VIF(id='uniq', plugin='foobar') + info = objects.instance_info.InstanceInfo() + vif = objects.vif.VIF(id='uniq', + plugin='foobar', + instance_info=info) os_vif.plug(vif, instance) plugin.plug.assert_called_once_with(vif, instance) @@ -58,6 +61,9 @@ class TestOSVIF(base.TestCase): with mock.patch('stevedore.extension.ExtensionManager', return_value={'foobar': plugin}): os_vif.initialize() - vif = objects.vif.VIF(id='uniq', plugin='foobar') + info = objects.instance_info.InstanceInfo() + vif = objects.vif.VIF(id='uniq', + plugin='foobar', + instance_info=info) os_vif.unplug(vif) plugin.unplug.assert_called_once_with(vif)