Search in sources :

Example 1 with HBAInfo

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

the class AixHostDiscoveryAdapter method discoverInitiators.

@Override
protected void discoverInitiators(Host host, List<Initiator> oldInitiators, HostStateChange changes) {
    AixSystem aix = getCli(host);
    List<Initiator> addedInitiators = Lists.newArrayList();
    try {
        for (HBAInfo hba : aix.listInitiators()) {
            Initiator initiator;
            String wwpn = SanUtils.normalizeWWN(hba.getWwpn());
            if (findInitiatorByPort(oldInitiators, wwpn) == null) {
                initiator = getOrCreateInitiator(host.getId(), oldInitiators, wwpn);
                addedInitiators.add(initiator);
            } else {
                initiator = getOrCreateInitiator(host.getId(), oldInitiators, wwpn);
            }
            discoverFCInitiator(host, initiator, hba);
        }
    } catch (DeviceControllerException e) {
        throw e;
    } catch (Exception e) {
        LOG.error("Failed to list FC Ports, skipping");
    }
    try {
        for (String iqn : aix.listIQNs()) {
            Initiator initiator;
            if (findInitiatorByPort(oldInitiators, iqn) == null) {
                initiator = getOrCreateInitiator(host.getId(), oldInitiators, iqn);
                addedInitiators.add(initiator);
            } else {
                initiator = getOrCreateInitiator(host.getId(), oldInitiators, iqn);
            }
            discoverISCSIInitiator(host, initiator, iqn);
        }
    } catch (DeviceControllerException e) {
        throw e;
    } catch (Exception e) {
        LOG.error("Failed to list iSCSI Ports, skipping");
    }
    // update export groups with new initiators if host is in use.
    if (!addedInitiators.isEmpty()) {
        Collection<URI> addedInitiatorIds = Lists.newArrayList(Collections2.transform(addedInitiators, CommonTransformerFunctions.fctnDataObjectToID()));
        changes.setNewInitiators(addedInitiatorIds);
    }
}
Also used : HBAInfo(com.iwave.ext.linux.model.HBAInfo) Initiator(com.emc.storageos.db.client.model.Initiator) AixSystem(com.emc.aix.AixSystem) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) URI(java.net.URI) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) CommandException(com.iwave.ext.command.CommandException) JSchException(com.jcraft.jsch.JSchException) ComputeSystemControllerException(com.emc.storageos.computesystemcontroller.exceptions.ComputeSystemControllerException)

Example 2 with HBAInfo

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

the class AixVioDiscoveryAdapter method discoverInitiators.

@Override
protected void discoverInitiators(Host host, List<Initiator> oldInitiators, HostStateChange changes) {
    AixVioCLI cli = getCli(host);
    List<Initiator> addedInitiators = Lists.newArrayList();
    try {
        for (HBAInfo hba : cli.listInitiators()) {
            Initiator initiator;
            String wwpn = SanUtils.normalizeWWN(hba.getWwpn());
            if (findInitiatorByPort(oldInitiators, wwpn) == null) {
                initiator = getOrCreateInitiator(host.getId(), oldInitiators, wwpn);
                addedInitiators.add(initiator);
            } else {
                initiator = getOrCreateInitiator(host.getId(), oldInitiators, wwpn);
            }
            discoverFCInitiator(host, initiator, hba);
        }
    } catch (DeviceControllerException e) {
        throw e;
    } catch (Exception e) {
        LOG.error("Failed to list FC Ports, skipping");
    }
    try {
        for (String iqn : cli.listIQNs()) {
            Initiator initiator;
            if (findInitiatorByPort(oldInitiators, iqn) == null) {
                initiator = getOrCreateInitiator(host.getId(), oldInitiators, iqn);
                addedInitiators.add(initiator);
            } else {
                initiator = getOrCreateInitiator(host.getId(), oldInitiators, iqn);
            }
            discoverISCSIInitiator(host, initiator, iqn);
        }
    } catch (DeviceControllerException e) {
        throw e;
    } catch (Exception e) {
        LOG.error("Failed to list iSCSI Ports, skipping");
    }
    // update export groups with new initiators if host is in use.
    if (!addedInitiators.isEmpty()) {
        Collection<URI> addedInitiatorIds = Lists.newArrayList(Collections2.transform(addedInitiators, CommonTransformerFunctions.fctnDataObjectToID()));
        changes.setNewInitiators(addedInitiatorIds);
    }
}
Also used : HBAInfo(com.iwave.ext.linux.model.HBAInfo) Initiator(com.emc.storageos.db.client.model.Initiator) AixVioCLI(com.emc.aix.AixVioCLI) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) URI(java.net.URI) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) CommandException(com.iwave.ext.command.CommandException) ComputeSystemControllerException(com.emc.storageos.computesystemcontroller.exceptions.ComputeSystemControllerException)

