Search in sources :

Example 6 with HostVirtualNic

use of com.vmware.vim25.HostVirtualNic 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 7 with HostVirtualNic

use of com.vmware.vim25.HostVirtualNic in project CloudStack-archive by CloudStack-extras.

the class HostMO method getHyperHostNetworkSummary.

@Override
public VmwareHypervisorHostNetworkSummary getHyperHostNetworkSummary(String managementPortGroup) throws Exception {
    if (s_logger.isTraceEnabled())
        s_logger.trace("vCenter API trace - getHyperHostNetworkSummary(). target MOR: " + _mor.get_value() + ", mgmtPortgroup: " + managementPortGroup);
    VmwareHypervisorHostNetworkSummary summary = new VmwareHypervisorHostNetworkSummary();
    if (this.getHostType() == VmwareHostType.ESXi) {
        VirtualNicManagerNetConfig[] netConfigs = (VirtualNicManagerNetConfig[]) _context.getServiceUtil().getDynamicProperty(_mor, "config.virtualNicManagerInfo.netConfig");
        assert (netConfigs != null);
        for (int i = 0; i < netConfigs.length; i++) {
            if (netConfigs[i].getNicType().equals("management")) {
                for (HostVirtualNic nic : netConfigs[i].getCandidateVnic()) {
                    if (nic.getPortgroup().equals(managementPortGroup)) {
                        summary.setHostIp(nic.getSpec().getIp().getIpAddress());
                        summary.setHostNetmask(nic.getSpec().getIp().getSubnetMask());
                        summary.setHostMacAddress(nic.getSpec().getMac());
                        if (s_logger.isTraceEnabled())
                            s_logger.trace("vCenter API trace - getHyperHostNetworkSummary() done(successfully)");
                        return summary;
                    }
                }
            }
        }
    } else {
        // try with ESX path
        HostVirtualNic[] hostVNics = (HostVirtualNic[]) _context.getServiceUtil().getDynamicProperty(_mor, "config.network.consoleVnic");
        if (hostVNics != null) {
            for (HostVirtualNic vnic : hostVNics) {
                if (vnic.getPortgroup().equals(managementPortGroup)) {
                    summary.setHostIp(vnic.getSpec().getIp().getIpAddress());
                    summary.setHostNetmask(vnic.getSpec().getIp().getSubnetMask());
                    summary.setHostMacAddress(vnic.getSpec().getMac());
                    if (s_logger.isTraceEnabled())
                        s_logger.trace("vCenter API trace - getHyperHostNetworkSummary() done(successfully)");
                    return summary;
                }
            }
        }
    }
    if (s_logger.isTraceEnabled())
        s_logger.trace("vCenter API trace - getHyperHostNetworkSummary() done(failed)");
    throw new Exception("Uanble to find management port group " + managementPortGroup);
}
Also used : HostVirtualNic(com.vmware.vim25.HostVirtualNic) VirtualNicManagerNetConfig(com.vmware.vim25.VirtualNicManagerNetConfig)

Example 8 with HostVirtualNic

use of com.vmware.vim25.HostVirtualNic in project CloudStack-archive by CloudStack-extras.

the class HostMO method getPortGroupNameByNicType.

public String getPortGroupNameByNicType(HostVirtualNicType nicType) throws Exception {
    assert (nicType != null);
    VirtualNicManagerNetConfig[] netConfigs = (VirtualNicManagerNetConfig[]) _context.getServiceUtil().getDynamicProperty(_mor, "config.virtualNicManagerInfo.netConfig");
    if (netConfigs != null) {
        for (VirtualNicManagerNetConfig netConfig : netConfigs) {
            if (netConfig.getNicType().equals(nicType.toString())) {
                HostVirtualNic[] nics = netConfig.getCandidateVnic();
                if (nics != null) {
                    for (HostVirtualNic nic : nics) {
                        return nic.getPortgroup();
                    }
                }
            }
        }
    }
    if (nicType == HostVirtualNicType.management) {
        // ESX management network is configured in service console
        HostNetworkInfo netInfo = getHostNetworkInfo();
        assert (netInfo != null);
        HostVirtualNic[] nics = netInfo.getConsoleVnic();
        if (nics != null) {
            for (HostVirtualNic nic : nics) {
                return nic.getPortgroup();
            }
        }
    }
    return null;
}
Also used : HostVirtualNic(com.vmware.vim25.HostVirtualNic) HostNetworkInfo(com.vmware.vim25.HostNetworkInfo) VirtualNicManagerNetConfig(com.vmware.vim25.VirtualNicManagerNetConfig)

Example 9 with HostVirtualNic

use of com.vmware.vim25.HostVirtualNic in project opennms by OpenNMS.

the class VmwareViJavaAccess method getHostSystemIpAddresses.

/**
 * Searches for all ip addresses of a host system
 *
 * @param hostSystem the host system to query
 * @return the ip addresses of the host system, the first one is the primary
 */
