From 7dcd6df29b5b720967cbbc0da5917540d001c763 Mon Sep 17 00:00:00 2001 From: Rick Harris Date: Mon, 25 Jun 2012 22:49:17 +0000 Subject: [PATCH] Refactor Dom0 Glance plugin. Moves shareable code out to a new utils file where future Dom0 plugins can make use of it. Change-Id: I57eb20b4ca308fdda424599d36d94f120d99ec0d --- nova/tests/test_xenapi.py | 4 ++-- nova/tests/xenapi/stubs.py | 7 +++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/nova/tests/test_xenapi.py b/nova/tests/test_xenapi.py index 668172a92..c4b3262f5 100644 --- a/nova/tests/test_xenapi.py +++ b/nova/tests/test_xenapi.py @@ -561,7 +561,7 @@ class XenAPIVMTestCase(test.TestCase): """ vdi_recs_start = self._list_vdis() - stubs.stubout_fetch_image_glance_disk(self.stubs, raise_failure=True) + stubs.stubout_fetch_disk_image(self.stubs, raise_failure=True) self.assertRaises(xenapi_fake.Failure, self._test_spawn, 1, 2, 3) # No additional VDI should be found. @@ -627,7 +627,7 @@ class XenAPIVMTestCase(test.TestCase): self.check_vm_params_for_windows() def test_spawn_glance(self): - stubs.stubout_fetch_image_glance_disk(self.stubs) + stubs.stubout_fetch_disk_image(self.stubs) self._test_spawn(IMAGE_MACHINE, IMAGE_KERNEL, IMAGE_RAMDISK) diff --git a/nova/tests/xenapi/stubs.py b/nova/tests/xenapi/stubs.py index 47b950e01..2b43b53a0 100644 --- a/nova/tests/xenapi/stubs.py +++ b/nova/tests/xenapi/stubs.py @@ -125,10 +125,10 @@ def stubout_lookup_image(stubs): stubs.Set(vm_utils, 'lookup_image', f) -def stubout_fetch_image_glance_disk(stubs, raise_failure=False): +def stubout_fetch_disk_image(stubs, raise_failure=False): """Simulates a failure in fetch image_glance_disk.""" - def _fake_fetch_image_glance_disk(context, session, instance, image, + def _fake_fetch_disk_image(context, session, instance, image, image_type): if raise_failure: raise fake.Failure("Test Exception raised by " @@ -143,8 +143,7 @@ def stubout_fetch_image_glance_disk(stubs, raise_failure=False): vdi_type = vm_utils.ImageType.to_string(image_type) return {vdi_type: dict(uuid=None, file=filename)} - stubs.Set(vm_utils, '_fetch_image_glance_disk', - _fake_fetch_image_glance_disk) + stubs.Set(vm_utils, '_fetch_disk_image', _fake_fetch_disk_image) def stubout_create_vm(stubs):