Java 类com.vmware.vim25.VirtualNicManagerNetConfig 实例源码

项目:vijava    文件:HostVirtualNicManager.java   
public VirtualNicManagerNetConfig queryNetConfig(String nicType) throws HostConfigFault, InvalidArgument, RuntimeFault, RemoteException
{
    return getVimService().queryNetConfig(getMOR(), nicType);
}
项目:cloudstack    文件:HostMO.java   
public List<VirtualNicManagerNetConfig> getHostVirtualNicManagerNetConfig() throws Exception {
    return _context.getVimClient().getDynamicProperty(_mor, "config.virtualNicManagerInfo.netConfig");
}
项目:cloudstack    文件:HostMO.java   
@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);
}