summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEwan Mellor <ewan.mellor@citrix.com>2011-01-07 22:28:59 +0000
committerEwan Mellor <ewan.mellor@citrix.com>2011-01-07 22:28:59 +0000
commitfedf946c7d04465fb958707e143d8de558ea4321 (patch)
tree36483c6c993b11b81649b57e5c31383da447af2d
parent5ca8ec42037ed4e2a1475bf29064f61068308687 (diff)
downloadnova-fedf946c7d04465fb958707e143d8de558ea4321.tar.gz
nova-fedf946c7d04465fb958707e143d8de558ea4321.tar.xz
nova-fedf946c7d04465fb958707e143d8de558ea4321.zip
Some fixes to _lookup_image_glance: fix the return value from lookup_image,
attach the disk read-only before running pygrub, and add some debug logging.
-rw-r--r--nova/virt/xenapi/vm_utils.py20
1 files changed, 9 insertions, 11 deletions
diff --git a/nova/virt/xenapi/vm_utils.py b/nova/virt/xenapi/vm_utils.py
index c5bd83b27..76094f35c 100644
--- a/nova/virt/xenapi/vm_utils.py
+++ b/nova/virt/xenapi/vm_utils.py
@@ -23,6 +23,7 @@ import glance.client
import logging
import os
import pickle
+import re
import urllib
from xml.dom import minidom
@@ -339,10 +340,9 @@ class VMHelper(HelperBase):
@classmethod
def lookup_image(cls, session, vdi_ref):
if FLAGS.xenapi_image_service == 'glance':
- cls._lookup_image_glance(session, vdi_ref)
+ return cls._lookup_image_glance(session, vdi_ref)
else:
- cls._lookup_image_objectstore(session, vdi_ref)
- return
+ return cls._lookup_image_objectstore(session, vdi_ref)
@classmethod
def _lookup_image_objectstore(cls, session, vdi_ref):
@@ -367,17 +367,15 @@ class VMHelper(HelperBase):
def is_vdi_pv(dev):
logging.debug("Running pygrub against %s", dev)
output = os.popen('pygrub -qn /dev/%s' % dev)
- pv = False
for line in output.readlines():
#try to find kernel string
m = re.search('(?<=kernel:)/.*(?:>)', line)
- if m:
- if m.group(0).find('xen') != -1:
- pv = True
- logging.debug("PV:%d", pv)
- return pv
- pv = with_vdi_attached_here(session, vdi_ref, False, is_vdi_pv)
- return pv
+ if m and m.group(0).find('xen') != -1:
+ logging.debug("Found Xen kernel %s" % m.group(0))
+ return True
+ logging.debug("No Xen kernel found. Booting HVM.")
+ return False
+ return with_vdi_attached_here(session, vdi_ref, True, is_vdi_pv)
@classmethod
def lookup(cls, session, i):