本文整理汇总了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;
}
示例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;
}
示例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;
}