Change in vdsm[ovirt-3.5]: iscsi: Finding iscsi's host to read netdev attribute fix.
aaviram at redhat.com
aaviram at redhat.com
Sun Apr 5 15:31:14 UTC 2015
Amit Aviram has uploaded a new change for review.
Change subject: iscsi: Finding iscsi's host to read netdev attribute fix.
......................................................................
iscsi: Finding iscsi's host to read netdev attribute fix.
In commit a78793935e (Configure iSCSI iface.net_ifacename), we
introduced the iface.net_ifacename probe for active sessions. We use
the sessionID to locate /sys/class/iscs_host/host* and read the
netdev attribue.
However, we looked up the session in /sys/devices/platform/host*
which is correct only for software iSCSI. For hardware iSCSI, the
session is located in /sys/devices/pci*/*/*/*/host*.
This patch locates the host using the real iscsi_session path, which
works for both software and hardware iSCSI.
Change-Id: Ie6f273fddff2235f15197c6689de5e6374fda6f0
Signed-off-by: Amit Aviram <aaviram at redhat.com>
---
M vdsm/storage/iscsi.py
1 file changed, 14 insertions(+), 6 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/55/39555/1
diff --git a/vdsm/storage/iscsi.py b/vdsm/storage/iscsi.py
index e7c25a0..3368f37 100644
--- a/vdsm/storage/iscsi.py
+++ b/vdsm/storage/iscsi.py
@@ -106,19 +106,25 @@
Returns:
- iSCSI host path - e.g. '/sys/class/iscsi_host/host17/'
"""
+ path = os.path.realpath(getIscsiSessionPath(sessionID))
+ if not os.path.exists(path):
+ raise OSError(errno.ENOENT, "No such session %r" % sessionID)
- pattern = '/sys/devices/platform/host*/session%s' % sessionID
- for path in glob.iglob(pattern):
- host = os.path.basename(os.path.dirname(path))
- return '/sys/class/iscsi_host/' + host
+ # Session path depends on the iSCSI implementation:
+ # Hardware iSCSI:
+ # /sys/devices/pci*/*/*/host0/session7/iscsi_session/session7
+ # Software iSCSI:
+ # /sys/devices/platform/host5/session8/iscsi_session/session8
+ host = path.rsplit(os.sep, 4)[-4]
+ if not host.startswith('host'):
+ raise RuntimeError("Unexpected session path %r" % path)
- raise OSError(errno.ENOENT, "No iscsi_host for session [%s]" % sessionID)
+ return '/sys/class/iscsi_host/' + host
def readSessionInfo(sessionID):
iscsi_session = getIscsiSessionPath(sessionID)
iscsi_connection = getIscsiConnectionPath(sessionID)
- iscsi_host = getIscsiHostPath(sessionID)
if not os.path.isdir(iscsi_session) or not os.path.isdir(iscsi_connection):
raise OSError(errno.ENOENT, "No such session")
@@ -133,6 +139,8 @@
paddr = os.path.join(iscsi_connection, "persistent_address")
pport = os.path.join(iscsi_connection, "persistent_port")
+ # iscsi_host is available only when the session exists.
+ iscsi_host = getIscsiHostPath(sessionID)
netdev = os.path.join(iscsi_host, "netdev")
res = []
--
To view, visit https://gerrit.ovirt.org/39555
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie6f273fddff2235f15197c6689de5e6374fda6f0
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-3.5
Gerrit-Owner: Amit Aviram <aaviram at redhat.com>
Gerrit-Reviewer: Amador Pahim <apahim at redhat.com>
More information about the vdsm-patches
mailing list