summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--nova/tests/virt_unittest.py2
-rw-r--r--nova/tests/xenapi/stubs.py24
-rw-r--r--nova/tests/xenapi_unittest.py5
-rw-r--r--nova/virt/xenapi/fake.py1
-rw-r--r--nova/virt/xenapi/volume_utils.py29
5 files changed, 29 insertions, 32 deletions
diff --git a/nova/tests/virt_unittest.py b/nova/tests/virt_unittest.py
index 52843b703..d49383fb7 100644
--- a/nova/tests/virt_unittest.py
+++ b/nova/tests/virt_unittest.py
@@ -25,8 +25,6 @@ from nova import utils
from nova.api.ec2 import cloud
from nova.auth import manager
from nova.virt import libvirt_conn
-from nova.virt.xenapi import fake
-from nova.virt.xenapi import volume_utils
FLAGS = flags.FLAGS
flags.DECLARE('instances_path', 'nova.compute.manager')
diff --git a/nova/tests/xenapi/stubs.py b/nova/tests/xenapi/stubs.py
index 525189388..11dd535d4 100644
--- a/nova/tests/xenapi/stubs.py
+++ b/nova/tests/xenapi/stubs.py
@@ -58,21 +58,12 @@ class FakeSessionForVolumeTests(fake.SessionBase):
def __init__(self, uri):
super(FakeSessionForVolumeTests, self).__init__(uri)
- def VBD_plug(self, _1, _2):
- #FIXME(armando):make proper plug
- pass
-
- def PBD_unplug(self, _1, _2):
- #FIXME(armando):make proper unplug
- pass
-
- def SR_forget(self, _1, _2):
- #FIXME(armando):make proper forget
- pass
+ def VBD_plug(self, _1, ref):
+ rec = fake.get_record('VBD', ref)
+ rec['currently-attached'] = True
def VDI_introduce(self, _1, uuid, _2, _3, _4, _5,
_6, _7, _8, _9, _10, _11):
- #FIXME(armando):make proper introduce
valid_vdi = False
refs = fake.get_all('VDI')
for ref in refs:
@@ -93,6 +84,9 @@ class FakeSessionForVolumeFailedTests(FakeSessionForVolumeTests):
# This is for testing failure
raise fake.Failure([['INVALID_VDI', 'session', self._session]])
- def VBD_plug(self, _1, _2):
- # This is for testing failure
- raise fake.Failure([['INVALID_VBD', 'session', self._session]])
+ def PBD_unplug(self, _1, ref):
+ rec = fake.get_record('PBD', ref)
+ rec['currently-attached'] = False
+
+ def SR_forget(self, _1, ref):
+ pass
diff --git a/nova/tests/xenapi_unittest.py b/nova/tests/xenapi_unittest.py
index c2612a4c5..839d6aa44 100644
--- a/nova/tests/xenapi_unittest.py
+++ b/nova/tests/xenapi_unittest.py
@@ -141,14 +141,13 @@ class XenAPIVolumeTestCase(test.TrialTestCase):
result = conn.attach_volume(instance.name, volume['ec2_id'],
'/dev/sdc')
- def check(exc):
+ def check_exception(exc):
""" handler """
if exc:
pass
else:
self.fail('Oops, no exception has been raised!')
-
- result.addErrback(check)
+ result.addErrback(check_exception)
return result
def tearDown(self):
diff --git a/nova/virt/xenapi/fake.py b/nova/virt/xenapi/fake.py
index a46f3fd80..7877b5905 100644
--- a/nova/virt/xenapi/fake.py
+++ b/nova/virt/xenapi/fake.py
@@ -102,6 +102,7 @@ def create_vdi(name_label, read_only, sr_ref, sharable):
'location': '',
'xenstore_data': '',
'sm_config': {},
+ 'VBDs': {},
})
diff --git a/nova/virt/xenapi/volume_utils.py b/nova/virt/xenapi/volume_utils.py
index 4482e465c..8d1d6fb81 100644
--- a/nova/virt/xenapi/volume_utils.py
+++ b/nova/virt/xenapi/volume_utils.py
@@ -152,18 +152,23 @@ class VolumeHelper(HelperBase):
logging.warn(exc)
raise StorageError('Unable to get record of VDI %s on' % vdis[0])
else:
- return session.get_xenapi().VDI.introduce(
- vdi_rec['uuid'],
- vdi_rec['name_label'],
- vdi_rec['name_description'],
- vdi_rec['SR'],
- vdi_rec['type'],
- vdi_rec['sharable'],
- vdi_rec['read_only'],
- vdi_rec['other_config'],
- vdi_rec['location'],
- vdi_rec['xenstore_data'],
- vdi_rec['sm_config'])
+ try:
+ vdi_ref = session.get_xenapi().VDI.introduce(
+ vdi_rec['uuid'],
+ vdi_rec['name_label'],
+ vdi_rec['name_description'],
+ vdi_rec['SR'],
+ vdi_rec['type'],
+ vdi_rec['sharable'],
+ vdi_rec['read_only'],
+ vdi_rec['other_config'],
+ vdi_rec['location'],
+ vdi_rec['xenstore_data'],
+ vdi_rec['sm_config'])
+ except cls.XenAPI.Failure, exc:
+ logging.warn(exc)
+ raise StorageError('Unable to introduce VDI for SR %s'
+ % sr_ref)
@classmethod
@defer.inlineCallbacks