From 09e682555fe5b0839721a89716a1fd302bf9b6d3 Mon Sep 17 00:00:00 2001 From: Johannes Erdfelt Date: Fri, 13 Apr 2012 22:26:13 +0000 Subject: [PATCH] Merge _spawn and _configure_instance in xenapi driver They were separated only to make it easier to stubout, but we want more test coverage, not less. So merge them together and fix the tests while we're at it. Change-Id: I18333017868b91fb71b8d3dce831463a1cd5bf81 --- nova/tests/test_xenapi.py | 10 ++++------ nova/tests/xenapi/stubs.py | 4 ---- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/nova/tests/test_xenapi.py b/nova/tests/test_xenapi.py index 913f5008..3e8f6ab7 100644 --- a/nova/tests/test_xenapi.py +++ b/nova/tests/test_xenapi.py @@ -211,10 +211,6 @@ class XenAPIVolumeTestCase(test.TestCase): '/dev/sdc') -def configure_instance(*args): - pass - - class XenAPIVMTestCase(test.TestCase): """Unit tests for VM operations.""" def setUp(self): @@ -234,8 +230,6 @@ class XenAPIVMTestCase(test.TestCase): stubs.stubout_get_this_vm_uuid(self.stubs) stubs.stubout_stream_disk(self.stubs) stubs.stubout_is_vdi_pv(self.stubs) - self.stubs.Set(vmops.VMOps, '_configure_instance', - configure_instance) stubs.stub_out_vm_methods(self.stubs) glance_stubs.stubout_glance_client(self.stubs) fake_utils.stub_out_utils_execute(self.stubs) @@ -480,6 +474,9 @@ class XenAPIVMTestCase(test.TestCase): if empty_dns: network_info[0][1]['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': glance_stubs.FakeGlance.IMAGE_VHD, 'disk_format': 'vhd'} self.conn.spawn(self.context, instance, image_meta, network_info) @@ -778,6 +775,7 @@ class XenAPIVMTestCase(test.TestCase): image_meta = {'id': glance_stubs.FakeGlance.IMAGE_VHD, 'disk_format': 'vhd'} if spawn: + instance.admin_pass = 'herp' self.conn.spawn(self.context, instance, image_meta, network_info) return instance diff --git a/nova/tests/xenapi/stubs.py b/nova/tests/xenapi/stubs.py index 533c1289..e6510125 100644 --- a/nova/tests/xenapi/stubs.py +++ b/nova/tests/xenapi/stubs.py @@ -389,9 +389,6 @@ def stub_out_migration_methods(stubs): def fake_destroy(*args, **kwargs): pass - def fake_reset_network(*args, **kwargs): - pass - @classmethod def fake_generate_ephemeral(cls, *args): pass @@ -402,5 +399,4 @@ def stub_out_migration_methods(stubs): stubs.Set(vmops.VMOps, '_create_snapshot', fake_create_snapshot) stubs.Set(vm_utils.VMHelper, 'get_vdi_for_vm_safely', fake_get_vdi) stubs.Set(vm_utils.VMHelper, 'get_sr_path', fake_get_sr_path) - stubs.Set(vmops.VMOps, 'reset_network', fake_reset_network) stubs.Set(vm_utils.VMHelper, 'generate_ephemeral', fake_generate_ephemeral)