Search in sources :

Example 1 with VirtualNicManagerNetConfig

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

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.getValue() + ", mgmtPortgroup: " + managementPortGroup);
    VmwareHypervisorHostNetworkSummary summary = new VmwareHypervisorHostNetworkSummary();
    if (getHostType() == VmwareHostType.ESXi) {
        List<VirtualNicManagerNetConfig> netConfigs = _context.getVimClient().getDynamicProperty(_mor, "config.virtualNicManagerInfo.netConfig");
        assert (netConfigs != null);
        String dvPortGroupKey;
        String portGroup;
        for (VirtualNicManagerNetConfig netConfig : netConfigs) {
            if (netConfig.getNicType().equals("management")) {
                for (HostVirtualNic nic : netConfig.getCandidateVnic()) {
                    portGroup = nic.getPortgroup();
                    if (portGroup == null || portGroup.isEmpty()) {
                        dvPortGroupKey = nic.getSpec().getDistributedVirtualPort().getPortgroupKey();
                        portGroup = getNetworkName(dvPortGroupKey);
                    }
                    if (portGroup.equalsIgnoreCase(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
        List<HostVirtualNic> hostVNics = _context.getVimClient().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 2 with VirtualNicManagerNetConfig

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

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

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