Fixed discovery of targets not to overwrite settings of already
connected targets.
Added support for iSER transport.
---
 vdsm/storage/iscsi.py |   44 +++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 39 insertions(+), 5 deletions(-)

diff --git a/vdsm/storage/iscsi.py b/vdsm/storage/iscsi.py
index d2a5bdd..b5ccbd9 100644
--- a/vdsm/storage/iscsi.py
+++ b/vdsm/storage/iscsi.py
@@ -34,7 +34,7 @@ import misc
 import storage_exception as se
 import devicemapper
 
-SENDTARGETS_DISCOVERY = [constants.EXT_ISCSIADM, "-m", "discoverydb", "-t", 
"sendtargets"]
+SENDTARGETS_DISCOVERY = [constants.EXT_ISCSIADM, "-m", "discoverydb", "-t", 
"sendtargets", "-o", "new", "-o", "delete"]
 ISCSIADM_NODE = [constants.EXT_ISCSIADM, "-m", "node"]
 ISCSIADM_IFACE = [constants.EXT_ISCSIADM, "-m", "iface"]
 ISCSI_DEFAULT_PORT = "3260"
@@ -248,14 +248,26 @@ def addiSCSINode(ip, port, iqn, tpgt, initiator, 
username=None, password=None):
             rc = misc.execCmd(cmd + [password], printable=cmd + ["******"])[0]
             if rc != 0:
                 raise se.SetiSCSIPasswdError(portal)
+       
 
         # Finally instruct the iscsi initiator to login to the target
+        # Since currently its not possible to choose transport from RHEV
+        # we try iSER transport first since its faster and if it fails we
+        # will try iSCSI tranport
+        setNodeTransport(portal, iqn, 'iser')
         cmd = cmdt + ["-l", "-p", portal]
         rc = misc.execCmd(cmd)[0]
-        if rc == ISCSI_ERR_LOGIN_AUTH_FAILED:
-            raise se.iSCSILoginAuthError(portal)
-        elif rc not in (0, ISCSI_ERR_SESS_EXISTS):
-            raise se.iSCSILoginError(portal)
+
+       if rc == ISCSI_ERR_LOGIN_AUTH_FAILED:
+               raise se.iSCSILoginAuthError(portal)
+       elif rc not in (0, ISCSI_ERR_SESS_EXISTS):
+           setNodeTransport(portal, iqn, 'tcp')
+           rc = misc.execCmd(cmd)[0]
+
+            if rc == ISCSI_ERR_LOGIN_AUTH_FAILED:
+                raise se.iSCSILoginAuthError(portal)
+            elif rc not in (0, ISCSI_ERR_SESS_EXISTS):
+                raise se.iSCSILoginError(portal)
 
     except se.StorageException:
         exc_class, exc, tb = sys.exc_info()
@@ -329,6 +341,28 @@ def getiScsiSession(dev):
     session = os.path.basename(sessiondir)
     return session
 
+def setNodeTransport(portal, iqn, transport='tcp'):
+    """
+    Configure a node transport
+    transport :tcp, iser
+    """
+    if transport not in ['tcp', 'iser']:
+        transport = 'tcp'
+
+    log.info('Set transport %s to target %s on portal %s' % (transport, iqn, 
portal))
+
+    params = [
+        ['node.conn[0].iscsi.HeaderDigest', 'None'],
+        ['iface.transport_name', transport]
+    ]
+
+    cmdt = [constants.EXT_ISCSIADM, '-m', 'node', '-o', 'update', '-p', 
portal, '-T', iqn]
+    for param in params:
+        cmd = cmdt + ['-n', param[0], '-v', param[1]]
+        rc = misc.execCmd(cmd)[0]
+        if rc not in (0, ISCSI_ERR_SESS_EXISTS):
+            raise se.iSCSILoginError(portal)
+
 def getdeviSCSIinfo(dev):
     """
     Reports the iSCSI parameters of the given device 'dev'
-- 
1.7.1

_______________________________________________
vdsm-patches mailing list
[email protected]
https://fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to