Skip to content

Commit eb0fdc2

Browse files
author
frank
committed
allow multiple clusters for baremetal planner
fix build
1 parent c81477a commit eb0fdc2

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

server/src/com/cloud/deploy/BareMetalPlanner.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import com.cloud.dc.dao.DataCenterDao;
3737
import com.cloud.dc.dao.HostPodDao;
3838
import com.cloud.exception.InsufficientServerCapacityException;
39+
import com.cloud.host.Host;
3940
import com.cloud.host.HostVO;
4041
import com.cloud.host.Status;
4142
import com.cloud.host.dao.HostDao;
@@ -87,18 +88,17 @@ public DeployDestination plan(VirtualMachineProfile<? extends VirtualMachine> vm
8788
}
8889
}
8990

90-
List<ClusterVO> clusters = _clusterDao.listByDcHyType(vm.getDataCenterIdToDeployIn(), HypervisorType.BareMetal.toString());
91+
List<ClusterVO> clusters = _clusterDao.listByDcHyType(vm.getDataCenterIdToDeployIn(), HypervisorType.BareMetal.toString());
9192
int cpu_requested;
9293
long ram_requested;
9394
HostVO target = null;
94-
List<HostVO> hosts;
95+
List<HostVO> hosts;
9596
for (ClusterVO cluster : clusters) {
96-
hosts = _resourceMgr.listAllHostsInCluster(cluster.getId());
97+
hosts = _resourceMgr.listAllUpAndEnabledHosts(Host.Type.Routing, cluster.getId(), cluster.getPodId(), cluster.getDataCenterId());
9798
if (hostTag != null) {
9899
for (HostVO h : hosts) {
99100
_hostDao.loadDetails(h);
100-
if (h.getDetail("hostTag") != null
101-
&& h.getDetail("hostTag").equalsIgnoreCase(hostTag)) {
101+
if (h.getDetail("hostTag") != null && h.getDetail("hostTag").equalsIgnoreCase(hostTag)) {
102102
target = h;
103103
break;
104104
}
@@ -115,17 +115,18 @@ public DeployDestination plan(VirtualMachineProfile<? extends VirtualMachine> vm
115115
ram_requested = target.getTotalMemory();
116116
}
117117

118-
for (HostVO h : hosts) {
119-
if (h.getStatus() == Status.Up) {
120-
if(_capacityMgr.checkIfHostHasCapacity(h.getId(), cpu_requested, ram_requested, false, cpuOverprovisioningFactor, true)){
118+
for (ClusterVO cluster : clusters) {
119+
hosts = _resourceMgr.listAllUpAndEnabledHosts(Host.Type.Routing, cluster.getId(), cluster.getPodId(), cluster.getDataCenterId());
120+
for (HostVO h : hosts) {
121+
if (_capacityMgr.checkIfHostHasCapacity(h.getId(), cpu_requested, ram_requested, false, cpuOverprovisioningFactor, true)) {
121122
s_logger.debug("Find host " + h.getId() + " has enough capacity");
122123
DataCenter dc = _dcDao.findById(h.getDataCenterId());
123124
Pod pod = _podDao.findById(h.getPodId());
124125
return new DeployDestination(dc, pod, cluster, h);
125126
}
126127
}
127128
}
128-
129+
129130
s_logger.warn(String.format("Cannot find enough capacity(requested cpu=%1$s memory=%2$s)", cpu_requested, ram_requested));
130131
return null;
131132
}

0 commit comments

Comments
 (0)