From 001961ed495a33cc944407888a2797f8a600e091 Mon Sep 17 00:00:00 2001 From: "Walter A. Boring IV" Date: Mon, 29 Apr 2013 13:51:42 -0700 Subject: Fix attach when running as root without sysfsutils When someone runs nova as root, and sysfsutils is not installed an exception was being thrown when a volume attach call was made. This wouldn't happen when being run as non-root because of the rootwrap would trap for the missing sysfsutils app (systool). Change-Id: Icc852fa7fd7a137cc7df86b8b96aeb629639ffad Fixes: bug 1172486 --- nova/virt/libvirt/utils.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/nova/virt/libvirt/utils.py b/nova/virt/libvirt/utils.py index fc73c2759..96f84c194 100755 --- a/nova/virt/libvirt/utils.py +++ b/nova/virt/libvirt/utils.py @@ -20,6 +20,7 @@ # License for the specific language governing permissions and limitations # under the License. +import errno import os from lxml import etree @@ -59,13 +60,23 @@ def get_iscsi_initiator(): def get_fc_hbas(): """Get the Fibre Channel HBA information.""" + out = None try: out, err = execute('systool', '-c', 'fc_host', '-v', run_as_root=True) except exception.ProcessExecutionError as exc: + # This handles the case where rootwrap is used + # and systool is not installed + # 96 = nova.cmd.rootwrap.RC_NOEXECFOUND: if exc.exit_code == 96: LOG.warn(_("systool is not installed")) return [] + except OSError as exc: + # This handles the case where rootwrap is NOT used + # and systool is not installed + if exc.errno == errno.ENOENT: + LOG.warn(_("systool is not installed")) + return [] if out is None: raise RuntimeError(_("Cannot find any Fibre Channel HBAs")) -- cgit