|
23 | 23 | import javax.inject.Inject; |
24 | 24 | import javax.naming.ConfigurationException; |
25 | 25 |
|
| 26 | +import com.cloud.dc.*; |
| 27 | +import com.cloud.dc.ClusterDetailsDao; |
26 | 28 | import org.apache.log4j.Logger; |
27 | 29 |
|
28 | 30 | import com.cloud.capacity.CapacityManager; |
29 | 31 | import com.cloud.configuration.Config; |
30 | 32 | import com.cloud.configuration.dao.ConfigurationDao; |
31 | | -import com.cloud.dc.ClusterVO; |
32 | | -import com.cloud.dc.DataCenter; |
33 | | -import com.cloud.dc.Pod; |
34 | 33 | import com.cloud.dc.dao.ClusterDao; |
35 | 34 | import com.cloud.dc.dao.DataCenterDao; |
36 | 35 | import com.cloud.dc.dao.HostPodDao; |
@@ -61,16 +60,14 @@ public class BareMetalPlanner extends AdapterBase implements DeploymentPlanner { |
61 | 60 | @Inject protected ConfigurationDao _configDao; |
62 | 61 | @Inject protected CapacityManager _capacityMgr; |
63 | 62 | @Inject protected ResourceManager _resourceMgr; |
| 63 | + @Inject protected ClusterDetailsDao _clusterDetailsDao; |
64 | 64 |
|
65 | 65 | @Override |
66 | 66 | public DeployDestination plan(VirtualMachineProfile<? extends VirtualMachine> vmProfile, DeploymentPlan plan, ExcludeList avoid) throws InsufficientServerCapacityException { |
67 | 67 | VirtualMachine vm = vmProfile.getVirtualMachine(); |
68 | | - ServiceOffering offering = vmProfile.getServiceOffering(); |
| 68 | + ServiceOffering offering = vmProfile.getServiceOffering(); |
69 | 69 | String hostTag = null; |
70 | | - |
71 | | - String opFactor = _configDao.getValue(Config.CPUOverprovisioningFactor.key()); |
72 | | - float cpuOverprovisioningFactor = NumbersUtil.parseFloat(opFactor, 1); |
73 | | - |
| 70 | + |
74 | 71 | String haVmTag = (String)vmProfile.getParameter(VirtualMachineProfile.Param.HaTag); |
75 | 72 |
|
76 | 73 | if (vm.getLastHostId() != null && haVmTag == null) { |
@@ -126,7 +123,13 @@ public DeployDestination plan(VirtualMachineProfile<? extends VirtualMachine> vm |
126 | 123 | return null; |
127 | 124 | } |
128 | 125 | for (HostVO h : hosts) { |
129 | | - if (_capacityMgr.checkIfHostHasCapacity(h.getId(), cpu_requested, ram_requested, false, cpuOverprovisioningFactor, true)) { |
| 126 | + long cluster_id = h.getClusterId(); |
| 127 | + ClusterDetailsVO cluster_detail_cpu = _clusterDetailsDao.findDetail(cluster_id,"cpuOvercommitRatio") ; |
| 128 | + ClusterDetailsVO cluster_detail_ram = _clusterDetailsDao.findDetail(cluster_id,"memoryOvercommitRatio"); |
| 129 | + Float cpuOvercommitRatio = Float.parseFloat(cluster_detail_cpu.getValue()); |
| 130 | + Float memoryOvercommitRatio = Float.parseFloat(cluster_detail_ram.getValue()); |
| 131 | + |
| 132 | + if (_capacityMgr.checkIfHostHasCapacity(h.getId(), cpu_requested, ram_requested, false, cpuOvercommitRatio, memoryOvercommitRatio, true)) { |
130 | 133 | s_logger.debug("Find host " + h.getId() + " has enough capacity"); |
131 | 134 | DataCenter dc = _dcDao.findById(h.getDataCenterId()); |
132 | 135 | Pod pod = _podDao.findById(h.getPodId()); |
|
0 commit comments