summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2012-10-24 23:21:12 +0000
committerGerrit Code Review <review@openstack.org>2012-10-24 23:21:12 +0000
commit29e4b4d592d328a1d18658f8d4af88e5ab9e5ea7 (patch)
tree48ccaecf227a780e7aee6dfeb3758f0c7aceeb0b
parent609d10684259c16f6893c8a783f9c9c8e405e0f5 (diff)
parenta0640a73df0d88d5c3c09c08cfb389fccff96b33 (diff)
Merge "xenapi: Tag volumes in boot from volume case"
-rw-r--r--nova/tests/test_xenapi.py9
-rw-r--r--nova/virt/xenapi/vm_utils.py9
-rw-r--r--nova/virt/xenapi/vmops.py6
-rw-r--r--nova/virt/xenapi/volumeops.py7
4 files changed, 19 insertions, 12 deletions
diff --git a/nova/tests/test_xenapi.py b/nova/tests/test_xenapi.py
index 7b92c352d..a7bfa7548 100644
--- a/nova/tests/test_xenapi.py
+++ b/nova/tests/test_xenapi.py
@@ -362,7 +362,8 @@ class XenAPIVMTestCase(stubs.XenAPITestBase):
def test_instance_snapshot_fails_with_no_primary_vdi(self):
def create_bad_vbd(session, vm_ref, vdi_ref, userdevice,
- vbd_type='disk', read_only=False, bootable=False):
+ vbd_type='disk', read_only=False, bootable=False,
+ osvol=False):
vbd_rec = {'VM': vm_ref,
'VDI': vdi_ref,
'userdevice': 'fake',
@@ -1335,7 +1336,8 @@ class XenAPIAutoDiskConfigTestCase(stubs.XenAPITestBase):
self.context = context.RequestContext(self.user_id, self.project_id)
def fake_create_vbd(session, vm_ref, vdi_ref, userdevice,
- vbd_type='disk', read_only=False, bootable=True):
+ vbd_type='disk', read_only=False, bootable=True,
+ osvol=False):
pass
self.stubs.Set(vm_utils, 'create_vbd', fake_create_vbd)
@@ -1427,7 +1429,8 @@ class XenAPIGenerateLocal(stubs.XenAPITestBase):
self.context = context.RequestContext(self.user_id, self.project_id)
def fake_create_vbd(session, vm_ref, vdi_ref, userdevice,
- vbd_type='disk', read_only=False, bootable=True):
+ vbd_type='disk', read_only=False, bootable=True,
+ osvol=False):
pass
self.stubs.Set(vm_utils, 'create_vbd', fake_create_vbd)
diff --git a/nova/virt/xenapi/vm_utils.py b/nova/virt/xenapi/vm_utils.py
index 14061829e..b08dd1387 100644
--- a/nova/virt/xenapi/vm_utils.py
+++ b/nova/virt/xenapi/vm_utils.py
@@ -354,7 +354,7 @@ def destroy_vbd(session, vbd_ref):
def create_vbd(session, vm_ref, vdi_ref, userdevice, vbd_type='disk',
- read_only=False, bootable=False):
+ read_only=False, bootable=False, osvol=False):
"""Create a VBD record and returns its reference."""
vbd_rec = {}
vbd_rec['VM'] = vm_ref
@@ -374,6 +374,11 @@ def create_vbd(session, vm_ref, vdi_ref, userdevice, vbd_type='disk',
vbd_ref = session.call_xenapi('VBD.create', vbd_rec)
LOG.debug(_('Created VBD %(vbd_ref)s for VM %(vm_ref)s,'
' VDI %(vdi_ref)s.'), locals())
+ if osvol:
+ # set osvol=True in other-config to indicate this is an
+ # attached nova (or cinder) volume
+ session.call_xenapi("VBD.add_to_other_config",
+ vbd_ref, 'osvol', "True")
return vbd_ref
@@ -451,7 +456,7 @@ def get_vdis_for_boot_from_vol(session, dev_params):
else:
session.call_xenapi("SR.scan", sr_ref)
return {'root': dict(uuid=dev_params['vdi_uuid'],
- file=None)}
+ file=None, osvol=True)}
return vdis
diff --git a/nova/virt/xenapi/vmops.py b/nova/virt/xenapi/vmops.py
index feee83b5d..469892ae8 100644
--- a/nova/virt/xenapi/vmops.py
+++ b/nova/virt/xenapi/vmops.py
@@ -269,7 +269,8 @@ class VMOps(object):
image_meta, block_device_info)
def undo_create_disks():
- vdi_refs = [vdi['ref'] for vdi in vdis.values()]
+ vdi_refs = [vdi['ref'] for vdi in vdis.values()
+ if not vdi.get('osvol')]
vm_utils.safe_destroy_vdis(self._session, vdi_refs)
undo_mgr.undo_with(undo_create_disks)
@@ -465,7 +466,8 @@ class VMOps(object):
instance_type['root_gb'])
vm_utils.create_vbd(self._session, vm_ref, root_vdi['ref'],
- DEVICE_ROOT, bootable=True)
+ DEVICE_ROOT, bootable=True,
+ osvol=root_vdi.get('osvol'))
# Attach (optional) swap disk
swap_mb = instance_type['swap']
diff --git a/nova/virt/xenapi/volumeops.py b/nova/virt/xenapi/volumeops.py
index 715554c5a..16da85b9d 100644
--- a/nova/virt/xenapi/volumeops.py
+++ b/nova/virt/xenapi/volumeops.py
@@ -175,7 +175,8 @@ class VolumeOps(object):
try:
vbd_ref = vm_utils.create_vbd(self._session, vm_ref, vdi_ref,
- dev_number, bootable=False)
+ dev_number, bootable=False,
+ osvol=True)
except self._session.XenAPI.Failure, exc:
LOG.exception(exc)
self.forget_sr(uuid)
@@ -184,10 +185,6 @@ class VolumeOps(object):
try:
self._session.call_xenapi("VBD.plug", vbd_ref)
- # set osvol=True in other-config to indicate this is an
- # attached nova (or cinder) volume
- self._session.call_xenapi("VBD.add_to_other_config",
- vbd_ref, 'osvol', "True")
except self._session.XenAPI.Failure, exc:
LOG.exception(exc)
self.forget_sr(uuid)