Merge "Refactor spawn to use UndoManager."
This commit is contained in:
@@ -517,7 +517,7 @@ class XenAPIVMTestCase(test.TestCase):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
vdi_recs_start = self._list_vdis()
|
vdi_recs_start = self._list_vdis()
|
||||||
stubs.stubout_fetch_image_glance_disk(self.stubs)
|
stubs.stubout_fetch_image_glance_disk(self.stubs, raise_failure=True)
|
||||||
self.assertRaises(xenapi_fake.Failure,
|
self.assertRaises(xenapi_fake.Failure,
|
||||||
self._test_spawn, 1, 2, 3)
|
self._test_spawn, 1, 2, 3)
|
||||||
# No additional VDI should be found.
|
# No additional VDI should be found.
|
||||||
@@ -583,6 +583,7 @@ class XenAPIVMTestCase(test.TestCase):
|
|||||||
self.check_vm_params_for_windows()
|
self.check_vm_params_for_windows()
|
||||||
|
|
||||||
def test_spawn_glance(self):
|
def test_spawn_glance(self):
|
||||||
|
stubs.stubout_fetch_image_glance_disk(self.stubs)
|
||||||
self._test_spawn(glance_stubs.FakeGlance.IMAGE_MACHINE,
|
self._test_spawn(glance_stubs.FakeGlance.IMAGE_MACHINE,
|
||||||
glance_stubs.FakeGlance.IMAGE_KERNEL,
|
glance_stubs.FakeGlance.IMAGE_KERNEL,
|
||||||
glance_stubs.FakeGlance.IMAGE_RAMDISK)
|
glance_stubs.FakeGlance.IMAGE_RAMDISK)
|
||||||
|
|||||||
@@ -124,14 +124,28 @@ def stubout_lookup_image(stubs):
|
|||||||
stubs.Set(vm_utils, 'lookup_image', f)
|
stubs.Set(vm_utils, 'lookup_image', f)
|
||||||
|
|
||||||
|
|
||||||
def stubout_fetch_image_glance_disk(stubs):
|
def stubout_fetch_image_glance_disk(stubs, raise_failure=False):
|
||||||
"""Simulates a failure in fetch image_glance_disk."""
|
"""Simulates a failure in fetch image_glance_disk."""
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def f(cls, *args):
|
def _fake_fetch_image_glance_disk(cls, context, session, instance, image,
|
||||||
raise fake.Failure("Test Exception raised by " +
|
image_type):
|
||||||
"fake fetch_image_glance_disk")
|
if raise_failure:
|
||||||
stubs.Set(vm_utils.VMHelper, '_fetch_image_glance_disk', f)
|
raise fake.Failure("Test Exception raised by "
|
||||||
|
"fake fetch_image_glance_disk")
|
||||||
|
elif image_type == vm_utils.ImageType.KERNEL:
|
||||||
|
filename = "kernel"
|
||||||
|
elif image_type == vm_utils.ImageType.RAMDISK:
|
||||||
|
filename = "ramdisk"
|
||||||
|
else:
|
||||||
|
filename = "unknown"
|
||||||
|
|
||||||
|
return [dict(vdi_type=vm_utils.ImageType.to_string(image_type),
|
||||||
|
vdi_uuid=None,
|
||||||
|
file=filename)]
|
||||||
|
|
||||||
|
stubs.Set(vm_utils.VMHelper, '_fetch_image_glance_disk',
|
||||||
|
_fake_fetch_image_glance_disk)
|
||||||
|
|
||||||
|
|
||||||
def stubout_create_vm(stubs):
|
def stubout_create_vm(stubs):
|
||||||
|
|||||||
Reference in New Issue
Block a user