diff --git a/server/src/com/cloud/deploy/BareMetalPlanner.java b/server/src/com/cloud/deploy/BareMetalPlanner.java index 4b2f9c1965a..55cf74224a6 100755 --- a/server/src/com/cloud/deploy/BareMetalPlanner.java +++ b/server/src/com/cloud/deploy/BareMetalPlanner.java @@ -114,13 +114,19 @@ public class BareMetalPlanner implements DeploymentPlanner { ram_requested = target.getTotalMemory(); } - for (HostVO h : hosts) { - if (h.getStatus() == Status.Up) { - if(_capacityMgr.checkIfHostHasCapacity(h.getId(), cpu_requested, ram_requested, false, cpuOverprovisioningFactor)){ - s_logger.debug("Find host " + h.getId() + " has enough capacity"); - DataCenter dc = _dcDao.findById(h.getDataCenterId()); - Pod pod = _podDao.findById(h.getPodId()); - return new DeployDestination(dc, pod, cluster, h); + for (ClusterVO cluster : clusters) { + List hosts = _hostDao.listByCluster(cluster.getId()); + for (HostVO h : hosts) { + if (h.getStatus() == Status.Up) { + if (_capacityMgr.checkIfHostHasCapacity(h.getId(), + cpu_requested, ram_requested, false, + cpuOverprovisioningFactor)) { + s_logger.debug("Find host " + h.getId() + + " has enough capacity"); + DataCenter dc = _dcDao.findById(h.getDataCenterId()); + Pod pod = _podDao.findById(h.getPodId()); + return new DeployDestination(dc, pod, cluster, h); + } } } }