diff options
| author | Renuka Apte <renuka.apte@citrix.com> | 2012-10-09 11:38:08 -0700 |
|---|---|---|
| committer | Renuka Apte <renuka.apte@citrix.com> | 2012-10-12 14:37:46 -0700 |
| commit | a0640a73df0d88d5c3c09c08cfb389fccff96b33 (patch) | |
| tree | 4de9dc1463d70ce704a6c38a2898b19c834c2c70 | |
| parent | 36b85251ab15d97441422c0b85dc0eb025d2f0cf (diff) | |
| download | nova-a0640a73df0d88d5c3c09c08cfb389fccff96b33.tar.gz nova-a0640a73df0d88d5c3c09c08cfb389fccff96b33.tar.xz nova-a0640a73df0d88d5c3c09c08cfb389fccff96b33.zip | |
xenapi: Tag volumes in boot from volume case
Fixes bug 1064134
Since https://review.openstack.org/#/c/10574, we require that all
openstack volumes are tagged, so as to distinguish them from other
disks that could be deleted on instance termination.
Change-Id: I965f88bf41d39be88f2331ad081f5cec71a65a0f
| -rw-r--r-- | nova/tests/test_xenapi.py | 9 | ||||
| -rw-r--r-- | nova/virt/xenapi/vm_utils.py | 9 | ||||
| -rw-r--r-- | nova/virt/xenapi/vmops.py | 6 | ||||
| -rw-r--r-- | nova/virt/xenapi/volumeops.py | 7 |
4 files changed, 19 insertions, 12 deletions
diff --git a/nova/tests/test_xenapi.py b/nova/tests/test_xenapi.py index 4720412d7..da4d8b6ad 100644 --- a/nova/tests/test_xenapi.py +++ b/nova/tests/test_xenapi.py @@ -358,7 +358,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', @@ -1331,7 +1332,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) @@ -1423,7 +1425,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 e1d3ab753..d5aacd2c0 100644 --- a/nova/virt/xenapi/vm_utils.py +++ b/nova/virt/xenapi/vm_utils.py @@ -353,7 +353,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 @@ -373,6 +373,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 @@ -428,7 +433,7 @@ def get_vdis_for_boot_from_vol(session, instance, dev_params): if sr_ref: 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 09d735902..42d648257 100644 --- a/nova/virt/xenapi/volumeops.py +++ b/nova/virt/xenapi/volumeops.py @@ -175,7 +175,8 @@ class VolumeOps(object): dev_number = volume_utils.mountpoint_to_number(mountpoint) 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) |
