From 6c3bc216c1f35c42604b685eebd8fa25828d0e0e Mon Sep 17 00:00:00 2001 From: Devdeep Singh Date: Tue, 17 Jan 2012 18:59:14 +0530 Subject: Changes for supporting fast cloning on Xenserver. Implements blueprint fast-cloning-for-xenserver 1. use_cow_images flag is reused for xenserver to check if copy on write images should be used. 2. image-id is used to tag an image which has already been streamed from glance. 3. If cow is true, when an instance of an image is created for the first time on a given xenserver, the image is streamed from glance and copy on write disk is created for the instance. 4. For subsequent instance creation requests (of the same image), a copy on write disk is created from the base image that is already present on the host. 5. If cow is false, when an instance of an image is created for the first time on a host, the image is streamed from glance and its copy is made to create a virtual disk for the instance. 6. For subsequent instance creation requests, a copy of disk is made for creating the disk for the instance. 7. Snapshot creation code was updated to handle cow=true. Now there can be upto 3 disks in the chain. The base disk needs to be uploaded too. 8. Also added a cache_images flag. Depending on whether the flag is turned on on not, images will be cached on the host. Change-Id: I54838a24b061c134877f3479c925c6ee78da14bc --- nova/tests/test_xenapi.py | 9 ++++++++- nova/tests/xenapi/stubs.py | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) (limited to 'nova/tests') diff --git a/nova/tests/test_xenapi.py b/nova/tests/test_xenapi.py index ec10defea..6fc7fdf7d 100644 --- a/nova/tests/test_xenapi.py +++ b/nova/tests/test_xenapi.py @@ -399,7 +399,14 @@ class XenAPIVMTestCase(test.TestCase): def _check_vdis(self, start_list, end_list): for vdi_ref in end_list: if not vdi_ref in start_list: - self.fail('Found unexpected VDI:%s' % vdi_ref) + vdi_rec = xenapi_fake.get_record('VDI', vdi_ref) + # If the cache is turned on then the base disk will be + # there even after the cleanup + if 'other_config' in vdi_rec: + if vdi_rec['other_config']['image-id'] is None: + self.fail('Found unexpected VDI:%s' % vdi_ref) + else: + self.fail('Found unexpected VDI:%s' % vdi_ref) def _test_spawn(self, image_ref, kernel_id, ramdisk_id, instance_type_id="3", os_type="linux", diff --git a/nova/tests/xenapi/stubs.py b/nova/tests/xenapi/stubs.py index 2dfece00f..27e2acd9e 100644 --- a/nova/tests/xenapi/stubs.py +++ b/nova/tests/xenapi/stubs.py @@ -46,7 +46,7 @@ def stubout_instance_snapshot(stubs): def fake_wait_for_vhd_coalesce(*args): #TODO(sirp): Should we actually fake out the data here - return "fakeparent" + return "fakeparent", "fakebase" stubs.Set(vm_utils, '_wait_for_vhd_coalesce', fake_wait_for_vhd_coalesce) -- cgit