use of com.vmware.vim25.DasVmPriority in project cloudstack by apache.
the class ClusterMO method getRestartPriorityForVM.
private String getRestartPriorityForVM(VirtualMachineMO vmMo) throws Exception {
if (vmMo == null) {
s_logger.debug("Failed to get restart priority for VM, invalid VM object reference");
return null;
}
ManagedObjectReference vmMor = vmMo.getMor();
if (vmMor == null || !vmMor.getType().equals("VirtualMachine")) {
s_logger.debug("Failed to get restart priority for VM: " + vmMo.getName() + ", invalid VM object reference");
return null;
}
ClusterConfigInfoEx configInfo = getClusterConfigInfo();
if (configInfo == null) {
s_logger.debug("Failed to get restart priority for VM: " + vmMo.getName() + ", no cluster config information");
return null;
}
List<ClusterDasVmConfigInfo> dasVmConfig = configInfo.getDasVmConfig();
for (int dasVmConfigIndex = 0; dasVmConfigIndex < dasVmConfig.size(); dasVmConfigIndex++) {
ClusterDasVmConfigInfo dasVmConfigInfo = dasVmConfig.get(dasVmConfigIndex);
if (dasVmConfigInfo != null && dasVmConfigInfo.getKey().getValue().equals(vmMor.getValue())) {
DasVmPriority dasVmPriority = dasVmConfigInfo.getRestartPriority();
if (dasVmPriority != null) {
return dasVmPriority.value();
} else {
//VM uses cluster restart priority when DasVmPriority for the VM is null.
return ClusterDasVmSettingsRestartPriority.CLUSTER_RESTART_PRIORITY.value();
}
}
}
s_logger.debug("VM: " + vmMo.getName() + " uses default restart priority in the cluster: " + getName());
return null;
}
Aggregations