Search in sources :

Example 1 with TextParser

use of com.iwave.ext.text.TextParser 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 2 with TextParser

use of com.iwave.ext.text.TextParser in project coprhd-controller by CoprHD.

the class ListIPInterfacesCommand 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(BLOCK_PATTERN);
        for (String textBlock : parser.parseTextBlocks(StringUtils.trim(stdout))) {
            IPInterface ipInfo = new IPInterface();
            String interfaceName = parser.findMatch(INTERFACE_NAME, textBlock);
            ipInfo.setInterfaceName(StringUtils.trim(interfaceName));
            String ipAddress = parser.findMatch(ADDRESS_PATTERN, textBlock);
            ipInfo.setIpAddress(StringUtils.trim(ipAddress));
            String netMask = parser.findMatch(MASK_PATTERN, textBlock);
            ipInfo.setNetMask(StringUtils.trim(netMask));
            String ip6Address = parser.findMatch(IP6_ADDRESS, textBlock);
            ipInfo.setIP6Address(StringUtils.trim(ip6Address));
            String broadcastAddress = parser.findMatch(BROADCAST_ADDRESS_PATTERN, textBlock);
            ipInfo.setBroadcastAddress(StringUtils.trim(broadcastAddress));
            if (ipInfo.getIpAddress() != null) {
                results.add(ipInfo);
            }
        }
    }
}
Also used : IPInterface(com.iwave.ext.linux.model.IPInterface) TextParser(com.iwave.ext.text.TextParser)

Example 3 with TextParser

use of com.iwave.ext.text.TextParser in project coprhd-controller by CoprHD.

the class ListMultiPathEntriesCommand 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(ENTRY_PATTERN);
        for (String textBlock : parser.parseTextBlocks(stdout)) {
            MultiPathEntry entry = readEntry(textBlock);
            if (entry != null) {
                results.add(entry);
            }
        }
    }
}
Also used : TextParser(com.iwave.ext.text.TextParser) MultiPathEntry(com.iwave.ext.linux.model.MultiPathEntry)

Example 4 with TextParser

use of com.iwave.ext.text.TextParser in project coprhd-controller by CoprHD.

the class GetNetworkAdapterMacAddressCommand method parseOutput.

@Override
public void parseOutput() {
    if (getOutput() != null && getOutput().getStdout() != null) {
        String stdout = getOutput().getStdout();
        TextParser parser = new TextParser();
        String macAddress = parser.findMatch(NETWORK_ADDRESS_PATTERN, stdout);
        results = normalizeMacAddress(macAddress);
    }
}
Also used : TextParser(com.iwave.ext.text.TextParser)

Example 5 with TextParser

use of com.iwave.ext.text.TextParser 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

TextParser (com.iwave.ext.text.TextParser)8 HBAInfo (com.iwave.ext.linux.model.HBAInfo)3 IPInterface (com.iwave.ext.linux.model.IPInterface)3 MultiPathEntry (com.iwave.ext.linux.model.MultiPathEntry)1