示例#1
0
文件: iscsi.py 项目: loler-zuan/vdsm
def addIscsiNode(iface, target, credentials=None):
    targetName = target.iqn

    # There are 2 formats for an iSCSI node record. An old style format where
    # the path is /var/lib/iscsi/nodes/{target}/{portal} and a new style format
    # where the portal path is a directory containing a record file for each
    # bounded iface. Explicitly specifying tpgt on iSCSI login imposes creation
    # of the node record in the new style format which enables to access a
    # portal through multiple ifaces for multipathing.
    portalStr = "%s:%d,%d" % (target.portal.hostname, target.portal.port,
                              target.tpgt)
    with _iscsiadmTransactionLock:
        iscsiadm.node_new(iface.name, portalStr, targetName)
        try:
            if credentials is not None:
                for key, value in credentials.getIscsiadmOptions():
                    key = "node.session." + key
                    iscsiadm.node_update(iface.name, portalStr, targetName,
                                         key, value, hideValue=True)

            iscsiadm.node_login(iface.name, portalStr, targetName)

            iscsiadm.node_update(iface.name, portalStr, targetName,
                                 "node.startup", "manual")
        except:
            removeIscsiNode(iface, target)
            raise
示例#2
0
def addIscsiNode(iface, target, credentials=None):
    # There are 2 formats for an iSCSI node record. An old style format where
    # the path is /var/lib/iscsi/nodes/{target}/{portal} and a new style format
    # where the portal path is a directory containing a record file for each
    # bounded iface. Explicitly specifying tpgt on iSCSI login imposes creation
    # of the node record in the new style format which enables to access a
    # portal through multiple ifaces for multipathing.
    portalStr = "%s:%d,%d" % (target.portal.hostname, target.portal.port,
                              target.tpgt)
    with _iscsiadmTransactionLock:
        iscsiadm.node_new(iface.name, portalStr, target.iqn)
        try:
            if credentials is not None:
                for key, value in credentials.getIscsiadmOptions():
                    key = "node.session." + key
                    iscsiadm.node_update(iface.name,
                                         portalStr,
                                         target.iqn,
                                         key,
                                         value,
                                         hideValue=True)

            setRpFilterIfNeeded(iface.netIfaceName, target.portal.hostname,
                                True)

            iscsiadm.node_login(iface.name, portalStr, target.iqn)

            iscsiadm.node_update(iface.name, portalStr, target.iqn,
                                 "node.startup", "manual")
        except:
            removeIscsiNode(iface, target)
            raise
示例#3
0
文件: iscsi.py 项目: ekohl/vdsm
def addIscsiNode(iface, target, credentials=None):
    targetName = target.iqn
    portalStr = "%s:%d" % (target.portal.hostname, target.portal.port)
    with _iscsiadmTransactionLock:
        iscsiadm.node_new(iface.name, portalStr, targetName)
        try:
            iscsiadm.node_update(iface.name, portalStr, targetName, "node.startup", "manual")

            if credentials is not None:
                for key, value in credentials.getIscsiadmOptions():
                    key = "node.session." + key
                    iscsiadm.node_update(iface.name, portalStr, targetName, key, value, hideValue=True)

            iscsiadm.node_login(iface.name, portalStr, targetName)
        except:
            removeIscsiNode(iface, target)
            raise
示例#4
0
def addIscsiNode(iface, target, credentials=None):
    targetName = target.iqn
    portalStr = "%s:%d" % (target.portal.hostname, target.portal.port)
    with _iscsiadmTransactionLock:
        iscsiadm.node_new(iface.name, portalStr, targetName)
        try:
            if credentials is not None:
                for key, value in credentials.getIscsiadmOptions():
                    key = "node.session." + key
                    iscsiadm.node_update(iface.name, portalStr, targetName,
                                         key, value, hideValue=True)

            iscsiadm.node_login(iface.name, portalStr, targetName)

            iscsiadm.node_update(iface.name, portalStr, targetName,
                                 "node.startup", "manual")
        except:
            removeIscsiNode(iface, target)
            raise