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
This commit is contained in:
Rick Harris
2012-06-25 22:49:17 +00:00
parent 9afa94f801
commit 56e37cebec
2 changed files with 5 additions and 6 deletions

View File

@@ -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)

View File

@@ -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):