summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2012-12-21 05:13:43 +0000
committerGerrit Code Review <review@openstack.org>2012-12-21 05:13:43 +0000
commitc1bdc39fd9ae728d824c65fd65bc857e51d2a233 (patch)
tree181eae1ae6e70c9c592ed8e51235762c7982e9aa
parent2a57e53855fcbccb8f5fe399f557f98494540e61 (diff)
parente6acd86b8419018f25e96f484340b7631c3e127b (diff)
Merge "Execute pygrub using nova-rootwrap in xenapi"
-rw-r--r--etc/nova/rootwrap.d/compute.filters3
-rw-r--r--nova/virt/xenapi/vm_utils.py23
2 files changed, 18 insertions, 8 deletions
diff --git a/etc/nova/rootwrap.d/compute.filters b/etc/nova/rootwrap.d/compute.filters
index baf4f1c92..f344a1b1c 100644
--- a/etc/nova/rootwrap.d/compute.filters
+++ b/etc/nova/rootwrap.d/compute.filters
@@ -92,6 +92,9 @@ iscsiadm: CommandFilter, iscsiadm, root
# nova/virt/xenapi/vm_utils.py: 'parted', '--script', dev_path, ..*.
parted: CommandFilter, parted, root
+# nova/virt/xenapi/vm_utils.py: 'pygrub', '-qn', dev_path
+pygrub: CommandFilter, /usr/bin/pygrub, root
+
# nova/virt/xenapi/vm_utils.py: fdisk %(dev_path)s
fdisk: CommandFilter, /sbin/fdisk, root
diff --git a/nova/virt/xenapi/vm_utils.py b/nova/virt/xenapi/vm_utils.py
index d15d89515..ee36cea0b 100644
--- a/nova/virt/xenapi/vm_utils.py
+++ b/nova/virt/xenapi/vm_utils.py
@@ -1922,14 +1922,21 @@ def _get_this_vm_ref(session):
def _is_vdi_pv(dev):
LOG.debug(_("Running pygrub against %s"), dev)
dev_path = utils.make_dev_path(dev)
- output = os.popen('pygrub -qn %s' % dev_path)
- for line in output.readlines():
- #try to find kernel string
- m = re.search('(?<=kernel:)/.*(?:>)', line)
- if m and m.group(0).find('xen') != -1:
- LOG.debug(_("Found Xen kernel %s") % m.group(0))
- return True
- LOG.debug(_("No Xen kernel found. Booting HVM."))
+ try:
+ out, err = utils.execute('pygrub', '-qn', dev_path, run_as_root=True)
+ for line in out:
+ # try to find kernel string
+ m = re.search('(?<=kernel:)/.*(?:>)', line)
+ if m and m.group(0).find('xen') != -1:
+ LOG.debug(_("Found Xen kernel %s") % m.group(0))
+ return True
+ LOG.debug(_("No Xen kernel found. Booting HVM."))
+ except exception.ProcessExecutionError:
+ LOG.exception(_("Error while executing pygrub! Please, ensure the "
+ "binary is installed correctly, and available in your "
+ "PATH; on some Linux distros, pygrub may be installed "
+ "in /usr/lib/xen-X.Y/bin/pygrub. Attempting to boot "
+ "in HVM mode."))
return False