summaryrefslogtreecommitdiffstats
path: root/nova/tests
diff options
context:
space:
mode:
authorArmando Migliaccio <amigliaccio@internap.com>2012-12-07 21:06:43 +0000
committerArmando Migliaccio <amigliaccio@internap.com>2012-12-12 23:15:34 +0000
commit503d5729547f135951d75d5237b398fe1700aaf2 (patch)
tree970b14385d25e815a692e29ca1a4ff405eb9df46 /nova/tests
parent46675d85dbb6c3fb7e417eb0c7ad4a4cccb30523 (diff)
Fixes KeyError: 'sr_uuid' when booting from volume on xenapi
This change fixes the capability for a XenServer/XCP hypervisor to boot instances from an iscsi volume running on Cinder. This patch takes into account that Cinder can be configured with an iscsi back-end, instead of a xensm one, where keys like sr_uuid are not being specified. It works through the magic of determining the SR, and the vdi associated with the iscsi target and lun. This patch also does a bit of clean-up of code/comments that no longer apply. Addresses bug #1087308 Change-Id: Ie7d65eeb965b3468e4407981788725e2b43bff5e
Diffstat (limited to 'nova/tests')
-rw-r--r--nova/tests/xenapi/test_vm_utils.py52
1 files changed, 35 insertions, 17 deletions
diff --git a/nova/tests/xenapi/test_vm_utils.py b/nova/tests/xenapi/test_vm_utils.py
index 3a8c9a640..a12c0f268 100644
--- a/nova/tests/xenapi/test_vm_utils.py
+++ b/nova/tests/xenapi/test_vm_utils.py
@@ -10,6 +10,29 @@ from nova.virt.xenapi import volume_utils
import unittest
+XENSM_TYPE = 'xensm'
+ISCSI_TYPE = 'iscsi'
+
+
+def get_fake_dev_params(sr_type):
+ fakes = {XENSM_TYPE: {'sr_uuid': 'falseSR',
+ 'name_label': 'fake_storage',
+ 'name_description': 'test purposes',
+ 'server': 'myserver',
+ 'serverpath': '/local/scratch/myname',
+ 'sr_type': 'nfs',
+ 'introduce_sr_keys': ['server',
+ 'serverpath',
+ 'sr_type'],
+ 'vdi_uuid': 'falseVDI'},
+ ISCSI_TYPE: {'volume_id': 'fake_volume_id',
+ 'target_lun': 1,
+ 'target_iqn': 'fake_iqn:volume-fake_volume_id',
+ 'target_portal': u'localhost:3260',
+ 'target_discovered': False}, }
+ return fakes[sr_type]
+
+
class GetInstanceForVdisForSrTestCase(stubs.XenAPITestBase):
def setUp(self):
super(GetInstanceForVdisForSrTestCase, self).setUp()
@@ -50,15 +73,8 @@ class GetInstanceForVdisForSrTestCase(stubs.XenAPITestBase):
self.assertEquals([], result)
- def test_get_vdis_for_boot_from_vol(self):
- dev_params = {'sr_uuid': 'falseSR',
- 'name_label': 'fake_storage',
- 'name_description': 'test purposes',
- 'server': 'myserver',
- 'serverpath': '/local/scratch/myname',
- 'sr_type': 'nfs',
- 'introduce_sr_keys': ['server', 'serverpath', 'sr_type'],
- 'vdi_uuid': 'falseVDI'}
+ def test_get_vdis_for_boot_from_vol_with_sr_uuid(self):
+ dev_params = get_fake_dev_params(XENSM_TYPE)
stubs.stubout_session(self.stubs, fake.SessionBase)
driver = xenapi_conn.XenAPIDriver(False)
@@ -74,18 +90,20 @@ class GetInstanceForVdisForSrTestCase(stubs.XenAPITestBase):
return None
self.stubs.Set(volume_utils, 'introduce_sr', bad_introduce_sr)
- dev_params = {'sr_uuid': 'falseSR',
- 'name_label': 'fake_storage',
- 'name_description': 'test purposes',
- 'server': 'myserver',
- 'serverpath': '/local/scratch/myname',
- 'sr_type': 'nfs',
- 'introduce_sr_keys': ['server', 'serverpath', 'sr_type'],
- 'vdi_uuid': 'falseVDI'}
+ dev_params = get_fake_dev_params(XENSM_TYPE)
self.assertRaises(exception.NovaException,
vm_utils.get_vdis_for_boot_from_vol,
driver._session, dev_params)
+ def test_get_vdis_for_boot_from_iscsi_vol_missing_sr_uuid(self):
+ dev_params = get_fake_dev_params(ISCSI_TYPE)
+ stubs.stubout_session(self.stubs, fake.SessionBase)
+ driver = xenapi_conn.XenAPIDriver(False)
+
+ result = vm_utils.get_vdis_for_boot_from_vol(driver._session,
+ dev_params)
+ self.assertNotEquals(result['root']['uuid'], None)
+
class VMRefOrRaiseVMFoundTestCase(unittest.TestCase):