use of com.vmware.vim25.HostFibreChannelHba in project coprhd-controller by CoprHD.
the class EsxHostDiscoveryAdapter method discoverConnectedHostInitiators.
/**
* Discovers connected Host's Initiators and Ipinterfaces
*
* @param hostSystem
* - {@link HostSystem} VI SDK managedObject instance
* @param targetHost
* - {@link Host} being discovered.
* @param oldInitiators
* - old initiator list
* @param addedInitiators
* - new/added initiator list
*/
protected void discoverConnectedHostInitiators(HostSystem hostSystem, Host targetHost, List<Initiator> oldInitiators, List<Initiator> addedInitiators) {
// discover ipInterfaces
info(String.format("Discovering IP interfaces for %s", targetHost.forDisplay()));
List<IpInterface> oldIpInterfaces = new ArrayList<IpInterface>();
Iterables.addAll(oldIpInterfaces, getIpInterfaces(targetHost));
for (HostVirtualNic nic : getNics(hostSystem)) {
if (isIp6Interface(nic)) {
IpInterface ipInterface = getOrCreateIpInterface(oldIpInterfaces, nic.spec.getIp().ipAddress);
discoverIp6Interface(targetHost, ipInterface, nic);
}
if (isIp4Interface(nic)) {
IpInterface ipInterface = getOrCreateIpInterface(oldIpInterfaces, nic.spec.getIp().ipAddress);
discoverIp4Interface(targetHost, ipInterface, nic);
}
}
removeDiscoveredInterfaces(oldIpInterfaces);
info(String.format("Discovering initiators for %s", targetHost.forDisplay()));
Iterables.addAll(oldInitiators, getInitiators(targetHost));
for (HostHostBusAdapter hba : getHostBusAdapters(hostSystem)) {
if (hba instanceof HostFibreChannelHba) {
String port = SanUtils.normalizeWWN(((HostFibreChannelHba) hba).getPortWorldWideName());
Initiator initiator;
if (findInitiatorByPort(oldInitiators, port) == null) {
initiator = getOrCreateInitiator(targetHost.getId(), oldInitiators, port);
addedInitiators.add(initiator);
} else {
initiator = getOrCreateInitiator(targetHost.getId(), oldInitiators, port);
}
discoverInitiator(targetHost, initiator, (HostFibreChannelHba) hba);
} else if (hba instanceof HostInternetScsiHba) {
String iqn = ((HostInternetScsiHba) hba).getIScsiName();
Initiator initiator;
if (findInitiatorByPort(oldInitiators, iqn) == null) {
initiator = getOrCreateInitiator(targetHost.getId(), oldInitiators, iqn);
addedInitiators.add(initiator);
} else {
initiator = getOrCreateInitiator(targetHost.getId(), oldInitiators, iqn);
}
discoverInitiator(targetHost, initiator, (HostInternetScsiHba) hba);
}
}
if (!oldInitiators.isEmpty()) {
clearScaleIOInitiators(oldInitiators);
}
}
use of com.vmware.vim25.HostFibreChannelHba in project coprhd-controller by CoprHD.
the class HostStorageAPI method findHostBusAdapterByWwn.
/**
* Finds a host bus adapter in the collection by FibreChannel port WWN.
*
* @param hbas the collection of host bus adapters.
* @param portWwn the port WWN.
* @return the FibreChannel adapter, or null if no matching adapters.
*/
public static HostFibreChannelHba findHostBusAdapterByWwn(Collection<? extends HostHostBusAdapter> hbas, String portWwn) {
portWwn = normalizeWwn(portWwn);
for (HostHostBusAdapter hba : hbas) {
if (hba instanceof HostFibreChannelHba) {
HostFibreChannelHba fcHba = (HostFibreChannelHba) hba;
String wwn = normalizeWwn(fcHba.getPortWorldWideName());
if (StringUtils.equals(portWwn, wwn)) {
return fcHba;
}
}
}
return null;
}
Aggregations