Skip to content

Commit e169550

Browse files
gp-santosSadiJr
authored andcommitted
Validação de último _host_ de VM em manutenção
1 parent f15a24a commit e169550

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

server/src/main/java/com/cloud/deploy/DeploymentPlanningManagerImpl.java

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737

3838
import com.cloud.api.ApiDBUtils;
3939
import com.cloud.cpu.CPU;
40+
import com.cloud.resource.ResourceState;
4041
import com.cloud.vm.UserVmManager;
4142
import org.apache.cloudstack.affinity.AffinityGroupDomainMapVO;
4243
import com.cloud.storage.VMTemplateVO;
@@ -487,11 +488,6 @@ private DeployDestination deployInVmLastHost(VirtualMachineProfile vmProfile, De
487488
if (canUseLastHost(host, avoids, plan, vm, offering, volumesRequireEncryption)) {
488489
_hostDao.loadHostTags(host);
489490
_hostDao.loadDetails(host);
490-
if (host.getStatus() != Status.Up) {
491-
logger.debug("Cannot deploy VM [{}] to the last host [{}] because this host is not in UP state or is not enabled. Host current status [{}] and resource status [{}].",
492-
vm.getUuid(), host.getUuid(), host.getState().name(), host.getResourceState());
493-
return null;
494-
}
495491
if (checkVmProfileAndHost(vmProfile, host)) {
496492
long cluster_id = host.getClusterId();
497493
ClusterDetailsVO cluster_detail_cpu = _clusterDetailsDao.findDetail(cluster_id, "cpuOvercommitRatio");
@@ -573,6 +569,16 @@ private boolean canUseLastHost(HostVO host, ExcludeList avoids, DeploymentPlan p
573569
return false;
574570
}
575571

572+
if (host.getStatus() != Status.Up) {
573+
logger.debug("Cannot deploy VM [{}] to the last host [{}] because this host is not Up: [{}].", vm.getUuid(), host.getUuid(), host.getState().name());
574+
return false;
575+
}
576+
577+
if (host.getResourceState() != ResourceState.Enabled) {
578+
logger.debug("Cannot deploy VM [{}] to the last host [{}] because this host is not Enabled: [{}].", vm.getUuid(), host.getUuid(), host.getResourceState());
579+
return false;
580+
}
581+
576582
if (avoids.shouldAvoid(host)) {
577583
logger.warn("The last host [{}] of VM [{}] is in the avoid set. Skipping this and trying other available hosts.", host.getUuid(), vm.getUuid());
578584
return false;

0 commit comments

Comments
 (0)