summaryrefslogtreecommitdiffstats
path: root/nova/tests
diff options
context:
space:
mode:
authorMarco Sinhoreli <msinhore@gmail.com>2012-07-23 15:24:59 -0300
committerMarco Sinhoreli <msinhore@gmail.com>2012-07-23 17:16:12 -0300
commit9a2cc2544a4e6609c409b06c8ff91d596fe43a8c (patch)
tree118a284e8f04b8b8e39f70c9f7a0d6dced86218c /nova/tests
parent62b75bf7c4259993e493d66d2fdf256d59ed4aa9 (diff)
Adds xcp disk resize support.
Implements resize image during instance creation. Fixes bug 1016650. Change-Id: I25f9d1030d9d014b1c9a65430bd535388b8f8943
Diffstat (limited to 'nova/tests')
-rw-r--r--nova/tests/test_xenapi.py28
-rw-r--r--nova/tests/xenapi/stubs.py7
2 files changed, 31 insertions, 4 deletions
diff --git a/nova/tests/test_xenapi.py b/nova/tests/test_xenapi.py
index 9486f4144..81c1ab909 100644
--- a/nova/tests/test_xenapi.py
+++ b/nova/tests/test_xenapi.py
@@ -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,
diff --git a/nova/tests/xenapi/stubs.py b/nova/tests/xenapi/stubs.py
index 483356424..b7de16e9c 100644
--- a/nova/tests/xenapi/stubs.py
+++ b/nova/tests/xenapi/stubs.py
@@ -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):