当前位置: 首页>>代码示例>>Java>>正文


Java GuestInfo.getNet方法代码示例

本文整理汇总了Java中com.vmware.vim25.GuestInfo.getNet方法的典型用法代码示例。如果您正苦于以下问题:Java GuestInfo.getNet方法的具体用法?Java GuestInfo.getNet怎么用?Java GuestInfo.getNet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.vmware.vim25.GuestInfo的用法示例。


在下文中一共展示了GuestInfo.getNet方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getNicInfo

import com.vmware.vim25.GuestInfo; //导入方法依赖的package包/类
GuestNicInfo getNicInfo(GuestInfo guestInfo, String adapter) {
    for (GuestNicInfo info : guestInfo.getNet()) {
        if (info != null && adapter.equals(info.getNetwork())) {
            return info;
        }
    }
    return null;
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:9,代码来源:VMwareAccessInfo.java

示例2: getVRouterVMIpFabricAddress

import com.vmware.vim25.GuestInfo; //导入方法依赖的package包/类
protected String getVRouterVMIpFabricAddress(String hostName,
        HostSystem host, String vmNamePrefix)
                throws Exception {
    // Find if vRouter Ip Fabric mapping exists..
    String vRouterIpAddress = esxiToVRouterIpMap.get(hostName);
    if (host.getRuntime().isInMaintenanceMode()) {
        VRouterNotifier.setVrouterActive(vRouterIpAddress, false);
    }

    if (vRouterIpAddress != null) {
        return vRouterIpAddress;
    } else {
        s_logger.debug(" vRouter IP mapping for Host: " + hostName +
                "does not exist");
    }

    VirtualMachine[] vms = host.getVms();
    for (VirtualMachine vm : vms) {
        String vmName = vm.getName();
        if (!vmName.toLowerCase().contains(vmNamePrefix.toLowerCase())) {
            continue;
        }
        // Assumption here is that VMware Tools are installed
        // and IP address is available
        GuestInfo guestInfo = vm.getGuest();
        if (guestInfo == null) {
            s_logger.debug(" Host: " + hostName +
                    " vm:" + vmName + " GuestInfo - VMware Tools " +
                    " NOT installed");
            continue;
        }
        GuestNicInfo[] nicInfos = guestInfo.getNet();
        if (nicInfos == null) {
            s_logger.debug(" Host: " + hostName +
                    " vm:" + vmName + " GuestNicInfo - VMware Tools " +
                    " NOT installed");
            continue;
        }
        for (GuestNicInfo nicInfo : nicInfos) {
            // Extract the IP address associated with simple port
            // group. Assumption here is that Contrail VRouter VM will
            // have only one standard port group
            String networkName = nicInfo.getNetwork();
            if (networkName == null || !networkName.equals(contrailIpFabricPgName)) {
                continue;
            }
            Network network = (Network)
                    inventoryNavigator.searchManagedEntity("Network",
                            networkName);
            if (network == null) {
                s_logger.debug("Host: " +
                        hostName + " vm: " + vmName + " network: " +
                        networkName + " NOT found");
                continue;
            }
            NetIpConfigInfo ipConfigInfo = nicInfo.getIpConfig();
            if (ipConfigInfo == null) {
                continue;
            }
            NetIpConfigInfoIpAddress[] ipAddrConfigInfos =
                    ipConfigInfo.getIpAddress();
            if (ipAddrConfigInfos == null ||
                    ipAddrConfigInfos.length == 0) {
                continue;

            }
            for (NetIpConfigInfoIpAddress ipAddrConfigInfo :
                ipAddrConfigInfos) {
                String ipAddress = ipAddrConfigInfo.getIpAddress();
                // Choose IPv4 only
                InetAddress ipAddr = InetAddress.getByName(ipAddress);
                if (ipAddr instanceof Inet4Address) {
                   // found vRouter VM ip-fabric address. Store it.
                    esxiToVRouterIpMap.put(hostName, ipAddress);
                    return ipAddress;
                }
            }
        }
    }
    return null;
}
 
开发者ID:Juniper,项目名称:contrail-vcenter-plugin,代码行数:82,代码来源:VCenterDB.java

示例3: getVirtualMachineIpAddress

import com.vmware.vim25.GuestInfo; //导入方法依赖的package包/类
public static String getVirtualMachineIpAddress(VirtualMachine vm,
        String dvPgName) throws Exception {

    // Assumption here is that VMware Tools are installed
    // and IP address is available
    GuestInfo guestInfo = vm.getGuest();
    String vmName = vm.getName();
    if (guestInfo == null) {
        s_logger.debug("dvPg: " + dvPgName + " vm:" + vmName
                + " GuestInfo - VMware Tools " + " NOT installed");
        return null;
    }
    GuestNicInfo[] nicInfos = guestInfo.getNet();
    if (nicInfos == null) {
        s_logger.debug("dvPg: " + dvPgName + " vm:" + vmName
                + " GuestNicInfo - VMware Tools " + " NOT installed");
        return null;
    }
    for (GuestNicInfo nicInfo : nicInfos) {
        // Extract the IP address associated with simple port
        // group. Assumption here is that Contrail VRouter VM will
        // have only one standard port group
        String networkName = nicInfo.getNetwork();
        if (networkName == null || !networkName.equals(dvPgName)) {
            continue;
        }

        NetIpConfigInfo ipConfigInfo = nicInfo.getIpConfig();
        if (ipConfigInfo == null) {
            continue;
        }
        NetIpConfigInfoIpAddress[] ipAddrConfigInfos =
                ipConfigInfo.getIpAddress();
        if (ipAddrConfigInfos == null ||
                ipAddrConfigInfos.length == 0) {
            continue;

        }
        for (NetIpConfigInfoIpAddress ipAddrConfigInfo :
            ipAddrConfigInfos) {
            String ipAddress = ipAddrConfigInfo.getIpAddress();
            InetAddress ipAddr = InetAddress.getByName(ipAddress);
            if (ipAddr instanceof Inet4Address) {
                // the VMI can have multiple IPv4 and IPv6 addresses,
                // but we pick only the first IPv4 address
                return ipAddress;
            }
        }
    }
    return null;
}
 
开发者ID:Juniper,项目名称:contrail-vcenter-plugin,代码行数:52,代码来源:VCenterDB.java


注:本文中的com.vmware.vim25.GuestInfo.getNet方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。