Skip to content

Commit e15e366

Browse files
author
Nicole Schmidt
committed
Move configuration to Planner hierarchy
1 parent 68e16c5 commit e15e366

File tree

6 files changed

+16
-24
lines changed

6 files changed

+16
-24
lines changed

api/src/main/java/com/cloud/deploy/DeploymentClusterPlanner.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,14 @@ public interface DeploymentClusterPlanner extends DeploymentPlanner {
6868
ConfigKey.Kind.Select,
6969
"random,firstfit,userdispersing,userconcentratedpod_random,userconcentratedpod_firstfit,firstfitleastconsumed");
7070

71+
ConfigKey<Boolean> allowRoutersOnDedicatedResources = new ConfigKey<>(
72+
"Advanced",
73+
Boolean.class,
74+
"allow.routers.on.dedicated.resources",
75+
"false",
76+
"Allow deploying virtual routers on dedicated Hosts, Clusters, Pods, and Zones",
77+
true);
78+
7179
/**
7280
* This is called to determine list of possible clusters where a virtual
7381
* machine can be deployed.

engine/schema/src/main/java/com/cloud/capacity/dao/CapacityDao.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,9 @@
2424
import com.cloud.utils.Pair;
2525
import com.cloud.utils.Ternary;
2626
import com.cloud.utils.db.GenericDao;
27-
import org.apache.cloudstack.framework.config.ConfigKey;
2827

2928
public interface CapacityDao extends GenericDao<CapacityVO, Long> {
3029

31-
ConfigKey<Boolean> allowRoutersOnDedicatedResources = new ConfigKey<>("Advanced", Boolean.class, "allow.routers.on.dedicated.resources", "false",
32-
"Allow deploying virtual routers on dedicated Hosts, Clusters, Pods, and Zones", true);
33-
3430
CapacityVO findByHostIdType(Long hostId, short capacityType);
3531

3632
List<CapacityVO> listByHostIdTypes(Long hostId, List<Short> capacityTypes);
@@ -45,7 +41,7 @@ public interface CapacityDao extends GenericDao<CapacityVO, Long> {
4541

4642
List<SummedCapacity> findNonSharedStorageForClusterPodZone(Long zoneId, Long podId, Long clusterId);
4743

48-
Pair<List<Long>, Map<Long, Double>> orderClustersByAggregateCapacity(long id, long vmId, short capacityType, boolean isVr, boolean isZone);
44+
Pair<List<Long>, Map<Long, Double>> orderClustersByAggregateCapacity(long id, long vmId, short capacityType, boolean isVr, boolean allowRoutersOnDedicatedResources, boolean isZone);
4945

5046
Ternary<Long, Long, Long> findCapacityByZoneAndHostTag(Long zoneId, String hostTag);
5147

engine/schema/src/main/java/com/cloud/capacity/dao/CapacityDaoImpl.java

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@
2626

2727
import javax.inject.Inject;
2828

29-
import org.apache.cloudstack.framework.config.ConfigKey;
30-
import org.apache.cloudstack.framework.config.Configurable;
3129
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
3230
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
3331
import org.apache.commons.collections.CollectionUtils;
@@ -51,7 +49,7 @@
5149
import com.cloud.utils.exception.CloudRuntimeException;
5250

5351
@Component
54-
public class CapacityDaoImpl extends GenericDaoBase<CapacityVO, Long> implements CapacityDao, Configurable {
52+
public class CapacityDaoImpl extends GenericDaoBase<CapacityVO, Long> implements CapacityDao {
5553

5654
private static final String ADD_ALLOCATED_SQL = "UPDATE `cloud`.`op_host_capacity` SET used_capacity = used_capacity + ? WHERE host_id = ? AND capacity_type = ?";
5755
private static final String SUBTRACT_ALLOCATED_SQL =
@@ -984,7 +982,7 @@ public boolean removeBy(Short capacityType, Long zoneId, Long podId, Long cluste
984982
}
985983

986984
@Override
987-
public Pair<List<Long>, Map<Long, Double>> orderClustersByAggregateCapacity(long id, long vmId, short capacityTypeForOrdering, boolean isVr, boolean isZone) {
985+
public Pair<List<Long>, Map<Long, Double>> orderClustersByAggregateCapacity(long id, long vmId, short capacityTypeForOrdering, boolean isVr, boolean allowRoutersOnDedicatedResources, boolean isZone) {
988986
TransactionLegacy txn = TransactionLegacy.currentTxn();
989987
PreparedStatement pstmt = null;
990988
List<Long> result = new ArrayList<Long>();
@@ -996,7 +994,7 @@ public Pair<List<Long>, Map<Long, Double>> orderClustersByAggregateCapacity(long
996994
sql.append(ORDER_CLUSTERS_BY_AGGREGATE_OVERCOMMIT_CAPACITY_PART1);
997995
}
998996

999-
if (isVr && allowRoutersOnDedicatedResources.value()) {
997+
if (isVr && allowRoutersOnDedicatedResources) {
1000998
sql.append(ORDER_CLUSTERS_BY_AGGREGATE_CAPACITY_INCLUDE_DEDICATED_TO_DOMAIN_JOIN_1);
1001999
} else {
10021000
sql.append(ORDER_CLUSTERS_BY_AGGREGATE_CAPACITY_JOIN_1);
@@ -1232,14 +1230,4 @@ public float findClusterConsumption(Long clusterId, short capacityType, long com
12321230
}
12331231
return 0;
12341232
}
1235-
1236-
@Override
1237-
public ConfigKey<?>[] getConfigKeys() {
1238-
return new ConfigKey<?>[] {allowRoutersOnDedicatedResources};
1239-
}
1240-
1241-
@Override
1242-
public String getConfigComponentName() {
1243-
return CapacityDaoImpl.class.getSimpleName();
1244-
}
12451233
}

plugins/deployment-planners/implicit-dedication/src/test/java/org/apache/cloudstack/implicitplanner/ImplicitPlannerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ private void initializeForTest(VirtualMachineProfileImpl vmProfile, DataCenterDe
366366
clusterCapacityMap.put(2L, 2048D);
367367
clusterCapacityMap.put(3L, 2048D);
368368
Pair<List<Long>, Map<Long, Double>> clustersOrderedByCapacity = new Pair<List<Long>, Map<Long, Double>>(clustersWithEnoughCapacity, clusterCapacityMap);
369-
when(capacityDao.orderClustersByAggregateCapacity(dataCenterId, 12L, Capacity.CAPACITY_TYPE_CPU, false, true)).thenReturn(clustersOrderedByCapacity);
369+
when(capacityDao.orderClustersByAggregateCapacity(dataCenterId, 12L, Capacity.CAPACITY_TYPE_CPU, false, false, true)).thenReturn(clustersOrderedByCapacity);
370370

371371
List<Long> disabledClusters = new ArrayList<Long>();
372372
List<Long> clustersWithDisabledPods = new ArrayList<Long>();

server/src/main/java/com/cloud/deploy/FirstFitPlanner.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ protected Pair<List<Long>, Map<Long, Double>> listClustersByCapacity(long id, lo
468468
if (logger.isTraceEnabled()) {
469469
logger.trace("ClusterId List having enough CPU and RAM capacity: " + clusterIdswithEnoughCapacity);
470470
}
471-
Pair<List<Long>, Map<Long, Double>> result = capacityDao.orderClustersByAggregateCapacity(id, vmId, capacityType, isVr, isZone);
471+
Pair<List<Long>, Map<Long, Double>> result = capacityDao.orderClustersByAggregateCapacity(id, vmId, capacityType, isVr, allowRoutersOnDedicatedResources.value(), isZone);
472472
List<Long> clusterIdsOrderedByAggregateCapacity = result.first();
473473
//only keep the clusters that have enough capacity to host this VM
474474
if (logger.isTraceEnabled()) {
@@ -595,6 +595,6 @@ public String getConfigComponentName() {
595595

596596
@Override
597597
public ConfigKey<?>[] getConfigKeys() {
598-
return new ConfigKey<?>[] {ClusterCPUCapacityDisableThreshold, ClusterMemoryCapacityDisableThreshold, ClusterThresholdEnabled, VmAllocationAlgorithm};
598+
return new ConfigKey<?>[] {ClusterCPUCapacityDisableThreshold, ClusterMemoryCapacityDisableThreshold, ClusterThresholdEnabled, VmAllocationAlgorithm, allowRoutersOnDedicatedResources};
599599
}
600600
}

server/src/test/java/com/cloud/vm/FirstFitPlannerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ private void initializeForTest(VirtualMachineProfileImpl vmProfile, DataCenterDe
304304
clusterCapacityMap.put(6L, 2048D);
305305

306306
Pair<List<Long>, Map<Long, Double>> clustersOrderedByCapacity = new Pair<List<Long>, Map<Long, Double>>(clustersWithEnoughCapacity, clusterCapacityMap);
307-
when(capacityDao.orderClustersByAggregateCapacity(dataCenterId, 12L, Capacity.CAPACITY_TYPE_CPU, false, true)).thenReturn(clustersOrderedByCapacity);
307+
when(capacityDao.orderClustersByAggregateCapacity(dataCenterId, 12L, Capacity.CAPACITY_TYPE_CPU, false, false,true)).thenReturn(clustersOrderedByCapacity);
308308

309309
List<Long> disabledClusters = new ArrayList<Long>();
310310
List<Long> clustersWithDisabledPods = new ArrayList<Long>();

0 commit comments

Comments
 (0)