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