Search in sources :

Example 1 with IScsiSession

use of com.iwave.ext.linux.model.IScsiSession in project coprhd-controller by CoprHD.

the class LinuxSupport method checkIScsiConnectivity.

private void checkIScsiConnectivity(Set<Initiator> initiators, BlockObjectRestRep volume) {
    List<ITLRestRep> exports = BlockStorageUtils.getExportsForBlockObject(volume.getId());
    List<ITLRestRep> connectedExports = BlockStorageUtils.getExportsForInitiators(exports, initiators);
    // Ensure we have at least one connection to the volume
    Set<String> targetPorts = BlockStorageUtils.getTargetPortsForExports(connectedExports);
    String sourceIqns = StringUtils.join(BlockStorageUtils.getPortNames(initiators), ", ");
    String targetIqns = StringUtils.join(targetPorts, ", ");
    logInfo("linux.support.check.connectivity", sourceIqns, targetIqns);
    int connections = 0;
    List<IScsiHost> iScsiInitiators = findIScsiIInitiators(initiators);
    for (IScsiHost iScsiInitiator : iScsiInitiators) {
        for (IScsiSession session : iScsiInitiator.getSessions()) {
            String sourceIqn = session.getIfaceInitiatorName();
            if (session.getTarget() != null) {
                String targetIqn = session.getTarget().getIqn();
                if (targetPorts.contains(targetIqn)) {
                    logInfo("linux.support.connected", sourceIqn, targetIqn);
                    connections++;
                }
            }
        }
    }
    if (connections == 0) {
        List<IScsiSession> iScsiSessions = findIScsiSessions(initiators);
        for (IScsiSession session : iScsiSessions) {
            String sourceIqn = session.getIfaceInitiatorName();
            if (session.getTarget() != null) {
                String targetIqn = session.getTarget().getIqn();
                if (targetPorts.contains(targetIqn)) {
                    logInfo("linux.support.connected", sourceIqn, targetIqn);
                    connections++;
                }
            }
        }
    }
    if (connections == 0) {
        Object[] detailArgs = new Object[] { volume.getId(), buildInitiatorsString(initiators) };
        Object[] messageArgs = new Object[] { sourceIqns, targetIqns };
        ExecutionUtils.fail("failTask.LinuxSupport.iqnConnectivity", detailArgs, messageArgs);
    }
}
Also used : IScsiSession(com.iwave.ext.linux.model.IScsiSession) IScsiHost(com.iwave.ext.linux.model.IScsiHost) ITLRestRep(com.emc.storageos.model.block.export.ITLRestRep) VerifyMountPoint(com.emc.sa.service.linux.tasks.VerifyMountPoint) MountPoint(com.iwave.ext.linux.model.MountPoint)

Example 2 with IScsiSession

use of com.iwave.ext.linux.model.IScsiSession in project coprhd-controller by CoprHD.

the class FindIScsiSessions method executeTask.

@Override
public List<IScsiSession> executeTask() throws Exception {
    List<IScsiSession> sessions = executeCommand(new ListIScsiSessionsCommand(), SHORT_TIMEOUT);
    Iterator<IScsiSession> iter = sessions.iterator();
    while (iter.hasNext()) {
        IScsiSession session = iter.next();
        if (!isMatch(session)) {
            iter.remove();
        }
    }
    return sessions;
}
Also used : IScsiSession(com.iwave.ext.linux.model.IScsiSession) ListIScsiSessionsCommand(com.iwave.ext.linux.command.iscsi.ListIScsiSessionsCommand)

Example 3 with IScsiSession

use of com.iwave.ext.linux.model.IScsiSession in project coprhd-controller by CoprHD.

the class IScsiSessionParser method parseSession.

public IScsiSession parseSession(String text) {
    if (StringUtils.isBlank(text)) {
        return null;
    }
    Map<String, String> properties = parser.parseProperties(text, ':');
    IScsiSession session = new IScsiSession();
    IScsiTarget target = new IScsiTarget();
    String targetValue = null;
    if (properties.get(TARGET) != null && properties.get(TARGET).contains(" ")) {
        targetValue = StringUtils.substring(properties.get(TARGET), 0, properties.get(TARGET).indexOf(" "));
    } else {
        targetValue = properties.get(TARGET);
    }
    target.setIqn(targetValue);
    target.setPortal(properties.get(CURRENT_PORTAL));
    target.setIfaceName(properties.get(IFACE_NAME));
    session.setTarget(target);
    session.setPersistentPortal(properties.get(PERSISTENT_PORTAL));
    session.setIfaceTransport(properties.get(IFACE_TRANSPORT));
    session.setIfaceInitiatorName(properties.get(IFACE_INITIATOR_NAME));
    session.setIfaceIPAddress(properties.get(IFACE_IP_ADDRESS));
    session.setIfaceHWAddress(properties.get(IFACE_HW_ADDRESS));
    session.setIfaceNetdev(properties.get(IFACE_NETDEV));
    session.setSessionID(properties.get(SESSION_ID));
    session.setConnectionState(properties.get(CONNECTION_STATE));
    session.setSessionState(properties.get(SESSION_STATE));
    return session;
}
Also used : IScsiSession(com.iwave.ext.linux.model.IScsiSession) IScsiTarget(com.iwave.ext.linux.model.IScsiTarget)

Aggregations

IScsiSession (com.iwave.ext.linux.model.IScsiSession)3 VerifyMountPoint (com.emc.sa.service.linux.tasks.VerifyMountPoint)1 ITLRestRep (com.emc.storageos.model.block.export.ITLRestRep)1 ListIScsiSessionsCommand (com.iwave.ext.linux.command.iscsi.ListIScsiSessionsCommand)1 IScsiHost (com.iwave.ext.linux.model.IScsiHost)1 IScsiTarget (com.iwave.ext.linux.model.IScsiTarget)1 MountPoint (com.iwave.ext.linux.model.MountPoint)1