Java源码示例:com.vmware.vim25.GuestInfo

示例1
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();
}
 
示例2
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);
    }
}
 
示例3
/**
 * 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;
}
 
示例4
GuestNicInfo getNicInfo(GuestInfo guestInfo, String adapter) {
    for (GuestNicInfo info : guestInfo.getNet()) {
        if (info != null && adapter.equals(info.getNetwork())) {
            return info;
        }
    }
    return null;
}
 
示例5
public boolean isVMwareToolsRunning() throws Exception {
    GuestInfo guestInfo = getVmGuestInfo();
    if (guestInfo != null) {
        if ("guestToolsRunning".equalsIgnoreCase(guestInfo.getToolsRunningStatus()))
            return true;
    }
    return false;
}
 
示例6
public GuestInfo getVmGuestInfo() throws Exception {
    return (GuestInfo)getContext().getVimClient().getDynamicProperty(_mor, "guest");
}
 
示例7
public GuestInfo getGuestInfo() throws Exception {
    return (GuestInfo)_context.getVimClient().getDynamicProperty(_mor, "guest");
}