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);
}
}
}
}
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());
}
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);
}
}
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);
}
}
Aggregations