Example 3 with HBAInfo

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

the class ListHBAInfoCommand method parseOutput.

@Override
public void parseOutput() {
    results = Lists.newArrayList();
    if (getOutput() != null && getOutput().getStdout() != null) {
        String stdout = getOutput().getStdout();
        TextParser parser = new TextParser();
        parser.setRepeatPattern(HOST_PATTERN);
        for (String textBlock : parser.parseTextBlocks(stdout)) {
            String host = parser.findMatch(HOST_PATTERN, textBlock);
            if (StringUtils.isNotBlank(host)) {
                HBAInfo hba = new HBAInfo();
                hba.setHostId(Integer.parseInt(host));
                String wwnn = parser.findMatch(WWNN_PATTERN, textBlock);
                hba.setWwnn(normalizeWWN(wwnn));
                String wwpn = parser.findMatch(WWPN_PATTERN, textBlock);
                hba.setWwpn(normalizeWWN(wwpn));
                results.add(hba);
            }
        }
    }
}
Also used : HBAInfo(com.iwave.ext.linux.model.HBAInfo) TextParser(com.iwave.ext.text.TextParser)

Example 4 with HBAInfo

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

the class FindHBAs method executeTask.

@Override
public List<HBAInfo> executeTask() throws Exception {
    List<HBAInfo> results = executeCommand(new ListHBAInfoCommand(), SHORT_TIMEOUT);
    debug("FindHBAs.lookingForWWNs", pwwns);
    Iterator<HBAInfo> iter = results.iterator();
    while (iter.hasNext()) {
        HBAInfo hba = iter.next();
        String wwn = LinuxUtils.normalizeWWN(hba.getWwpn());
        if (!pwwns.contains(wwn)) {
            logDebug("FindHBAs.ignoringHBA", hba);
            iter.remove();
        }
    }
    if (results.isEmpty()) {
        throw stateException("FindHBAs.illegalState.couldNotFindHBAs", pwwns);
    }
    return results;
}
Also used : HBAInfo(com.iwave.ext.linux.model.HBAInfo) ListHBAInfoCommand(com.iwave.ext.linux.command.ListHBAInfoCommand)

Example 5 with HBAInfo

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

the class ListHBAInfoCommand method parseOutput.

@Override
public void parseOutput() {
    results = Lists.newArrayList();
    if (getOutput() != null && getOutput().getStdout() != null) {
        String stdout = getOutput().getStdout();
        TextParser parser = new TextParser();
        parser.setRepeatPattern(DEVICE_PATTERN);
        for (String textBlock : parser.parseTextBlocks(stdout)) {
            String host = parser.findMatch(DEVICE_PATTERN, textBlock);
            if (StringUtils.isNotBlank(host)) {
                HBAInfo hba = new HBAInfo();
                String wwnn = parser.findMatch(WWNN_PATTERN, textBlock);
                hba.setWwnn(normalizeWWN(wwnn));
                String wwpn = parser.findMatch(WWPN_PATTERN, textBlock);
                hba.setWwpn(normalizeWWN(wwpn));
                results.add(hba);
            }
        }
    }
}
Also used : HBAInfo(com.iwave.ext.linux.model.HBAInfo) TextParser(com.iwave.ext.text.TextParser)

Aggregations

HBAInfo (com.iwave.ext.linux.model.HBAInfo)9 ComputeSystemControllerException (com.emc.storageos.computesystemcontroller.exceptions.ComputeSystemControllerException)4 Initiator (com.emc.storageos.db.client.model.Initiator)4 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)4 CommandException (com.iwave.ext.command.CommandException)4 URI (java.net.URI)4 TextParser (com.iwave.ext.text.TextParser)3 JSchException (com.jcraft.jsch.JSchException)3 AixSystem (com.emc.aix.AixSystem)1 AixVioCLI (com.emc.aix.AixVioCLI)1 HpuxSystem (com.emc.hpux.HpuxSystem)1 CompatibilityException (com.emc.storageos.computesystemcontroller.exceptions.CompatibilityException)1 LinuxSystemCLI (com.iwave.ext.linux.LinuxSystemCLI)1 ListHBAInfoCommand (com.iwave.ext.linux.command.ListHBAInfoCommand)1 MultipathException (com.iwave.ext.linux.command.MultipathException)1 PowerPathException (com.iwave.ext.linux.command.powerpath.PowerPathException)1 StrBuilder (org.apache.commons.lang.text.StrBuilder)1