Adds xcp disk resize support.

Implements resize image during instance creation.  Fixes bug 1016650.

Change-Id: I25f9d1030d9d014b1c9a65430bd535388b8f8943
This commit is contained in:
Marco Sinhoreli
2012-07-23 15:24:59 -03:00
parent 6d83cf7d61
commit bf04f5f1e0
2 changed files with 31 additions and 4 deletions

View File

@@ -952,7 +952,27 @@ class XenAPIMigrateInstance(stubs.XenAPITestBase):
self.stubs.Set(stubs.FakeSessionForVMTests,
"VDI_resize", fake_vdi_resize)
stubs.stubout_session(self.stubs, stubs.FakeSessionForVMTests,
product_version=(6, 0, 0))
product_version=(6, 0, 0),
product_brand='XenServer')
conn = xenapi_conn.XenAPIDriver(False)
vdi_ref = xenapi_fake.create_vdi('hurr', 'fake')
vdi_uuid = xenapi_fake.get_record('VDI', vdi_ref)['uuid']
conn._vmops._resize_instance(instance,
{'uuid': vdi_uuid, 'ref': vdi_ref})
self.assertEqual(called['resize'], True)
def test_resize_xcp(self):
instance = db.instance_create(self.context, self.instance_values)
called = {'resize': False}
def fake_vdi_resize(*args, **kwargs):
called['resize'] = True
self.stubs.Set(stubs.FakeSessionForVMTests,
"VDI_resize", fake_vdi_resize)
stubs.stubout_session(self.stubs, stubs.FakeSessionForVMTests,
product_version=(1, 4, 99),
product_brand='XCP')
conn = xenapi_conn.XenAPIDriver(False)
vdi_ref = xenapi_fake.create_vdi('hurr', 'fake')
vdi_uuid = xenapi_fake.get_record('VDI', vdi_ref)['uuid']
@@ -1011,6 +1031,9 @@ class XenAPIMigrateInstance(stubs.XenAPITestBase):
self.stubs.Set(vmops.VMOps, '_start', fake_vm_start)
self.stubs.Set(vmops.VMOps, 'finish_revert_migration',
fake_finish_revert_migration)
stubs.stubout_session(self.stubs, stubs.FakeSessionForVMTests,
product_version=(4, 0, 0),
product_brand='XenServer')
conn = xenapi_conn.XenAPIDriver(False)
network_info = fake_network.fake_get_instance_nw_info(self.stubs,
@@ -1043,6 +1066,9 @@ class XenAPIMigrateInstance(stubs.XenAPITestBase):
self.stubs.Set(vmops.VMOps, '_start', fake_vm_start)
self.stubs.Set(stubs.FakeSessionForVMTests,
"VDI_resize_online", fake_vdi_resize)
stubs.stubout_session(self.stubs, stubs.FakeSessionForVMTests,
product_version=(4, 0, 0),
product_brand='XenServer')
conn = xenapi_conn.XenAPIDriver(False)
network_info = fake_network.fake_get_instance_nw_info(self.stubs,

View File

@@ -53,12 +53,13 @@ def stubout_instance_snapshot(stubs):
stubs.Set(vm_utils, '_wait_for_vhd_coalesce', fake_wait_for_vhd_coalesce)
def stubout_session(stubs, cls, product_version=(5, 6, 2), **opt_args):
def stubout_session(stubs, cls, product_version=(5, 6, 2),
product_brand='XenServer', **opt_args):
"""Stubs out methods from XenAPISession"""
stubs.Set(xenapi_conn.XenAPISession, '_create_session',
lambda s, url: cls(url, **opt_args))
stubs.Set(xenapi_conn.XenAPISession, '_get_product_version',
lambda s: product_version)
stubs.Set(xenapi_conn.XenAPISession, '_get_product_version_and_brand',
lambda s: (product_version, product_brand))
def stubout_get_this_vm_uuid(stubs):