mirror of https://github.com/apache/cloudstack.git
CLOUDSTACK-9198: Donot allow VMs to be deplyed on host that are in disabled pod
This commit is contained in:
parent
2132107be5
commit
a86f672bc6
|
|
@ -314,12 +314,22 @@ StateListener<State, VirtualMachine.Event, VirtualMachine> {
|
|||
s_logger.debug("The specified host is in avoid set");
|
||||
} else {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Looking for suitable pools for this host under zone: " + host.getDataCenterId() + ", pod: " + host.getPodId() + ", cluster: " +
|
||||
host.getClusterId());
|
||||
s_logger.debug(
|
||||
"Looking for suitable pools for this host under zone: " + host.getDataCenterId() + ", pod: " + host.getPodId() + ", cluster: " + host.getClusterId());
|
||||
}
|
||||
|
||||
Pod pod = _podDao.findById(host.getPodId());
|
||||
// check if the cluster or the pod is disabled
|
||||
if (pod.getAllocationState() != Grouping.AllocationState.Enabled) {
|
||||
s_logger.warn("The Pod containing this host is in disabled state, PodId= " + pod.getId());
|
||||
return null;
|
||||
}
|
||||
|
||||
Cluster cluster = _clusterDao.findById(host.getClusterId());
|
||||
if (cluster.getAllocationState() != Grouping.AllocationState.Enabled) {
|
||||
s_logger.warn("The Cluster containing this host is in disabled state, PodId= " + cluster.getId());
|
||||
return null;
|
||||
}
|
||||
|
||||
if (vm.getHypervisorType() == HypervisorType.BareMetal) {
|
||||
DeployDestination dest = new DeployDestination(dc, pod, cluster, host, new HashMap<Volume, StoragePool>());
|
||||
|
|
@ -923,47 +933,49 @@ StateListener<State, VirtualMachine.Event, VirtualMachine> {
|
|||
DataCenterDeployment potentialPlan =
|
||||
new DataCenterDeployment(plan.getDataCenterId(), clusterVO.getPodId(), clusterVO.getId(), null, plan.getPoolId(), null, plan.getReservationContext());
|
||||
|
||||
// find suitable hosts under this cluster, need as many hosts as we
|
||||
// get.
|
||||
List<Host> suitableHosts = findSuitableHosts(vmProfile, potentialPlan, avoid, HostAllocator.RETURN_UPTO_ALL);
|
||||
// if found suitable hosts in this cluster, find suitable storage
|
||||
// pools for each volume of the VM
|
||||
if (suitableHosts != null && !suitableHosts.isEmpty()) {
|
||||
if (vmProfile.getHypervisorType() == HypervisorType.BareMetal) {
|
||||
Pod pod = _podDao.findById(clusterVO.getPodId());
|
||||
DeployDestination dest = new DeployDestination(dc, pod, clusterVO, suitableHosts.get(0));
|
||||
return dest;
|
||||
}
|
||||
|
||||
Pair<Map<Volume, List<StoragePool>>, List<Volume>> result =
|
||||
findSuitablePoolsForVolumes(vmProfile, potentialPlan, avoid, StoragePoolAllocator.RETURN_UPTO_ALL);
|
||||
Map<Volume, List<StoragePool>> suitableVolumeStoragePools = result.first();
|
||||
List<Volume> readyAndReusedVolumes = result.second();
|
||||
|
||||
// choose the potential host and pool for the VM
|
||||
if (!suitableVolumeStoragePools.isEmpty()) {
|
||||
Pair<Host, Map<Volume, StoragePool>> potentialResources = findPotentialDeploymentResources(
|
||||
suitableHosts, suitableVolumeStoragePools, avoid, resourceUsageRequired,
|
||||
readyAndReusedVolumes);
|
||||
|
||||
if (potentialResources != null) {
|
||||
Pod pod = _podDao.findById(clusterVO.getPodId());
|
||||
Host host = _hostDao.findById(potentialResources.first().getId());
|
||||
Map<Volume, StoragePool> storageVolMap = potentialResources.second();
|
||||
// remove the reused vol<->pool from destination, since
|
||||
// we don't have to prepare this volume.
|
||||
for (Volume vol : readyAndReusedVolumes) {
|
||||
storageVolMap.remove(vol);
|
||||
}
|
||||
DeployDestination dest = new DeployDestination(dc, pod, clusterVO, host, storageVolMap);
|
||||
s_logger.debug("Returning Deployment Destination: " + dest);
|
||||
Pod pod = _podDao.findById(clusterVO.getPodId());
|
||||
if (pod.getAllocationState() == Grouping.AllocationState.Enabled ) {
|
||||
// find suitable hosts under this cluster, need as many hosts as we
|
||||
// get.
|
||||
List<Host> suitableHosts = findSuitableHosts(vmProfile, potentialPlan, avoid, HostAllocator.RETURN_UPTO_ALL);
|
||||
// if found suitable hosts in this cluster, find suitable storage
|
||||
// pools for each volume of the VM
|
||||
if (suitableHosts != null && !suitableHosts.isEmpty()) {
|
||||
if (vmProfile.getHypervisorType() == HypervisorType.BareMetal) {
|
||||
DeployDestination dest = new DeployDestination(dc, pod, clusterVO, suitableHosts.get(0));
|
||||
return dest;
|
||||
}
|
||||
|
||||
Pair<Map<Volume, List<StoragePool>>, List<Volume>> result = findSuitablePoolsForVolumes(vmProfile, potentialPlan, avoid, StoragePoolAllocator.RETURN_UPTO_ALL);
|
||||
Map<Volume, List<StoragePool>> suitableVolumeStoragePools = result.first();
|
||||
List<Volume> readyAndReusedVolumes = result.second();
|
||||
|
||||
// choose the potential host and pool for the VM
|
||||
if (!suitableVolumeStoragePools.isEmpty()) {
|
||||
Pair<Host, Map<Volume, StoragePool>> potentialResources = findPotentialDeploymentResources(suitableHosts, suitableVolumeStoragePools, avoid,
|
||||
resourceUsageRequired, readyAndReusedVolumes);
|
||||
|
||||
if (potentialResources != null) {
|
||||
Host host = _hostDao.findById(potentialResources.first().getId());
|
||||
Map<Volume, StoragePool> storageVolMap = potentialResources.second();
|
||||
// remove the reused vol<->pool from destination, since
|
||||
// we don't have to prepare this volume.
|
||||
for (Volume vol : readyAndReusedVolumes) {
|
||||
storageVolMap.remove(vol);
|
||||
}
|
||||
DeployDestination dest = new DeployDestination(dc, pod, clusterVO, host, storageVolMap);
|
||||
s_logger.debug("Returning Deployment Destination: " + dest);
|
||||
return dest;
|
||||
}
|
||||
} else {
|
||||
s_logger.debug("No suitable storagePools found under this Cluster: " + clusterId);
|
||||
}
|
||||
} else {
|
||||
s_logger.debug("No suitable storagePools found under this Cluster: " + clusterId);
|
||||
s_logger.debug("No suitable hosts found under this Cluster: " + clusterId);
|
||||
}
|
||||
} else {
|
||||
s_logger.debug("No suitable hosts found under this Cluster: " + clusterId);
|
||||
}
|
||||
else {
|
||||
s_logger.debug("The cluster is in a disabled pod : " + pod.getId());
|
||||
}
|
||||
|
||||
if (canAvoidCluster(clusterVO, avoid, plannerAvoidOutput, vmProfile)) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue