Search in sources :

Example 1 with DatacenterConfigInfo

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

the class HypervisorHostHelper method getNewVMHardwareVersion.

/**
 * Return the VM hardware version based on the information retrieved by the cluster and datacenter:
 * - If the cluster hardware version is set, then return this hardware version
 * - If the cluster hardware version is not set, check datacenter hardware version. If it is set, then return it
 * - In case both cluster and datacenter hardware version are not set, return null
 */
public static String getNewVMHardwareVersion(ClusterMO clusterMO, DatacenterMO datacenterMO) throws Exception {
    String version = null;
    ClusterConfigInfoEx clusterConfigInfo = clusterMO != null ? clusterMO.getClusterConfigInfo() : null;
    String clusterHardwareVersion = clusterConfigInfo != null ? clusterConfigInfo.getDefaultHardwareVersionKey() : null;
    if (StringUtils.isNotBlank(clusterHardwareVersion)) {
        s_logger.debug("Cluster hardware version found: " + clusterHardwareVersion + ". Creating VM with this hardware version");
        version = clusterHardwareVersion;
    } else {
        DatacenterConfigInfo datacenterConfigInfo = datacenterMO != null ? datacenterMO.getDatacenterConfigInfo() : null;
        String datacenterHardwareVersion = datacenterConfigInfo != null ? datacenterConfigInfo.getDefaultHardwareVersionKey() : null;
        if (StringUtils.isNotBlank(datacenterHardwareVersion)) {
            s_logger.debug("Datacenter hardware version found: " + datacenterHardwareVersion + ". Creating VM with this hardware version");
            version = datacenterHardwareVersion;
        }
    }
    return version;
}
Also used : ClusterConfigInfoEx(com.vmware.vim25.ClusterConfigInfoEx) DatacenterConfigInfo(com.vmware.vim25.DatacenterConfigInfo)

Aggregations

ClusterConfigInfoEx (com.vmware.vim25.ClusterConfigInfoEx)1 DatacenterConfigInfo (com.vmware.vim25.DatacenterConfigInfo)1