Skip to content

Commit 166ea33

Browse files
committed
server: use method checkIfHostHasCpuCapabilityAndCapacity
1 parent 8adac6c commit 166ea33

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

server/src/main/java/com/cloud/vm/UserVmManagerImpl.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4935,17 +4935,19 @@ public Pair<UserVmVO, Map<VirtualMachineProfile.Param, Object>> startVirtualMach
49354935
boolean deployOnGivenHost = false;
49364936
if (destinationHost != null) {
49374937
s_logger.debug("Destination Host to deploy the VM is specified, specifying a deployment plan to deploy the VM");
4938-
try {
4939-
checkVmDestinationServerCapacity(vm, destinationHost);
4938+
final ServiceOfferingVO offering = _offeringDao.findById(vm.getId(), vm.getServiceOfferingId());
4939+
Pair<Boolean, Boolean> cpuCapabilityAndCapacity = _capacityMgr.checkIfHostHasCpuCapabilityAndCapacity(destinationHost, offering, false);
4940+
if (!cpuCapabilityAndCapacity.first() || !cpuCapabilityAndCapacity.second()) {
4941+
String errorMsg = "Cannot deploy the VM to specified host " + hostId + "; host has cpu capability? " + cpuCapabilityAndCapacity.first() + ", host has capacity? " + cpuCapabilityAndCapacity.second();
4942+
s_logger.info(errorMsg);
4943+
if (!AllowDeployVmIfGivenHostFails.value()) {
4944+
throw new InvalidParameterValueException(errorMsg);
4945+
};
4946+
} else {
49404947
plan = new DataCenterDeployment(vm.getDataCenterId(), destinationHost.getPodId(), destinationHost.getClusterId(), destinationHost.getId(), null, null);
49414948
if (!AllowDeployVmIfGivenHostFails.value()) {
49424949
deployOnGivenHost = true;
49434950
}
4944-
} catch (InvalidParameterValueException ex) {
4945-
s_logger.error("Cannot deploy the VM to specified host due to: " + ex.getMessage());
4946-
if (!AllowDeployVmIfGivenHostFails.value()) {
4947-
throw ex;
4948-
}
49494951
}
49504952
} else if (destinationCluster != null) {
49514953
s_logger.debug("Destination Cluster to deploy the VM is specified, specifying a deployment plan to deploy the VM");

0 commit comments

Comments
 (0)