summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2012-01-22 14:41:08 +0000
committerGerrit Code Review <review@openstack.org>2012-01-22 14:41:08 +0000
commit727b3b7f86d8cb4d7a75dc6a0820b6f47387ff88 (patch)
treed71886d8faf742f5fe6238d99e18eff5d44a0c7e
parent255ce807236e9cdfd61357208fbb12b3453b109d (diff)
parentab252806c97c2983921ed045bc790b5db984da68 (diff)
Merge "Fix xenapi rescue without swap."
-rw-r--r--nova/virt/xenapi/vmops.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/nova/virt/xenapi/vmops.py b/nova/virt/xenapi/vmops.py
index 73ed79bad..665584072 100644
--- a/nova/virt/xenapi/vmops.py
+++ b/nova/virt/xenapi/vmops.py
@@ -1000,11 +1000,19 @@ class VMOps(object):
LOG.exception(exc)
def _find_rescue_vbd_ref(self, vm_ref, rescue_vm_ref):
- """Find and return the rescue VM's vbd_ref.
+ """Find and return the rescue VM's vbd_ref."""
+ vbd_refs = self._session.call_xenapi("VM.get_VBDs", vm_ref)
+
+ if len(vbd_refs) == 0:
+ raise Exception(_("Unable to find VBD for VM"))
+ elif len(vbd_refs) == 1:
+ # If we only have one VBD, assume it's the root fs
+ vbd_ref = vbd_refs[0]
+ else:
+ # If we have more than one VBD, swap will be first by convention
+ # with the root fs coming second
+ vbd_ref = vbd_refs[1]
- We use the second VBD here because swap is first with the root file
- system coming in second."""
- vbd_ref = self._session.call_xenapi("VM.get_VBDs", vm_ref)[1]
vdi_ref = self._session.call_xenapi("VBD.get_record", vbd_ref)["VDI"]
return VolumeHelper.create_vbd(self._session, rescue_vm_ref, vdi_ref,