diff options
| author | matt.dietz@rackspace.com <> | 2011-06-16 13:56:52 -0500 |
|---|---|---|
| committer | matt.dietz@rackspace.com <> | 2011-06-16 13:56:52 -0500 |
| commit | 83df657360fe32315d6a55488de7dccdffa25c90 (patch) | |
| tree | 4444a0ae8c478dcc6ff94dfa2b2be60291f994da | |
| parent | 9f62def7b578fc85f85e174a031592a5c4750751 (diff) | |
| download | nova-83df657360fe32315d6a55488de7dccdffa25c90.tar.gz nova-83df657360fe32315d6a55488de7dccdffa25c90.tar.xz nova-83df657360fe32315d6a55488de7dccdffa25c90.zip | |
Added a new test for confirming failure when no primary VDI is present
| -rw-r--r-- | nova/tests/test_xenapi.py | 18 | ||||
| -rw-r--r-- | nova/virt/xenapi/vm_utils.py | 2 |
2 files changed, 19 insertions, 1 deletions
diff --git a/nova/tests/test_xenapi.py b/nova/tests/test_xenapi.py index d1c88287a..c0213250a 100644 --- a/nova/tests/test_xenapi.py +++ b/nova/tests/test_xenapi.py @@ -33,6 +33,7 @@ from nova import utils from nova.auth import manager from nova.compute import instance_types from nova.compute import power_state +from nova import exception from nova.virt import xenapi_conn from nova.virt.xenapi import fake as xenapi_fake from nova.virt.xenapi import volume_utils @@ -228,6 +229,23 @@ class XenAPIVMTestCase(test.TestCase): instance = self._create_instance() self.conn.get_diagnostics(instance) + def test_instance_snapshot_fails_with_no_primary_vdi(self): + def create_bad_vbd(vm_ref, vdi_ref): + vbd_rec = {'VM': vm_ref, + 'VDI': vdi_ref, + 'userdevice': 'fake', + 'currently_attached': False} + vbd_ref = xenapi_fake._create_object('VBD', vbd_rec) + xenapi_fake.after_VBD_create(vbd_ref, vbd_rec) + return vbd_ref + + self.stubs.Set(xenapi_fake, 'create_vbd', create_bad_vbd) + stubs.stubout_instance_snapshot(self.stubs) + instance = self._create_instance() + + name = "MySnapshot" + self.assertRaises(exception.Error, self.conn.snapshot, instance, name) + def test_instance_snapshot(self): stubs.stubout_instance_snapshot(self.stubs) instance = self._create_instance() diff --git a/nova/virt/xenapi/vm_utils.py b/nova/virt/xenapi/vm_utils.py index c91a9bab7..7597a0e82 100644 --- a/nova/virt/xenapi/vm_utils.py +++ b/nova/virt/xenapi/vm_utils.py @@ -879,7 +879,7 @@ def get_vdi_for_vm_safely(session, vm_ref): else: num_vdis = len(vdi_refs) if num_vdis != 1: - raise Exception(_("Unexpected number of VDIs (%(num_vdis)s) found" + raise exception.Exception(_("Unexpected number of VDIs (%(num_vdis)s) found" " for VM %(vm_ref)s") % locals()) vdi_ref = vdi_refs[0] |
