From 09b72cdbd602c5a387dbeb83368d43ab4e596cdc Mon Sep 17 00:00:00 2001 From: Johannes Erdfelt Date: Sun, 12 Aug 2012 04:15:41 +0000 Subject: [PATCH] Don't stuff non-db data into instance dict The RPC API passes admin_pass and injected_files as arguments, but when calling the driver API, those values get stuffed into the instance dict which is otherwise all data that is stored in the database. This has led to some bugs (such as 1034948) which could have been avoided if the code was consistent. Change-Id: I09a7de8eca3791a5ab27e93b22e5ccccee31cf09 --- nova/tests/test_libvirt.py | 3 ++- nova/tests/test_virt_drivers.py | 9 ++++----- nova/tests/test_xenapi.py | 12 +++++------- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/nova/tests/test_libvirt.py b/nova/tests/test_libvirt.py index 2fda6eb4..0a9df31e 100644 --- a/nova/tests/test_libvirt.py +++ b/nova/tests/test_libvirt.py @@ -1925,7 +1925,8 @@ class LibvirtConnTestCase(test.TestCase): fake_none) try: - conn.spawn(self.context, instance, None, network_info) + conn.spawn(self.context, instance, None, [], 'herp', + network_info=network_info) except Exception, e: # assert that no exception is raised due to sha1 receiving an int self.assertEqual(-1, unicode(e).find('must be string or buffer' diff --git a/nova/tests/test_virt_drivers.py b/nova/tests/test_virt_drivers.py index 68b4fe4f..276c1b5d 100644 --- a/nova/tests/test_virt_drivers.py +++ b/nova/tests/test_virt_drivers.py @@ -206,9 +206,8 @@ class _VirtDriverTestCase(_FakeDriverBackendTestCase): instance_ref = test_utils.get_test_instance() network_info = test_utils.get_test_network_info() image_info = test_utils.get_test_image_info(None, instance_ref) - self.connection.spawn(self.ctxt, instance=instance_ref, - image_meta=image_info, - network_info=network_info) + self.connection.spawn(self.ctxt, instance_ref, image_info, + [], 'herp', network_info=network_info) return instance_ref, network_info @catch_notimplementederror @@ -279,7 +278,7 @@ class _VirtDriverTestCase(_FakeDriverBackendTestCase): @catch_notimplementederror def test_rescue(self): instance_ref, network_info = self._get_running_instance() - self.connection.rescue(self.ctxt, instance_ref, network_info, None) + self.connection.rescue(self.ctxt, instance_ref, network_info, None, '') @catch_notimplementederror def test_unrescue_unrescued_instance(self): @@ -289,7 +288,7 @@ class _VirtDriverTestCase(_FakeDriverBackendTestCase): @catch_notimplementederror def test_unrescue_rescued_instance(self): instance_ref, network_info = self._get_running_instance() - self.connection.rescue(self.ctxt, instance_ref, network_info, None) + self.connection.rescue(self.ctxt, instance_ref, network_info, None, '') self.connection.unrescue(instance_ref, network_info) @catch_notimplementederror diff --git a/nova/tests/test_xenapi.py b/nova/tests/test_xenapi.py index ec84ba07..32106565 100644 --- a/nova/tests/test_xenapi.py +++ b/nova/tests/test_xenapi.py @@ -552,12 +552,10 @@ class XenAPIVMTestCase(stubs.XenAPITestBase): # NOTE(tr3buchet): this is a terrible way to do this... network_info[0]['network']['subnets'][0]['dns'] = [] - # admin_pass isn't part of the DB model, but it does get set as - # an attribute for spawn to use - instance.admin_pass = 'herp' image_meta = {'id': IMAGE_VHD, 'disk_format': 'vhd'} - self.conn.spawn(self.context, instance, image_meta, network_info) + self.conn.spawn(self.context, instance, image_meta, [], 'herp', + network_info) self.create_vm_record(self.conn, os_type, instance['name']) self.check_vm_record(self.conn, check_injection) self.assertTrue(instance.os_type) @@ -790,7 +788,7 @@ class XenAPIVMTestCase(stubs.XenAPITestBase): conn = xenapi_conn.XenAPIDriver(False) image_meta = {'id': IMAGE_VHD, 'disk_format': 'vhd'} - conn.rescue(self.context, instance, [], image_meta) + conn.rescue(self.context, instance, [], image_meta, '') vm = xenapi_fake.get_record('VM', vm_ref) rescue_name = "%s-rescue" % vm["name_label"] @@ -881,8 +879,8 @@ class XenAPIVMTestCase(stubs.XenAPITestBase): image_meta = {'id': IMAGE_VHD, 'disk_format': 'vhd'} if spawn: - instance.admin_pass = 'herp' - self.conn.spawn(self.context, instance, image_meta, network_info) + self.conn.spawn(self.context, instance, image_meta, [], 'herp', + network_info) return instance