Search in sources :

Example 1 with HostCapability

use of com.vmware.vim25.HostCapability in project cloudstack by apache.

the class VmwareResource method configNestedHVSupport.

protected void configNestedHVSupport(VirtualMachineMO vmMo, VirtualMachineTO vmSpec, VirtualMachineConfigSpec vmConfigSpec) throws Exception {
    VmwareContext context = vmMo.getContext();
    if ("true".equals(vmSpec.getDetails().get(VmDetailConstants.NESTED_VIRTUALIZATION_FLAG))) {
        if (s_logger.isDebugEnabled())
            s_logger.debug("Nested Virtualization enabled in configuration, checking hypervisor capability");
        ManagedObjectReference hostMor = vmMo.getRunningHost().getMor();
        ManagedObjectReference computeMor = context.getVimClient().getMoRefProp(hostMor, "parent");
        ManagedObjectReference environmentBrowser = context.getVimClient().getMoRefProp(computeMor, "environmentBrowser");
        HostCapability hostCapability = context.getService().queryTargetCapabilities(environmentBrowser, hostMor);
        Boolean nestedHvSupported = hostCapability.isNestedHVSupported();
        if (nestedHvSupported == null) {
            // nestedHvEnabled property is supported only since VMware 5.1. It's not defined for earlier versions.
            s_logger.warn("Hypervisor doesn't support nested virtualization, unable to set config for VM " + vmSpec.getName());
        } else if (nestedHvSupported.booleanValue()) {
            s_logger.debug("Hypervisor supports nested virtualization, enabling for VM " + vmSpec.getName());
            vmConfigSpec.setNestedHVEnabled(true);
        } else {
            s_logger.warn("Hypervisor doesn't support nested virtualization, unable to set config for VM " + vmSpec.getName());
            vmConfigSpec.setNestedHVEnabled(false);
        }
    }
}
Also used : VmwareContext(com.cloud.hypervisor.vmware.util.VmwareContext) HostCapability(com.vmware.vim25.HostCapability) ManagedObjectReference(com.vmware.vim25.ManagedObjectReference)

Aggregations

VmwareContext (com.cloud.hypervisor.vmware.util.VmwareContext)1 HostCapability (com.vmware.vim25.HostCapability)1 ManagedObjectReference (com.vmware.vim25.ManagedObjectReference)1