Search in sources :

Example 6 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 7 with HBAInfo

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

the class RescanHBAsCommand method setHbas.

public void setHbas(Collection<HBAInfo> hbas) {
    StrBuilder sb = new StrBuilder();
    for (HBAInfo hba : hbas) {
        sb.appendSeparator(' ');
        sb.append("host").append(hba.getHostId());
    }
    setVariableValue(HOSTS, sb.toString());
}
Also used : HBAInfo(com.iwave.ext.linux.model.HBAInfo) StrBuilder(org.apache.commons.lang.text.StrBuilder)

Example 8 with HBAInfo

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

the class HpuxHostDiscoveryAdapter method discoverInitiators.

@Override
protected void discoverInitiators(Host host, List<Initiator> oldInitiators, HostStateChange changes) {
    HpuxSystem hpux = getCli(host);
    List<Initiator> addedInitiators = Lists.newArrayList();
    try {
        for (HBAInfo hba : hpux.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 : hpux.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) HpuxSystem(com.emc.hpux.HpuxSystem) Initiator(com.emc.storageos.db.client.model.Initiator) 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 9 with HBAInfo

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

the class LinuxHostDiscoveryAdapter method discoverInitiators.

@Override
protected void discoverInitiators(Host host, List<Initiator> oldInitiators, HostStateChange changes) {
    LinuxSystemCLI linux = createLinuxCLI(host);
    List<Initiator> addedInitiators = Lists.newArrayList();
    try {
        for (HBAInfo hba : linux.listHBAs()) {
            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 : linux.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");
    }
    try {
        String cephPseudoPort = String.format("rbd:%s", linux.getMachineId());
        Initiator initiator;
        if (findInitiatorByPort(oldInitiators, cephPseudoPort) == null) {
            initiator = getOrCreateInitiator(host.getId(), oldInitiators, cephPseudoPort);
            addedInitiators.add(initiator);
        } else {
            initiator = getOrCreateInitiator(host.getId(), oldInitiators, cephPseudoPort);
        }
        discoverRBDInitiator(host, initiator, cephPseudoPort);
    } catch (DeviceControllerException e) {
        throw e;
    } catch (Exception e) {
        LOG.error("Failed to create RBD pseudo port, 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 : LinuxSystemCLI(com.iwave.ext.linux.LinuxSystemCLI) HBAInfo(com.iwave.ext.linux.model.HBAInfo) Initiator(com.emc.storageos.db.client.model.Initiator) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) URI(java.net.URI) MultipathException(com.iwave.ext.linux.command.MultipathException) PowerPathException(com.iwave.ext.linux.command.powerpath.PowerPathException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) CompatibilityException(com.emc.storageos.computesystemcontroller.exceptions.CompatibilityException) CommandException(com.iwave.ext.command.CommandException) JSchException(com.jcraft.jsch.JSchException) ComputeSystemControllerException(com.emc.storageos.computesystemcontroller.exceptions.ComputeSystemControllerException)

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