Exemple #1
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.
    with _iscsiadmTransactionLock:
        iscsiadm.node_new(iface.name, target.address, target.iqn)
        try:
            if credentials is not None:
                for key, value in credentials.getIscsiadmOptions():
                    key = "node.session." + key
                    iscsiadm.node_update(iface.name, target.address,
                                         target.iqn, key, value,
                                         hideValue=True)

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

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

            iscsiadm.node_update(iface.name, target.address, target.iqn,
                                 "node.startup", "manual")
        except:
            removeIscsiNode(iface, target)
            raise
Exemple #2
0
def loginToIscsiNode(iface, target):
    log.info("Logging in to iscsi target %s via iface %s", target, iface.name)
    try:
        iscsiadm.node_login(iface.name, target.address, target.iqn)
    except:
        removeIscsiNode(iface, target)
        raise
Exemple #3
0
def loginToIscsiNode(iface, target):
    log.info("Logging in to iscsi target %s via iface %s", target, iface.name)
    try:
        iscsiadm.node_login(iface.name, target.address, target.iqn)
    except iscsiadm.IscsiSessionExists:
        # We are already logged in to this node, fail the request keeping the
        # existing session.
        raise
    except:
        removeIscsiNode(iface, target)
        raise