public TreeSet<String> getHostSystemIpAddresses(HostSystem hostSystem) {
    TreeSet<String> ipAddresses = new TreeSet<String>();
    HostNetworkSystem hostNetworkSystem = null;
    try {
        hostNetworkSystem = hostSystem.getHostNetworkSystem();
    } catch (RemoteException e) {
        logger.warn("Error fetching network information for Host System '{}' (ID: {})", hostSystem.getName(), hostSystem.getMOR().getVal());
        logger.warn("Exception thrown while fetching network information: {}", e);
        return ipAddresses;
    }
    if (hostNetworkSystem != null) {
        HostNetworkInfo hostNetworkInfo = hostNetworkSystem.getNetworkInfo();
        if (hostNetworkInfo != null) {
            HostVirtualNic[] hostVirtualNics = hostNetworkInfo.getConsoleVnic();
            if (hostVirtualNics != null) {
                for (HostVirtualNic hostVirtualNic : hostVirtualNics) {
                    ipAddresses.add(hostVirtualNic.getSpec().getIp().getIpAddress());
                }
            }
            hostVirtualNics = hostNetworkInfo.getVnic();
            if (hostVirtualNics != null) {
                for (HostVirtualNic hostVirtualNic : hostVirtualNics) {
                    ipAddresses.add(hostVirtualNic.getSpec().getIp().getIpAddress());
                }
            }
        }
    }
    return ipAddresses;
}
Also used : HostNetworkInfo(com.vmware.vim25.HostNetworkInfo) HostVirtualNic(com.vmware.vim25.HostVirtualNic) TreeSet(java.util.TreeSet) RemoteException(java.rmi.RemoteException) HostNetworkSystem(com.vmware.vim25.mo.HostNetworkSystem)

Example 10 with HostVirtualNic

use of com.vmware.vim25.HostVirtualNic in project cloudstack by apache.

the class HostMO method getPortGroupNameByNicType.

public String getPortGroupNameByNicType(HostVirtualNicType nicType) throws Exception {
    assert (nicType != null);
    List<VirtualNicManagerNetConfig> netConfigs = _context.getVimClient().getDynamicProperty(_mor, "config.virtualNicManagerInfo.netConfig");
    if (netConfigs != null) {
        for (VirtualNicManagerNetConfig netConfig : netConfigs) {
            if (netConfig.getNicType().equals(nicType.toString())) {
                List<HostVirtualNic> nics = netConfig.getCandidateVnic();
                if (nics != null) {
                    for (HostVirtualNic nic : nics) {
                        return nic.getPortgroup();
                    }
                }
            }
        }
    }
    if (nicType == HostVirtualNicType.management) {
        // ESX management network is configured in service console
        HostNetworkInfo netInfo = getHostNetworkInfo();
        assert (netInfo != null);
        List<HostVirtualNic> nics = netInfo.getConsoleVnic();
        if (nics != null) {
            for (HostVirtualNic nic : nics) {
                return nic.getPortgroup();
            }
        }
    }
    return null;
}
Also used : HostVirtualNic(com.vmware.vim25.HostVirtualNic) HostNetworkInfo(com.vmware.vim25.HostNetworkInfo) VirtualNicManagerNetConfig(com.vmware.vim25.VirtualNicManagerNetConfig)

Aggregations

HostVirtualNic (com.vmware.vim25.HostVirtualNic)9 HostNetworkInfo (com.vmware.vim25.HostNetworkInfo)5 VirtualNicManagerNetConfig (com.vmware.vim25.VirtualNicManagerNetConfig)4 HostIpConfig (com.vmware.vim25.HostIpConfig)2 HostNetworkSystem (com.vmware.vim25.mo.HostNetworkSystem)2 RemoteException (java.rmi.RemoteException)2 Initiator (com.emc.storageos.db.client.model.Initiator)1 IpInterface (com.emc.storageos.db.client.model.IpInterface)1 AboutInfo (com.vmware.vim25.AboutInfo)1 ElementDescription (com.vmware.vim25.ElementDescription)1 HostConfigInfo (com.vmware.vim25.HostConfigInfo)1 HostFibreChannelHba (com.vmware.vim25.HostFibreChannelHba)1 HostHostBusAdapter (com.vmware.vim25.HostHostBusAdapter)1 HostInternetScsiHba (com.vmware.vim25.HostInternetScsiHba)1 HostIpConfigIpV6Address (com.vmware.vim25.HostIpConfigIpV6Address)1 HostServiceTicket (com.vmware.vim25.HostServiceTicket)1 HostVirtualNicSpec (com.vmware.vim25.HostVirtualNicSpec)1 ManagedObjectReference (com.vmware.vim25.ManagedObjectReference)1 PerfCounterInfo (com.vmware.vim25.PerfCounterInfo)1 PerfEntityMetric (com.vmware.vim25.PerfEntityMetric)1