From c56e093327834ea1c18647fc14e06298f2351617 Mon Sep 17 00:00:00 2001 From: Nikola Dipanov Date: Mon, 1 Sep 2014 09:12:29 +0200 Subject: [PATCH] InstanceNUMAToplogy object create remove uuid param We can get this from the object attribute so no need to pass it in explicitly. We do not need to bump the version of the object as there is no code calling it as of yet, so we do not have to support the broken method interface until the next major version bump. Change-Id: I96e1d958e907272d94d7ca6481592b79ea6b6397 Blueprint: virt-driver-numa-placement --- nova/objects/instance.py | 3 ++- nova/objects/instance_numa_topology.py | 4 ++-- nova/tests/objects/test_instance_numa_topology.py | 3 ++- nova/tests/objects/test_objects.py | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/nova/objects/instance.py b/nova/objects/instance.py index 233418893153..6f10d8c3ca4c 100644 --- a/nova/objects/instance.py +++ b/nova/objects/instance.py @@ -350,7 +350,8 @@ class Instance(base.NovaPersistentObject, base.NovaObject): db_inst = db.instance_create(context, updates) if numa_topology: expected_attrs.append('numa_topology') - numa_topology.create(context, db_inst['uuid']) + numa_topology.instance_uuid = db_inst['uuid'] + numa_topology.create(context) self._from_db_object(context, self, db_inst, expected_attrs) @base.remotable diff --git a/nova/objects/instance_numa_topology.py b/nova/objects/instance_numa_topology.py index 57b5df54409c..6e7a9ab8ad03 100644 --- a/nova/objects/instance_numa_topology.py +++ b/nova/objects/instance_numa_topology.py @@ -62,14 +62,14 @@ class InstanceNUMATopology(base.NovaObject): return hardware.VirtNUMAInstanceTopology(cells=cells) @base.remotable - def create(self, context, instance_uuid): + def create(self, context): if self.obj_attr_is_set('id'): raise exception.ObjectActionError(action='create', reason='already created') topology = self.topology_from_obj() if not topology: return - values = {'instance_uuid': instance_uuid, + values = {'instance_uuid': self.instance_uuid, 'numa_topology': topology.to_json()} db_object = db.instance_extra_create(context, values) self.instance_uuid = db_object['instance_uuid'] diff --git a/nova/tests/objects/test_instance_numa_topology.py b/nova/tests/objects/test_instance_numa_topology.py index 77623a8f560d..67289f298f1e 100644 --- a/nova/tests/objects/test_instance_numa_topology.py +++ b/nova/tests/objects/test_instance_numa_topology.py @@ -38,7 +38,8 @@ class _TestInstanceNUMATopology(object): def test_create(self): topo_obj = objects.InstanceNUMATopology.obj_from_topology( fake_numa_topology) - topo_obj.create(self.context, fake_db_topology['instance_uuid']) + topo_obj.instance_uuid = fake_db_topology['instance_uuid'] + topo_obj.create(self.context) got = objects.InstanceNUMATopology.get_by_instance_uuid( self.context, fake_db_topology['instance_uuid']) self.assertIsNotNone(got) diff --git a/nova/tests/objects/test_objects.py b/nova/tests/objects/test_objects.py index 3555749932a9..362319153b2b 100644 --- a/nova/tests/objects/test_objects.py +++ b/nova/tests/objects/test_objects.py @@ -961,7 +961,7 @@ object_data = { 'InstanceInfoCache': '1.5-ef64b604498bfa505a8c93747a9d8b2f', 'InstanceList': '1.8-16db4c93fe5b80564413b9a4f547e0d1', 'InstanceNUMACell': '1.0-17e6ee0a24cb6651d1b084efa3027bda', - 'InstanceNUMATopology': '1.0-a4264388d42c21a692cb74ed8fa8bb4d', + 'InstanceNUMATopology': '1.0-86b95d263c4c68411d44c6741b8d2bb0', 'KeyPair': '1.1-3410f51950d052d861c11946a6ae621a', 'KeyPairList': '1.0-71132a568cc5d078ba1748a9c02c87b8', 'Migration': '1.1-67c47726c2c71422058cd9d149d6d3ed',