|
37 | 37 |
|
38 | 38 | import com.cloud.api.ApiDBUtils; |
39 | 39 | import com.cloud.cpu.CPU; |
| 40 | +import com.cloud.resource.ResourceState; |
40 | 41 | import com.cloud.vm.UserVmManager; |
41 | 42 | import org.apache.cloudstack.affinity.AffinityGroupDomainMapVO; |
42 | 43 | import com.cloud.storage.VMTemplateVO; |
@@ -487,11 +488,6 @@ private DeployDestination deployInVmLastHost(VirtualMachineProfile vmProfile, De |
487 | 488 | if (canUseLastHost(host, avoids, plan, vm, offering, volumesRequireEncryption)) { |
488 | 489 | _hostDao.loadHostTags(host); |
489 | 490 | _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 | | - } |
495 | 491 | if (checkVmProfileAndHost(vmProfile, host)) { |
496 | 492 | long cluster_id = host.getClusterId(); |
497 | 493 | ClusterDetailsVO cluster_detail_cpu = _clusterDetailsDao.findDetail(cluster_id, "cpuOvercommitRatio"); |
@@ -573,6 +569,16 @@ private boolean canUseLastHost(HostVO host, ExcludeList avoids, DeploymentPlan p |
573 | 569 | return false; |
574 | 570 | } |
575 | 571 |
|
| 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 | + |
576 | 582 | if (avoids.shouldAvoid(host)) { |
577 | 583 | logger.warn("The last host [{}] of VM [{}] is in the avoid set. Skipping this and trying other available hosts.", host.getUuid(), vm.getUuid()); |
578 | 584 | return false; |
|
0 commit comments