Search in sources :

Example 1 with HostFibreChannelHba

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);
    }
}
Also used : HostVirtualNic(com.vmware.vim25.HostVirtualNic) IpInterface(com.emc.storageos.db.client.model.IpInterface) Initiator(com.emc.storageos.db.client.model.Initiator) HostInternetScsiHba(com.vmware.vim25.HostInternetScsiHba) ArrayList(java.util.ArrayList) HostFibreChannelHba(com.vmware.vim25.HostFibreChannelHba) HostHostBusAdapter(com.vmware.vim25.HostHostBusAdapter)

Example 2 with HostFibreChannelHba

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;
}
Also used : HostFibreChannelHba(com.vmware.vim25.HostFibreChannelHba) HostHostBusAdapter(com.vmware.vim25.HostHostBusAdapter)

Aggregations

HostFibreChannelHba (com.vmware.vim25.HostFibreChannelHba)2 HostHostBusAdapter (com.vmware.vim25.HostHostBusAdapter)2 Initiator (com.emc.storageos.db.client.model.Initiator)1 IpInterface (com.emc.storageos.db.client.model.IpInterface)1 HostInternetScsiHba (com.vmware.vim25.HostInternetScsiHba)1 HostVirtualNic (com.vmware.vim25.HostVirtualNic)1 ArrayList (java.util.ArrayList)1