Search in sources :

Example 6 with HostNetworkInfo

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

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

the class HostMO method getPortGroupSpec.

public HostPortGroupSpec getPortGroupSpec(String portGroupName) throws Exception {
    HostNetworkInfo hostNetInfo = getHostNetworkInfo();
    HostPortGroup[] portGroups = hostNetInfo.getPortgroup();
    if (portGroups != null) {
        for (HostPortGroup portGroup : portGroups) {
            HostPortGroupSpec spec = portGroup.getSpec();
            if (spec.getName().equals(portGroupName))
                return spec;
        }
    }
    return null;
}
Also used : HostNetworkInfo(com.vmware.vim25.HostNetworkInfo) HostPortGroup(com.vmware.vim25.HostPortGroup) HostPortGroupSpec(com.vmware.vim25.HostPortGroupSpec)

Example 8 with HostNetworkInfo

use of com.vmware.vim25.HostNetworkInfo 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
     * @throws RemoteException
     */
public TreeSet<String> getHostSystemIpAddresses(HostSystem hostSystem) throws RemoteException {
    TreeSet<String> ipAddresses = new TreeSet<String>();
    HostNetworkSystem hostNetworkSystem = hostSystem.getHostNetworkSystem();
    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) HostNetworkSystem(com.vmware.vim25.mo.HostNetworkSystem)

Example 9 with HostNetworkInfo

use of com.vmware.vim25.HostNetworkInfo 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)

Example 10 with HostNetworkInfo

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

the class HostMO method getPortGroupSpec.

public HostPortGroupSpec getPortGroupSpec(String portGroupName) throws Exception {
    HostNetworkInfo hostNetInfo = getHostNetworkInfo();
    List<HostPortGroup> portGroups = hostNetInfo.getPortgroup();
    if (portGroups != null) {
        for (HostPortGroup portGroup : portGroups) {
            HostPortGroupSpec spec = portGroup.getSpec();
            if (spec.getName().equals(portGroupName))
                return spec;
        }
    }
    return null;
}
Also used : HostNetworkInfo(com.vmware.vim25.HostNetworkInfo) HostPortGroup(com.vmware.vim25.HostPortGroup) HostPortGroupSpec(com.vmware.vim25.HostPortGroupSpec)

Aggregations

HostNetworkInfo (com.vmware.vim25.HostNetworkInfo)12 HostPortGroup (com.vmware.vim25.HostPortGroup)6 HostPortGroupSpec (com.vmware.vim25.HostPortGroupSpec)6 HostVirtualNic (com.vmware.vim25.HostVirtualNic)5 HostIpConfig (com.vmware.vim25.HostIpConfig)2 VirtualNicManagerNetConfig (com.vmware.vim25.VirtualNicManagerNetConfig)2 HostNetworkSystem (com.vmware.vim25.mo.HostNetworkSystem)2 AboutInfo (com.vmware.vim25.AboutInfo)1 ElementDescription (com.vmware.vim25.ElementDescription)1 HostOpaqueNetworkInfo (com.vmware.vim25.HostOpaqueNetworkInfo)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 PerfMetricId (com.vmware.vim25.PerfMetricId)1 PerfMetricIntSeries (com.vmware.vim25.PerfMetricIntSeries)1 PerfProviderSummary (com.vmware.vim25.PerfProviderSummary)1 PerfQuerySpec (com.vmware.vim25.PerfQuerySpec)1 VimPortType (com.vmware.vim25.VimPortType)1