本文整理汇总了Java中com.vmware.vim25.GuestInfo类的典型用法代码示例。如果您正苦于以下问题:Java GuestInfo类的具体用法?Java GuestInfo怎么用?Java GuestInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GuestInfo类属于com.vmware.vim25包,在下文中一共展示了GuestInfo类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getIpAddress
import com.vmware.vim25.GuestInfo; //导入依赖的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: VM
import com.vmware.vim25.GuestInfo; //导入依赖的package包/类
public VM(VMwareClient vmw, String instanceName) throws Exception {
this.vmw = vmw;
this.instanceName = instanceName;
vmInstance = vmw.getServiceUtil().getDecendentMoRef(null,
"VirtualMachine", instanceName);
configSpec = (VirtualMachineConfigInfo) vmw.getServiceUtil()
.getDynamicProperty(vmInstance, "config");
folder = (ManagedObjectReference) vmw.getServiceUtil()
.getDynamicProperty(vmInstance, "parent");
guestInfo = (GuestInfo) vmw.getServiceUtil()
.getDynamicProperty(vmInstance, "guest");
if (vmInstance == null || configSpec == null || folder == null
|| guestInfo == null) {
LOG.warn("failed to retrieve VM");
throw new Exception(
"Failed to retrieve information of VM " + instanceName);
}
}
开发者ID:servicecatalog,项目名称:oscm,代码行数:21,代码来源:VM.java
示例3: generateAccessInfo
import com.vmware.vim25.GuestInfo; //导入依赖的package包/类
/**
* Returns the generated access info for the given VM.
*/
public String generateAccessInfo(GuestInfo guestInfo)
throws APPlatformException {
String myHOST = guestInfo.getHostName();
String hostName;
if (myHOST != null) {
hostName = guestInfo.getHostName().split("\\.", 2)[0];
} else {
hostName = "Unkown hostname (probably missing vmware tools).\nInstance name "
+ paramHandler.getInstanceName() + ".";
myHOST = "Unkown(InstanceName " + paramHandler.getInstanceName()
+ ")";
}
String accessInfoPattern = paramHandler.getAccessInfo();
if (accessInfoPatternUndefined(accessInfoPattern)) {
return hostName;
}
String accessInfo = accessInfoPattern.replace(PATTERN_IP,
getIpAddress(guestInfo));
accessInfo = accessInfo.replace(PATTERN_HOST, myHOST);
accessInfo = accessInfo.replace(PATTERN_CPU,
Integer.toString(paramHandler.getConfigCPUs()));
accessInfo = accessInfo.replace(PATTERN_MEM,
paramHandler.formatMBasGB(paramHandler.getConfigMemoryMB()));
accessInfo = accessInfo.replace(PATTERN_DISKS,
paramHandler.getDataDisksAsString());
accessInfo = accessInfo.replace(PATTERN_RESPUSER, getResponsibleUser());
accessInfo = accessInfo.replace("<br>", "<br>\r\n");
return accessInfo;
}
开发者ID:servicecatalog,项目名称:oscm,代码行数:36,代码来源:VMwareAccessInfo.java
示例4: 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
示例5: applyTest
import com.vmware.vim25.GuestInfo; //导入依赖的package包/类
@Test
public void applyTest() {
VirtualMachineToSshClient virtualMachineToSshClient = new VirtualMachineToSshClient(new StubSshClientModule.Factory());
VirtualMachine vm = PowerMock.createMock(VirtualMachine.class);
GuestInfo guest = PowerMock.createMock(GuestInfo.class);
expect(vm.getGuest()).andReturn(guest).anyTimes();
expect(guest.getIpAddress()).andReturn("10.10.0.2").anyTimes();
expect(guest.getToolsStatus()).andReturn(VirtualMachineToolsStatus.toolsOk).anyTimes();
replay(vm, guest);
SshClient sshClient = virtualMachineToSshClient.apply(vm);
Assert.assertNotNull(sshClient);
}
开发者ID:igreenfield,项目名称:jcloud-vsphere,代码行数:15,代码来源:VirtualMachineToSshClientTest.java
示例6: isVMwareToolsRunning
import com.vmware.vim25.GuestInfo; //导入依赖的package包/类
public boolean isVMwareToolsRunning() throws Exception {
GuestInfo guestInfo = getVmGuestInfo();
if (guestInfo != null) {
if ("guestToolsRunning".equalsIgnoreCase(guestInfo.getToolsRunningStatus()))
return true;
}
return false;
}
开发者ID:apache,项目名称:cloudstack,代码行数:9,代码来源:VirtualMachineMO.java
示例7: 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
示例8: 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
示例9: getVmGuestInfo
import com.vmware.vim25.GuestInfo; //导入依赖的package包/类
public GuestInfo getVmGuestInfo() throws Exception {
return (GuestInfo)getContext().getVimClient().getDynamicProperty(_mor, "guest");
}
开发者ID:apache,项目名称:cloudstack,代码行数:4,代码来源:VirtualMachineMO.java
示例10: getGuestInfo
import com.vmware.vim25.GuestInfo; //导入依赖的package包/类
public GuestInfo getGuestInfo() throws Exception {
return (GuestInfo)_context.getVimClient().getDynamicProperty(_mor, "guest");
}
开发者ID:apache,项目名称:cloudstack,代码行数:4,代码来源:VirtualMachineMO.java
示例11: execute
import com.vmware.vim25.GuestInfo; //导入依赖的package包/类
protected Answer execute(GetVmIpAddressCommand cmd) {
if (s_logger.isTraceEnabled()) {
s_logger.trace("Executing resource command GetVmIpAddressCommand: " + _gson.toJson(cmd));
}
String details = "Unable to find IP Address of VM. ";
String vmName = cmd.getVmName();
boolean result = false;
String ip = null;
Answer answer = null;
VmwareContext context = getServiceContext();
VmwareHypervisorHost hyperHost = getHyperHost(context);
if (vmName == null || vmName.isEmpty()) {
details += "Name of instance provided is NULL or empty.";
return new Answer(cmd, result, details);
}
try {
VirtualMachineMO vmMo = hyperHost.findVmOnHyperHost(vmName);
if (vmMo != null) {
GuestInfo guestInfo = vmMo.getGuestInfo();
VirtualMachineToolsStatus toolsStatus = guestInfo.getToolsStatus();
if (toolsStatus == VirtualMachineToolsStatus.TOOLS_NOT_INSTALLED) {
details += "Vmware tools not installed.";
} else {
ip = guestInfo.getIpAddress();
if (ip != null) {
result = true;
}
details = ip;
}
} else {
details += "VM " + vmName + " no longer exists on vSphere host: " + hyperHost.getHyperHostName();
s_logger.info(details);
}
} catch (Throwable e) {
if (e instanceof RemoteException) {
s_logger.warn("Encounter remote exception to vCenter, invalidate VMware session context");
invalidateServiceContext();
}
details += "Encountered exception : " + VmwareHelper.getExceptionMessage(e);
s_logger.error(details);
}
answer = new Answer(cmd, result, details);
if (s_logger.isTraceEnabled()) {
s_logger.trace("Returning GetVmIpAddressAnswer: " + _gson.toJson(answer));
}
return answer;
}
开发者ID:apache,项目名称:cloudstack,代码行数:53,代码来源:VmwareResource.java
注:本文中的com.vmware.vim25.GuestInfo类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论