Federico Simoncelli has uploaded a new change for review. Change subject: iscsi: report hba sessions as fiber channel ......................................................................
iscsi: report hba sessions as fiber channel At the moment the engine doesn't support static (unmanaged) iscsi connections therefore it's safer to maintain the old behavior and report the HBA iscsi sessions as if they were fiber channel devices. Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=967605 Change-Id: I9b87aafc89a502c872ceec6a55b49d9e49d1ee9f Signed-off-by: Federico Simoncelli <[email protected]> --- M vdsm/storage/iscsi.py 1 file changed, 41 insertions(+), 10 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/61/15161/1 diff --git a/vdsm/storage/iscsi.py b/vdsm/storage/iscsi.py index 2139e78..5749dde 100644 --- a/vdsm/storage/iscsi.py +++ b/vdsm/storage/iscsi.py @@ -52,6 +52,14 @@ log = logging.getLogger('Storage.ISCSI') +def getDevIscsiSessionId(dev): + device = os.path.realpath(os.path.join("/sys", "block", dev, "device")) + if not os.path.exists(device): + return None + session = os.path.realpath(os.path.join(device, "../..")) + return int(os.path.basename(session)[7:]) + + def getDevIscsiInfo(dev): """ Reports the iSCSI parameters of the given device 'dev' @@ -62,11 +70,8 @@ """ - device = os.path.realpath(os.path.join("/sys/block", dev, "device")) - if os.path.exists(device) and devIsiSCSI(dev): - sessiondir = os.path.realpath(os.path.join(device, "../..")) - sessionID = int(os.path.basename(sessiondir)[7:]) - return getSessionInfo(sessionID) + if devIsiSCSI(dev): + return getSessionInfo(getDevIscsiSessionId(dev)) #FIXME: raise exception instead of returning an empty object return IscsiSession(0, IscsiInterface(""), @@ -77,11 +82,20 @@ return supervdsm.getProxy().readSessionInfo(sessionID) +def getIscsiSessionPath(sessionId): + return os.path.join("/sys", "class", "iscsi_session", + "session%d" % sessionId) + + +def getIscsiConnectionPath(sessionId): + return os.path.join("/sys", "class", "iscsi_connection", + "connection%d:0" % sessionId) + + def readSessionInfo(sessionID): - sessionName = "session%d" % sessionID - connectionName = "connection%d:0" % sessionID - iscsi_session = "/sys/class/iscsi_session/%s/" % sessionName - iscsi_connection = "/sys/class/iscsi_connection/%s/" % connectionName + iscsi_session = getIscsiSessionPath(sessionID) + iscsi_connection = getIscsiConnectionPath(sessionID) + if not os.path.isdir(iscsi_session) or not os.path.isdir(iscsi_connection): raise OSError(errno.ENOENT, "No such session") @@ -431,7 +445,24 @@ iscsi_host = os.path.join(hostdir, "iscsi_host/", host) scsi_host = os.path.join(hostdir, "scsi_host/", host) proc_name = os.path.join(scsi_host, "proc_name") - return (os.path.exists(iscsi_host) and os.path.exists(proc_name)) + + if not os.path.exists(iscsi_host) or not os.path.exists(proc_name): + return False + + # This second part of the validation is to make sure that if the + # iscsi connection is handled by an HBS (e.g. qlogic in bz967605) + # the device is reported as fiber channel to avoid unmanageable + # commands (dis/connectStorageServer). + session_id = getDevIscsiSessionId(dev) + + if session_id is None: + return False + + iscsi_connection = getIscsiConnectionPath(session_id) + pers_addr = os.path.join(iscsi_connection, "persistent_address") + pers_port = os.path.join(iscsi_connection, "persistent_port") + + return os.path.exists(pers_addr) and os.path.exists(pers_port) def getiScsiTarget(dev): -- To view, visit http://gerrit.ovirt.org/15161 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I9b87aafc89a502c872ceec6a55b49d9e49d1ee9f Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Federico Simoncelli <[email protected]> _______________________________________________ vdsm-patches mailing list [email protected] https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
