summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--nova/tests/test_xenapi.py35
-rw-r--r--nova/tests/xenapi/stubs.py6
-rw-r--r--nova/virt/xenapi/vm_utils.py18
-rw-r--r--nova/virt/xenapi_conn.py7
-rw-r--r--plugins/xenserver/xenapi/etc/xapi.d/plugins/glance1
5 files changed, 38 insertions, 29 deletions
diff --git a/nova/tests/test_xenapi.py b/nova/tests/test_xenapi.py
index 1c5a81f0d..feaced8ac 100644
--- a/nova/tests/test_xenapi.py
+++ b/nova/tests/test_xenapi.py
@@ -343,8 +343,10 @@ class XenAPIVMTestCase(test.TestCase):
1, 2, 3, "m1.xlarge")
def test_spawn_fail_cleanup_1(self):
- """Simulates an error while downloading image
- Verifies VDI create are properly cleaned up"""
+ """
+ Simulates an error while downloading image
+ Verifies VDI create are properly cleaned up.
+ """
FLAGS.xenapi_image_service = 'glance'
stubs.stubout_fetch_image_glance_disk(self.stubs)
self.assertRaises(xenapi_fake.Failure,
@@ -353,8 +355,10 @@ class XenAPIVMTestCase(test.TestCase):
self._check_no_unbound_vdi()
def test_spawn_fail_cleanup_2(self):
- """Simulates an error while creating VM record.
- Verifies VDI create are properly cleaned up"""
+ """
+ Simulates an error while creating VM record. It
+ verifies that VDI created are properly cleaned up.
+ """
FLAGS.xenapi_image_service = 'glance'
stubs.stubout_create_vm(self.stubs)
self.assertRaises(xenapi_fake.Failure,
@@ -423,18 +427,17 @@ class XenAPIVMTestCase(test.TestCase):
self.stubs.UnsetAll()
def _create_instance(self):
- """Creates and spawns a test instance"""
- values = {
- 'name': 1,
- 'id': 1,
- 'project_id': self.project.id,
- 'user_id': self.user.id,
- 'image_id': 1,
- 'kernel_id': 2,
- 'ramdisk_id': 3,
- 'instance_type': 'm1.large',
- 'mac_address': 'aa:bb:cc:dd:ee:ff',
- 'os_type': 'linux'}
+ """Creates and spawns a test instance."""
+ values = {'name': 1,
+ 'id': 1,
+ 'project_id': self.project.id,
+ 'user_id': self.user.id,
+ 'image_id': 1,
+ 'kernel_id': 2,
+ 'ramdisk_id': 3,
+ 'instance_type': 'm1.large',
+ 'mac_address': 'aa:bb:cc:dd:ee:ff',
+ 'os_type': 'linux'}
instance = db.instance_create(values)
self.conn.spawn(instance)
return instance
diff --git a/nova/tests/xenapi/stubs.py b/nova/tests/xenapi/stubs.py
index 709a8b6ff..b745205f5 100644
--- a/nova/tests/xenapi/stubs.py
+++ b/nova/tests/xenapi/stubs.py
@@ -138,14 +138,14 @@ def stubout_is_vdi_pv(stubs):
def stubout_lookup_image(stubs):
- """Simulates a failure in lookup image"""
+ """Simulates a failure in lookup image."""
def f(_1, _2, _3, _4):
raise Exception("Test Exception raised by fake lookup_image")
stubs.Set(vm_utils, 'lookup_image', f)
def stubout_fetch_image_glance_disk(stubs):
- """Simulates a failure in fetch image_glance_disk"""
+ """Simulates a failure in fetch image_glance_disk."""
@classmethod
def f(cls, *args):
@@ -155,7 +155,7 @@ def stubout_fetch_image_glance_disk(stubs):
def stubout_create_vm(stubs):
- """Simulates a failure in create_vm"""
+ """Simulates a failure in create_vm."""
@classmethod
def f(cls, *args):
diff --git a/nova/virt/xenapi/vm_utils.py b/nova/virt/xenapi/vm_utils.py
index 8abd19c3c..bcf2a9962 100644
--- a/nova/virt/xenapi/vm_utils.py
+++ b/nova/virt/xenapi/vm_utils.py
@@ -466,17 +466,23 @@ class VMHelper(HelperBase):
vdi_size += MBR_SIZE_BYTES
name_label = get_name_label_for_image(image)
- vdi_ref = cls.create_vdi(session, sr_ref, name_label,
- vdi_size, False)
+ vdi_ref = cls.create_vdi(session,
+ sr_ref,
+ name_label,
+ vdi_size,
+ False)
# from this point we have a VDI on Xen host
# if anything goes wrong, we need to remember its uuid
try:
filename = None
vdi_uuid = session.get_xenapi().VDI.get_uuid(vdi_ref)
- with_vdi_attached_here(session, vdi_ref, False,
- lambda dev:
- _stream_disk(dev, image_type,
- virtual_size, image_file))
+ with_vdi_attached_here(session,
+ vdi_ref,
+ False,
+ lambda dev: _stream_disk(dev,
+ image_type,
+ virtual_size,
+ image_file))
if image_type in (ImageType.KERNEL, ImageType.RAMDISK):
# we need to invoke a plugin for copying VDI's
# content into proper path
diff --git a/nova/virt/xenapi_conn.py b/nova/virt/xenapi_conn.py
index c7e94c508..191498916 100644
--- a/nova/virt/xenapi_conn.py
+++ b/nova/virt/xenapi_conn.py
@@ -367,10 +367,9 @@ class XenAPISession(object):
try:
name = self._session.xenapi.task.get_name_label(task)
status = self._session.xenapi.task.get_status(task)
- action = dict(
- action=name[0:255], # Ensure action is never > 255
- instance_id=id and int(id) or None,
- error=None)
+ action = dict(action=name[0:255],
+ instance_id=id and int(id) or None,
+ error=None)
if status == "pending":
return
elif status == "success":
diff --git a/plugins/xenserver/xenapi/etc/xapi.d/plugins/glance b/plugins/xenserver/xenapi/etc/xapi.d/plugins/glance
index b12175845..1eed7e862 100644
--- a/plugins/xenserver/xenapi/etc/xapi.d/plugins/glance
+++ b/plugins/xenserver/xenapi/etc/xapi.d/plugins/glance
@@ -374,6 +374,7 @@ def remove_kernel_ramdisk(session, args):
os.remove(ramdisk_file)
return "ok"
+
if __name__ == '__main__':
XenAPIPlugin.dispatch({'upload_vhd': upload_vhd,
'download_vhd': download_vhd,