[PATCH] iscsi.py: fixed discovery issue and added support for iSER transport

Dan Kenigsberg danken at redhat.com
Sat Dec 10 09:53:59 UTC 2011


On Thu, Dec 08, 2011 at 12:41:10PM +0200, Roi Dayan wrote:
> Fixed discovery of targets not to overwrite settings of already
> connected targets.
> Added support for iSER transport.

Roi, what is the difference from your previous patch?
Have you addressed all the former comments? It seems that at least two (race
between setting node transport to using it, trying iser on hosts that did not
opt for it) are just as problematic as in the former patch.

It would be easier for us to review your patch if you send it via
gerrit.ovirt.org (see http://www.ovirt.org/wiki/Working_with_oVirt_Gerrit for
explanations)

Regards,
Dan.

> ---
>  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


More information about the vdsm-patches mailing list