You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by nv...@apache.org on 2021/09/03 00:45:23 UTC
[cloudstack] branch 4.15 updated: server: check server capacity
when start/deploy a vm (#5339)
This is an automated email from the ASF dual-hosted git repository.
nvazquez pushed a commit to branch 4.15
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/4.15 by this push:
new cf6dc66 server: check server capacity when start/deploy a vm (#5339)
cf6dc66 is described below
commit cf6dc663de1a6881e8336dc28c975efc96698158
Author: Wei Zhou <we...@apache.org>
AuthorDate: Fri Sep 3 02:45:00 2021 +0200
server: check server capacity when start/deploy a vm (#5339)
---
server/src/main/java/com/cloud/vm/UserVmManagerImpl.java | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/server/src/main/java/com/cloud/vm/UserVmManagerImpl.java b/server/src/main/java/com/cloud/vm/UserVmManagerImpl.java
index af28648..17832bb 100644
--- a/server/src/main/java/com/cloud/vm/UserVmManagerImpl.java
+++ b/server/src/main/java/com/cloud/vm/UserVmManagerImpl.java
@@ -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");