Skip to content

Commit c2d4461

Browse files
authored
Merge branch '4.20' into storagePoolAutomationRefactors
2 parents 66d0ba5 + 4d95f08 commit c2d4461

File tree

45 files changed

+343
-115
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+343
-115
lines changed

api/src/main/java/org/apache/cloudstack/api/ApiConstants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public class ApiConstants {
2626
public static final String ACTIVATION_RULE = "activationrule";
2727
public static final String ACTIVITY = "activity";
2828
public static final String ADAPTER_TYPE = "adaptertype";
29+
public static final String ADDITONAL_CONFIG_ENABLED = "additionalconfigenabled";
2930
public static final String ADDRESS = "address";
3031
public static final String ALGORITHM = "algorithm";
3132
public static final String ALIAS = "alias";

api/src/main/java/org/apache/cloudstack/api/command/user/config/ListCapabilitiesCmd.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ public void execute() {
7373
response.setSharedFsVmMinCpuCount((Integer)capabilities.get(ApiConstants.SHAREDFSVM_MIN_CPU_COUNT));
7474
response.setSharedFsVmMinRamSize((Integer)capabilities.get(ApiConstants.SHAREDFSVM_MIN_RAM_SIZE));
7575
response.setDynamicScalingEnabled((Boolean) capabilities.get(ApiConstants.DYNAMIC_SCALING_ENABLED));
76+
response.setAdditionalConfigEnabled((Boolean) capabilities.get(ApiConstants.ADDITONAL_CONFIG_ENABLED));
7677
response.setObjectName("capability");
7778
response.setResponseName(getCommandName());
7879
this.setResponseObject(response);

api/src/main/java/org/apache/cloudstack/api/response/CapabilitiesResponse.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,10 @@ public class CapabilitiesResponse extends BaseResponse {
140140
@Param(description = "true if dynamically scaling for instances is enabled", since = "4.21.0")
141141
private Boolean dynamicScalingEnabled;
142142

143+
@SerializedName(ApiConstants.ADDITONAL_CONFIG_ENABLED)
144+
@Param(description = "true if additional configurations or extraconfig can be passed to Instances", since = "4.20.2")
145+
private Boolean additionalConfigEnabled;
146+
143147
public void setSecurityGroupsEnabled(boolean securityGroupsEnabled) {
144148
this.securityGroupsEnabled = securityGroupsEnabled;
145149
}
@@ -255,4 +259,8 @@ public void setSharedFsVmMinRamSize(Integer sharedFsVmMinRamSize) {
255259
public void setDynamicScalingEnabled(Boolean dynamicScalingEnabled) {
256260
this.dynamicScalingEnabled = dynamicScalingEnabled;
257261
}
262+
263+
public void setAdditionalConfigEnabled(Boolean additionalConfigEnabled) {
264+
this.additionalConfigEnabled = additionalConfigEnabled;
265+
}
258266
}

engine/components-api/src/main/java/com/cloud/storage/StorageManager.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,8 @@ static Boolean getFullCloneConfiguration(Long storeId) {
294294

295295
Answer sendToPool(StoragePool pool, long[] hostIdsToTryFirst, Command cmd) throws StorageUnavailableException;
296296

297+
void updateStoragePoolHostVOAndBytes(StoragePool pool, long hostId, ModifyStoragePoolAnswer mspAnswer);
298+
297299
CapacityVO getSecondaryStorageUsedStats(Long hostId, Long zoneId);
298300

299301
CapacityVO getStoragePoolUsedStats(Long poolId, Long clusterId, Long podId, Long zoneId);

engine/components-api/src/main/java/com/cloud/template/TemplateManager.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,13 @@ public interface TemplateManager {
5656
+ "will validate if the provided URL is resolvable during the register of templates/ISOs before persisting them in the database.",
5757
true);
5858

59+
ConfigKey<Boolean> TemplateDeleteFromPrimaryStorage = new ConfigKey<Boolean>("Advanced",
60+
Boolean.class,
61+
"template.delete.from.primary.storage", "true",
62+
"Template when deleted will be instantly deleted from the Primary Storage",
63+
true,
64+
ConfigKey.Scope.Global);
65+
5966
static final String VMWARE_TOOLS_ISO = "vmware-tools.iso";
6067
static final String XS_TOOLS_ISO = "xs-tools.iso";
6168

@@ -103,6 +110,8 @@ public interface TemplateManager {
103110
*/
104111
List<VMTemplateStoragePoolVO> getUnusedTemplatesInPool(StoragePoolVO pool);
105112

113+
void evictTemplateFromStoragePoolsForZones(Long templateId, List<Long> zoneId);
114+
106115
/**
107116
* Deletes a template in the specified storage pool.
108117
*

engine/schema/src/main/java/com/cloud/storage/dao/VMTemplatePoolDao.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ public interface VMTemplatePoolDao extends GenericDao<VMTemplateStoragePoolVO, L
3535

3636
List<VMTemplateStoragePoolVO> listByPoolIdAndState(long poolId, ObjectInDataStoreStateMachine.State state);
3737

38+
List<VMTemplateStoragePoolVO> listByPoolIdsAndTemplate(List<Long> poolIds, Long templateId);
39+
3840
List<VMTemplateStoragePoolVO> listByTemplateStatus(long templateId, VMTemplateStoragePoolVO.Status downloadState);
3941

4042
List<VMTemplateStoragePoolVO> listByTemplateStatus(long templateId, VMTemplateStoragePoolVO.Status downloadState, long poolId);

engine/schema/src/main/java/com/cloud/storage/dao/VMTemplatePoolDaoImpl.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,16 @@ public VMTemplateStoragePoolVO findByPoolTemplate(long poolId, long templateId,
150150
return findOneIncludingRemovedBy(sc);
151151
}
152152

153+
@Override
154+
public List<VMTemplateStoragePoolVO> listByPoolIdsAndTemplate(List<Long> poolIds, Long templateId) {
155+
SearchCriteria<VMTemplateStoragePoolVO> sc = PoolTemplateSearch.create();
156+
if (CollectionUtils.isNotEmpty(poolIds)) {
157+
sc.setParameters("pool_id", poolIds.toArray());
158+
}
159+
sc.setParameters("template_id", templateId);
160+
return listBy(sc);
161+
}
162+
153163
@Override
154164
public List<VMTemplateStoragePoolVO> listByTemplateStatus(long templateId, VMTemplateStoragePoolVO.Status downloadState) {
155165
SearchCriteria<VMTemplateStoragePoolVO> sc = TemplateStatusSearch.create();

engine/schema/src/main/java/com/cloud/vm/dao/VMInstanceDaoImpl.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,17 +116,17 @@ public class VMInstanceDaoImpl extends GenericDaoBase<VMInstanceVO, Long> implem
116116

117117
protected Attribute _updateTimeAttr;
118118

119-
private static final String ORDER_CLUSTERS_NUMBER_OF_VMS_FOR_ACCOUNT_PART1 = "SELECT host.cluster_id, SUM(IF(vm.state='Running' AND vm.account_id = ?, 1, 0)) " +
119+
private static final String ORDER_CLUSTERS_NUMBER_OF_VMS_FOR_ACCOUNT_PART1 = "SELECT host.cluster_id, SUM(IF(vm.state IN ('Running', 'Starting') AND vm.account_id = ?, 1, 0)) " +
120120
"FROM `cloud`.`host` host LEFT JOIN `cloud`.`vm_instance` vm ON host.id = vm.host_id WHERE ";
121121
private static final String ORDER_CLUSTERS_NUMBER_OF_VMS_FOR_ACCOUNT_PART2 = " AND host.type = 'Routing' AND host.removed is null GROUP BY host.cluster_id " +
122122
"ORDER BY 2 ASC ";
123123

124-
private static final String ORDER_PODS_NUMBER_OF_VMS_FOR_ACCOUNT = "SELECT pod.id, SUM(IF(vm.state='Running' AND vm.account_id = ?, 1, 0)) FROM `cloud`.`" +
124+
private static final String ORDER_PODS_NUMBER_OF_VMS_FOR_ACCOUNT = "SELECT pod.id, SUM(IF(vm.state IN ('Running', 'Starting') AND vm.account_id = ?, 1, 0)) FROM `cloud`.`" +
125125
"host_pod_ref` pod LEFT JOIN `cloud`.`vm_instance` vm ON pod.id = vm.pod_id WHERE pod.data_center_id = ? AND pod.removed is null "
126126
+ " GROUP BY pod.id ORDER BY 2 ASC ";
127127

128128
private static final String ORDER_HOSTS_NUMBER_OF_VMS_FOR_ACCOUNT =
129-
"SELECT host.id, SUM(IF(vm.state='Running' AND vm.account_id = ?, 1, 0)) FROM `cloud`.`host` host LEFT JOIN `cloud`.`vm_instance` vm ON host.id = vm.host_id " +
129+
"SELECT host.id, SUM(IF(vm.state IN ('Running', 'Starting') AND vm.account_id = ?, 1, 0)) FROM `cloud`.`host` host LEFT JOIN `cloud`.`vm_instance` vm ON host.id = vm.host_id " +
130130
"WHERE host.data_center_id = ? AND host.type = 'Routing' AND host.removed is null ";
131131

132132
private static final String ORDER_HOSTS_NUMBER_OF_VMS_FOR_ACCOUNT_PART2 = " GROUP BY host.id ORDER BY 2 ASC ";

engine/schema/src/main/java/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDao.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,4 +154,6 @@ Pair<List<Long>, Integer> searchForIdsAndCount(Long storagePoolId, String storag
154154
String keyword, Filter searchFilter);
155155

156156
List<StoragePoolVO> listByIds(List<Long> ids);
157+
158+
List<StoragePoolVO> listByDataCenterIds(List<Long> dataCenterIds);
157159
}

engine/schema/src/main/java/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDaoImpl.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ public class PrimaryDataStoreDaoImpl extends GenericDaoBase<StoragePoolVO, Long>
6363
private final GenericSearchBuilder<StoragePoolVO, Long> StatusCountSearch;
6464
private final SearchBuilder<StoragePoolVO> ClustersSearch;
6565
private final SearchBuilder<StoragePoolVO> IdsSearch;
66+
private final SearchBuilder<StoragePoolVO> DcsSearch;
6667

6768
@Inject
6869
private StoragePoolDetailsDao _detailsDao;
@@ -155,6 +156,9 @@ public PrimaryDataStoreDaoImpl() {
155156
IdsSearch.and("ids", IdsSearch.entity().getId(), SearchCriteria.Op.IN);
156157
IdsSearch.done();
157158

159+
DcsSearch = createSearchBuilder();
160+
DcsSearch.and("dataCenterId", DcsSearch.entity().getDataCenterId(), SearchCriteria.Op.IN);
161+
DcsSearch.done();
158162
}
159163

160164
@Override
@@ -733,6 +737,16 @@ public List<StoragePoolVO> listByIds(List<Long> ids) {
733737
return listBy(sc);
734738
}
735739

740+
@Override
741+
public List<StoragePoolVO> listByDataCenterIds(List<Long> dataCenterIds) {
742+
if (CollectionUtils.isEmpty(dataCenterIds)) {
743+
return Collections.emptyList();
744+
}
745+
SearchCriteria<StoragePoolVO> sc = DcsSearch.create();
746+
sc.setParameters("dataCenterId", dataCenterIds.toArray());
747+
return listBy(sc);
748+
}
749+
736750
private SearchCriteria<StoragePoolVO> createStoragePoolSearchCriteria(Long storagePoolId, String storagePoolName,
737751
Long zoneId, String path, Long podId, Long clusterId, String address, ScopeType scopeType,
738752
StoragePoolStatus status, String keyword) {

0 commit comments

Comments
 (0)