mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
server: check server capacity when start/deploy a vm (#5339)
This commit is contained in:
parent
2297c73c92
commit
cf6dc663de
@ -4853,9 +4853,19 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
|
||||
boolean deployOnGivenHost = false;
|
||||
if (destinationHost != null) {
|
||||
s_logger.debug("Destination Host to deploy the VM is specified, specifying a deployment plan to deploy the VM");
|
||||
plan = new DataCenterDeployment(vm.getDataCenterId(), destinationHost.getPodId(), destinationHost.getClusterId(), destinationHost.getId(), null, null);
|
||||
if (!AllowDeployVmIfGivenHostFails.value()) {
|
||||
deployOnGivenHost = true;
|
||||
final ServiceOfferingVO offering = _offeringDao.findById(vm.getId(), vm.getServiceOfferingId());
|
||||
Pair<Boolean, Boolean> cpuCapabilityAndCapacity = _capacityMgr.checkIfHostHasCpuCapabilityAndCapacity(destinationHost, offering, false);
|
||||
if (!cpuCapabilityAndCapacity.first() || !cpuCapabilityAndCapacity.second()) {
|
||||
String errorMsg = "Cannot deploy the VM to specified host " + hostId + "; host has cpu capability? " + cpuCapabilityAndCapacity.first() + ", host has capacity? " + cpuCapabilityAndCapacity.second();
|
||||
s_logger.info(errorMsg);
|
||||
if (!AllowDeployVmIfGivenHostFails.value()) {
|
||||
throw new InvalidParameterValueException(errorMsg);
|
||||
};
|
||||
} else {
|
||||
plan = new DataCenterDeployment(vm.getDataCenterId(), destinationHost.getPodId(), destinationHost.getClusterId(), destinationHost.getId(), null, null);
|
||||
if (!AllowDeployVmIfGivenHostFails.value()) {
|
||||
deployOnGivenHost = true;
|
||||
}
|
||||
}
|
||||
} else if (destinationCluster != null) {
|
||||
s_logger.debug("Destination Cluster to deploy the VM is specified, specifying a deployment plan to deploy the VM");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user