Change in vdsm[master]: Skip netdev probe from sessions missing iscsi sysfs (i.e. us...

apahim at redhat.com apahim at redhat.com
Tue Mar 3 17:28:06 UTC 2015


Amador Pahim has uploaded a new change for review.

Change subject: Skip netdev probe from sessions missing iscsi sysfs (i.e. using hardware iSCSI)
......................................................................

Skip netdev probe from sessions missing iscsi sysfs (i.e. using hardware iSCSI)

In https://gerrit.ovirt.org/#/c/31534/, we introduced the
iface.net_ifacename probe for active sessions. To do so, we had to use
the sessionID (S) to access the iscsi sysfs, looking for
/sys/devices/platform/hostN/sessionS to then use the probed hostN into the
path /sys/class/iscsi_host/hostN/netdev, where netdev contains the value for
iface.net_ifacename, if any.

As we didn't expect /sys/devices/platform/hostN/sessionS to be missing, the
adopted policy was to raise an exception if that happens.

Now we learned the hard way that there is a valid case for missing
/sys/devices/platform/hostN/sessionS, which is using hardware iSCSI (qla4xxx).

This patch is fixing the code to allow missing
/sys/devices/platform/hostN/sessionS.

Change-Id: Ie6f273fddff2235f15197c6689de5e6374fda6f0
Signed-off-by: Amador Pahim <apahim at redhat.com>
---
M vdsm/storage/iscsi.py
1 file changed, 8 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/54/38354/1

diff --git a/vdsm/storage/iscsi.py b/vdsm/storage/iscsi.py
index e7c25a0..fed236d 100644
--- a/vdsm/storage/iscsi.py
+++ b/vdsm/storage/iscsi.py
@@ -105,6 +105,7 @@
         sessionID - the iSCSI session ID.
     Returns:
         - iSCSI host path - e.g. '/sys/class/iscsi_host/host17/'
+        - None if host session is not present (i.e. hardware iSCSI)
     """
 
     pattern = '/sys/devices/platform/host*/session%s' % sessionID
@@ -112,13 +113,18 @@
         host = os.path.basename(os.path.dirname(path))
         return '/sys/class/iscsi_host/' + host
 
-    raise OSError(errno.ENOENT, "No iscsi_host for session [%s]" % sessionID)
+    return None
 
 
 def readSessionInfo(sessionID):
     iscsi_session = getIscsiSessionPath(sessionID)
     iscsi_connection = getIscsiConnectionPath(sessionID)
+
     iscsi_host = getIscsiHostPath(sessionID)
+    if iscsi_host is not None:
+        netdev = os.path.join(iscsi_host, "netdev")
+    else:
+        netdev = None
 
     if not os.path.isdir(iscsi_session) or not os.path.isdir(iscsi_connection):
         raise OSError(errno.ENOENT, "No such session")
@@ -133,14 +139,12 @@
     paddr = os.path.join(iscsi_connection, "persistent_address")
     pport = os.path.join(iscsi_connection, "persistent_port")
 
-    netdev = os.path.join(iscsi_host, "netdev")
-
     res = []
     for fname in (targetname, iface, tpgt, user, passwd, paddr, pport, netdev):
         try:
             with open(fname, "r") as f:
                 res.append(f.read().strip())
-        except (OSError, IOError):
+        except (OSError, IOError, TypeError):
             res.append("")
 
     iqn, iface, tpgt, username, password, ip, port, netdev = res


-- 
To view, visit https://gerrit.ovirt.org/38354
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie6f273fddff2235f15197c6689de5e6374fda6f0
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Amador Pahim <apahim at redhat.com>


More information about the vdsm-patches mailing list