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);
}
}
}
}
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);
}
}
}
}
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 macAddress = parser.findMatch(MAC_ADDRESS_PATTERN, textBlock);
ipInfo.setMacAddress(StringUtils.trim(macAddress));
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));
results.add(ipInfo);
}
}
}
Aggregations