• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java GuestNicInfo类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



GuestNicInfo类属于com.vmware.vim25包,在下文中一共展示了GuestNicInfo类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getIpAddress

import com.vmware.vim25.GuestNicInfo; //导入依赖的package包/类
private String getIpAddress(GuestInfo guestInfo) {
    StringBuilder sb = new StringBuilder();
    for (int i = 1; i <= paramHandler.getNumberOfNetworkAdapter(); i++) {
        GuestNicInfo info = getNicInfo(guestInfo,
                paramHandler.getNetworkAdapter(i));
        if (info != null) {
            if (paramHandler.getNetworkAdapter(i) != null && !paramHandler
                    .getNetworkAdapter(i).trim().isEmpty()) {
                sb.append(paramHandler.getNetworkAdapter(i) + ": ");
            }
            sb.append(info.getIpAddress());
            if (i < paramHandler.getNumberOfNetworkAdapter()) {
                sb.append(", ");
            }
        }
    }
    return sb.toString();
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:19,代码来源:VMwareAccessInfo.java


示例2: createLogForGetState

import com.vmware.vim25.GuestNicInfo; //导入依赖的package包/类
private String createLogForGetState(boolean validHostname,
        VMPropertyHandler configuration, boolean isConnected,
        boolean validIp) {

    StringBuilder sb = new StringBuilder();
    sb.append("Guest system is not ready yet ");
    sb.append("[");
    sb.append("hostname (" + validHostname + ") =" + guestInfo.getHostName()
            + ", ");
    sb.append("ipReady=" + validIp + ", ");
    for (int i = 1; i <= configuration.getNumberOfNetworkAdapter(); i++) {
        GuestNicInfo info = getNicInfo(configuration, i);
        if (info != null) {
            sb.append(info.getNetwork() + "=");
            sb.append(info.getIpAddress());
            sb.append(",");
        }
    }
    sb.append("guestState=" + guestInfo.getGuestState() + ", ");
    sb.append("toolsState=" + guestInfo.getToolsStatus() + ", ");
    sb.append("toolsRunning=" + guestInfo.getToolsRunningStatus() + ", ");
    sb.append("isConnected=" + isConnected);
    sb.append("]");
    String logStatement = sb.toString();
    return logStatement;
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:27,代码来源:VM.java


示例3: isValidIp

import com.vmware.vim25.GuestNicInfo; //导入依赖的package包/类
boolean isValidIp(VMPropertyHandler configuration) {
    for (int i = 1; i <= configuration.getNumberOfNetworkAdapter(); i++) {
        GuestNicInfo info = getNicInfo(configuration, i);
        if (info == null) {
            return false;
        }

        if (configuration.isAdapterConfiguredManually(i)) {
            if (!containsIpAddress(info, configuration.getIpAddress(i))) {
                return false;
            }
        } else {
            if (!ipAddressExists(info)) {
                return false;
            }
        }
    }

    return true;
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:21,代码来源:VM.java


示例4: updatedGuestNics

import com.vmware.vim25.GuestNicInfo; //导入依赖的package包/类
public void updatedGuestNics(GuestNicInfo[] nics, VncDB vncDB)
        throws Exception {
    if (nics == null) {
        return;
    }

    for (GuestNicInfo nic: nics) {
        if (nic == null) {
            continue;
        }
        String mac = nic.getMacAddress();

        if (vmiInfoMap.containsKey(mac)) {
            VirtualMachineInterfaceInfo oldVmi = vmiInfoMap.get(mac);
            oldVmi.updatedGuestNic(nic, vncDB);
        }
    }
}
 
开发者ID:Juniper,项目名称:contrail-vcenter-plugin,代码行数:19,代码来源:VirtualMachineInfo.java


示例5: getVirtualMachineIpAddresses

import com.vmware.vim25.GuestNicInfo; //导入依赖的package包/类
/**
 * Searches for all ip addresses of a virtual machine
 *
 * @param virtualMachine the virtual machine to query
 * @return the ip addresses of the virtual machine, the first one is the primary
 * @throws RemoteException
 */
public TreeSet<String> getVirtualMachineIpAddresses(VirtualMachine virtualMachine) throws RemoteException {
    TreeSet<String> ipAddresses = new TreeSet<String>();

    // add the Ip address reported by VMware tools, this should be primary
    if (virtualMachine.getGuest().getIpAddress() != null)
        ipAddresses.add(virtualMachine.getGuest().getIpAddress());

    // if possible, iterate over all virtual networks networks and add interface Ip addresses
    if (virtualMachine.getGuest().getNet() != null) {
        for (GuestNicInfo guestNicInfo : virtualMachine.getGuest().getNet()) {
            if (guestNicInfo.getIpAddress() != null) {
                for (String ipAddress : guestNicInfo.getIpAddress()) {
                    ipAddresses.add(ipAddress);
                }
            }
        }
    }

    return ipAddresses;
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:28,代码来源:VmwareViJavaAccess.java


示例6: getNicInfo

import com.vmware.vim25.GuestNicInfo; //导入依赖的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


示例7: areNetworkCardsConnected

import com.vmware.vim25.GuestNicInfo; //导入依赖的package包/类
boolean areNetworkCardsConnected() {
    boolean isConnected = false;
    if (guestInfo.getNet() != null && !guestInfo.getNet().isEmpty()) {
        isConnected = true;
    }
    for (GuestNicInfo nicInfo : guestInfo.getNet()) {
        isConnected = isConnected && nicInfo.isConnected();
    }
    return isConnected;
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:11,代码来源:VM.java


示例8: getNicInfo

import com.vmware.vim25.GuestNicInfo; //导入依赖的package包/类
GuestNicInfo getNicInfo(VMPropertyHandler configuration, int i) {
    if (configuration.getNetworkAdapter(i) == null) {
        return null;
    }
    for (GuestNicInfo info : guestInfo.getNet()) {
        if (configuration.isAdapterConfiguredByDhcp(i)) {
            return info;
        }
        if (configuration.getNetworkAdapter(i).equals(info.getNetwork())) {
            return info;
        }
    }
    return null;
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:15,代码来源:VM.java


示例9: guestInfoContainsNic

import com.vmware.vim25.GuestNicInfo; //导入依赖的package包/类
boolean guestInfoContainsNic(String adapter) {
    for (GuestNicInfo info : guestInfo.getNet()) {
        if (info.getNetwork().equals(adapter)) {
            return true;
        }
    }

    return false;
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:10,代码来源:VM.java


示例10: ipAddressExists

import com.vmware.vim25.GuestNicInfo; //导入依赖的package包/类
boolean ipAddressExists(GuestNicInfo info) {
    if (info.getIpAddress().isEmpty()) {
        return false;
    }

    for (String ip : info.getIpAddress()) {
        if (ip == null || ip.trim().length() == 0) {
            return false;
        }
    }

    return true;
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:14,代码来源:VM.java


示例11: setup

import com.vmware.vim25.GuestNicInfo; //导入依赖的package包/类
@Before
public void setup() {
    ObjectContent cont = new ObjectContent();
    ManagedObjectReference ref = new ManagedObjectReference();
    ref.setType(VimNames.TYPE_VM);
    ref.setValue("vm-123");
    cont.setObj(ref);

    Map<String, Object> props = new HashMap<>();
    ArrayOfGuestNicInfo arrayOfGuestNicInfo = new ArrayOfGuestNicInfo();
    List<GuestNicInfo> listGuestNicInfo = arrayOfGuestNicInfo.getGuestNicInfo();
    GuestNicInfo nic1 = new GuestNicInfo();
    List<String> ipsNic1 = nic1.getIpAddress();
    String mac1Address = "00:50:56:8b:54:bd";
    String mac2Address = "98:87:fd:9e:ed:6d";
    nic1.setMacAddress(mac1Address);
    ipsNic1.add("192.168.1.10");
    ipsNic1.add("192.168.1.11");
    GuestNicInfo nic2 = new GuestNicInfo();
    List<String> ipsNic2 = nic2.getIpAddress();
    nic2.setMacAddress(mac2Address);
    ipsNic2.add("10.10.10.20");
    listGuestNicInfo.add(nic1);
    listGuestNicInfo.add(nic2);
    props.put(vm_guest_net, arrayOfGuestNicInfo);

    this.overlay = new VmOverlay(ref, props);
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:29,代码来源:VmOverlayTest.java


示例12: apply

import com.vmware.vim25.GuestNicInfo; //导入依赖的package包/类
@Override
public boolean apply(@Nullable VirtualMachine input) {
   if (input == null)
      return false;
   GuestNicInfo[] nics = input.getGuest().getNet();
   boolean nicConnected = false;
   if (null != nics) {
      for (GuestNicInfo nic : nics) {
         nicConnected = nicConnected || nic.connected;
      }
   }
   return nicConnected;
}
 
开发者ID:igreenfield,项目名称:jcloud-vsphere,代码行数:14,代码来源:VSpherePredicate.java


示例13: updatedGuestNic

import com.vmware.vim25.GuestNicInfo; //导入依赖的package包/类
public void updatedGuestNic(GuestNicInfo nic, VncDB vncDB)
            throws Exception {
    if (nic == null) {
        return;
    }
    NetIpConfigInfo ipConfig = nic.getIpConfig();
    if (ipConfig == null ) {
        return;
    }
    NetIpConfigInfoIpAddress[] ipAddrs = nic.getIpConfig().getIpAddress();
    if (ipAddrs == null || ipAddrs.length <= 0) {
        return;
    }
    String newIpAddress = ipAddrs[0].getIpAddress();
    if (newIpAddress != null && newIpAddress.equals(ipAddress)) {
        // IP address has not changed
        return;
    }

    s_logger.info("Updated guestNic Address " + " to " + newIpAddress + " for " + this);

     if (ipAddress != null) {
        vncDB.deleteInstanceIp(this);
    }

    deletePort();

    setIpAddress(newIpAddress);

    if (ipAddress != null || vnInfo.getExternalIpam() == false) {
        vncDB.createInstanceIp(this);
    }

    addPort();
}
 
开发者ID:Juniper,项目名称:contrail-vcenter-plugin,代码行数:36,代码来源:VirtualMachineInterfaceInfo.java


示例14: updateServiceParameter

import com.vmware.vim25.GuestNicInfo; //导入依赖的package包/类
public void updateServiceParameter(VMPropertyHandler paramHandler)
        throws Exception {
    LOG.debug("instanceName: " + instanceName);
    int key = getDataDiskKey();
    if (key != -1) {
        paramHandler.setDataDiskKey(1, key);
    }

    if (!paramHandler
            .isServiceSettingTrue(VMPropertyHandler.TS_IMPORT_EXISTING_VM)
            && !paramHandler.getInstanceName()
                    .equals(guestInfo.getHostName())) {
        throw new Exception(
                "Instancename and hostname do not match. Hostname: "
                        + guestInfo.getHostName() + "  Instancename: "
                        + paramHandler.getInstanceName());
    }

    String targetFolder = (String) vmw.getServiceUtil()
            .getDynamicProperty(folder, "name");

    Integer ramMB = (Integer) vmw.getServiceUtil()
            .getDynamicProperty(vmInstance, "summary.config.memorySizeMB");
    paramHandler.setSetting(VMPropertyHandler.TS_AMOUNT_OF_RAM,
            ramMB.toString());
    paramHandler.setSetting(VMPropertyHandler.TS_NUMBER_OF_CPU,
            Integer.toString(getNumCPU()));
    paramHandler.setSetting(VMPropertyHandler.TS_TARGET_FOLDER,
            targetFolder);

    paramHandler.setSetting(VMPropertyHandler.TS_DISK_SIZE,
            getDiskSizeInGB(1));

    paramHandler.setSetting(
            VMPropertyHandler.TS_DATA_DISK_SIZE.replace("#", "1"),
            getDiskSizeInGB(2));
    paramHandler.setSetting(VMPropertyHandler.TS_NUMBER_OF_NICS,
            Integer.toString(getNumberOfNICs()));

    int i = 1;
    List<GuestNicInfo> nicList = guestInfo.getNet();
    for (GuestNicInfo info : nicList) {
        if (info.getIpAddress() != null && info.getIpAddress().size() > 0) {
            paramHandler.setSetting("NIC" + i + "_IP_ADDRESS",
                    info.getIpAddress().get(0));
            if (info.getNetwork() != null) {
                paramHandler.setSetting("NIC" + i + "_NETWORK_ADAPTER",
                        info.getNetwork());
            }
            i++;
        }
    }
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:54,代码来源:VM.java


示例15: containsIpAddress

import com.vmware.vim25.GuestNicInfo; //导入依赖的package包/类
boolean containsIpAddress(GuestNicInfo info, String address) {
    return info.getIpAddress().contains(address);
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:4,代码来源:VM.java


示例16: getGuestInfo

import com.vmware.vim25.GuestNicInfo; //导入依赖的package包/类
/**
 * TODO: メソッドコメントを記述
 *
 * @param vmwareProcessClient
 * @param instanceNo
 */
public void getGuestInfo(VmwareProcessClient vmwareProcessClient, Long instanceNo) {
    Instance instance = instanceDao.read(instanceNo);
    VmwareInstance vmwareInstance = vmwareInstanceDao.read(instanceNo);
    List<VmwareNetwork> vmwareNetworks = vmwareNetworkDao.readByFarmNo(instance.getFarmNo());

    // ネットワーク名の取得
    Platform platform = platformDao.read(instance.getPlatformNo());
    PlatformVmware platformVmware = platformVmwareDao.read(instance.getPlatformNo());
    String publicNetworkName = platformVmware.getPublicNetwork();
    String privateNetworkName = platformVmware.getPrivateNetwork();
    for (VmwareNetwork vmwareNetwork : vmwareNetworks) {
        if (BooleanUtils.isTrue(vmwareNetwork.getPublicNetwork())) {
            publicNetworkName = vmwareNetwork.getNetworkName();
        } else {
            privateNetworkName = vmwareNetwork.getNetworkName();
        }
    }

    String publicIpAddress = null;
    String privateIpAddress = null;

    VirtualMachine machine = vmwareProcessClient.getVirtualMachine(vmwareInstance.getMachineName());
    for (GuestNicInfo nicInfo : machine.getGuest().getNet()) {
        // NIC情報からIPv4のアドレスを取得
        NetIpConfigInfoIpAddress[] tmpAddresses = nicInfo.getIpConfig().getIpAddress();
        if (tmpAddresses == null) {
            continue;
        }

        String ipAddress = null;
        for (NetIpConfigInfoIpAddress tmpAdress : tmpAddresses) {
            try {
                InetAddress inetAddress = InetAddress.getByName(tmpAdress.getIpAddress());
                if (inetAddress instanceof Inet4Address) {
                    ipAddress = tmpAdress.getIpAddress();
                    break;
                }
            } catch (UnknownHostException ignore) {
            }
        }

        // NIC情報がPublicかPrivateかの判定
        if (StringUtils.isNotEmpty(publicNetworkName) && publicNetworkName.equals(nicInfo.getNetwork())) {
            publicIpAddress = ipAddress;
        } else if (privateNetworkName.equals(nicInfo.getNetwork())) {
            privateIpAddress = ipAddress;
        }
    }

    if (StringUtils.isNotEmpty(publicNetworkName) && publicIpAddress == null) {
        // パブリックIPを取得できない場合
        throw new AutoException("EPROCESS-000510", vmwareInstance.getMachineName());
    } else if (privateIpAddress == null) {
        // プライベートIPを取得できない場合
        throw new AutoException("EPROCESS-000511", vmwareInstance.getMachineName());
    }

    // イベントログ出力
    processLogger.debug(null, instance, "VmwareInstanceStartFinish", new Object[] { platform.getPlatformName(),
            vmwareInstance.getMachineName() });

    // データベースに格納
    vmwareInstance = vmwareInstanceDao.read(instanceNo);
    vmwareInstance.setIpAddress(publicIpAddress);
    vmwareInstance.setPrivateIpAddress(privateIpAddress);
    vmwareInstanceDao.update(vmwareInstance);

    if (log.isInfoEnabled()) {
        log.info(MessageUtils.getMessage("IPROCESS-100432", vmwareInstance.getMachineName()));
    }
}
 
开发者ID:primecloud-controller-org,项目名称:primecloud-controller,代码行数:78,代码来源:VmwareMachineProcess.java


示例17: getVRouterVMIpFabricAddress

import com.vmware.vim25.GuestNicInfo; //导入依赖的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


示例18: getVirtualMachineIpAddress

import com.vmware.vim25.GuestNicInfo; //导入依赖的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.GuestNicInfo类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java MaskUtil类代码示例发布时间:2022-05-23
下一篇:
Java InterpolationBilinear类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap