From cc6bf7376003205b452e9e6d87d881854c146655 Mon Sep 17 00:00:00 2001 From: frank Date: Thu, 27 Oct 2011 17:42:25 -0700 Subject: [PATCH] allow multiple clusters for baremetal planner fix build --- .../com/cloud/deploy/BareMetalPlanner.java | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) 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); + } } } }