Skip to content

Commit 5c9224a

Browse files
committed
Merge remote-tracking branch 'origin/4.22' into fix-reset-link-default-value
2 parents 151cd06 + b196e97 commit 5c9224a

File tree

59 files changed

+1515
-294
lines changed

Some content is hidden

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

59 files changed

+1515
-294
lines changed

api/src/main/java/org/apache/cloudstack/api/command/user/volume/CreateVolumeCmd.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import org.apache.cloudstack.api.response.DomainResponse;
3333
import org.apache.cloudstack.api.response.ProjectResponse;
3434
import org.apache.cloudstack.api.response.SnapshotResponse;
35+
import org.apache.cloudstack.api.response.StoragePoolResponse;
3536
import org.apache.cloudstack.api.response.UserVmResponse;
3637
import org.apache.cloudstack.api.response.VolumeResponse;
3738
import org.apache.cloudstack.api.response.ZoneResponse;
@@ -109,6 +110,13 @@ public class CreateVolumeCmd extends BaseAsyncCreateCustomIdCmd implements UserC
109110
description = "The ID of the Instance; to be used with snapshot Id, Instance to which the volume gets attached after creation")
110111
private Long virtualMachineId;
111112

113+
@Parameter(name = ApiConstants.STORAGE_ID,
114+
type = CommandType.UUID,
115+
entityType = StoragePoolResponse.class,
116+
description = "Storage pool ID to create the volume in. Cannot be used with the snapshotid parameter.",
117+
authorized = {RoleType.Admin})
118+
private Long storageId;
119+
112120
/////////////////////////////////////////////////////
113121
/////////////////// Accessors ///////////////////////
114122
/////////////////////////////////////////////////////
@@ -153,6 +161,13 @@ private Long getProjectId() {
153161
return projectId;
154162
}
155163

164+
public Long getStorageId() {
165+
if (snapshotId != null && storageId != null) {
166+
throw new IllegalArgumentException("StorageId parameter cannot be specified with the SnapshotId parameter.");
167+
}
168+
return storageId;
169+
}
170+
156171
public Boolean getDisplayVolume() {
157172
return displayVolume;
158173
}

api/src/main/java/org/apache/cloudstack/storage/volume/VolumeImportUnmanageService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public interface VolumeImportUnmanageService extends PluggableService, Configura
3737
Arrays.asList(Hypervisor.HypervisorType.KVM, Hypervisor.HypervisorType.VMware);
3838

3939
List<Storage.StoragePoolType> SUPPORTED_STORAGE_POOL_TYPES_FOR_KVM = Arrays.asList(Storage.StoragePoolType.NetworkFilesystem,
40-
Storage.StoragePoolType.Filesystem, Storage.StoragePoolType.RBD);
40+
Storage.StoragePoolType.Filesystem, Storage.StoragePoolType.RBD, Storage.StoragePoolType.SharedMountPoint);
4141

4242
ConfigKey<Boolean> AllowImportVolumeWithBackingFile = new ConfigKey<>(Boolean.class,
4343
"allow.import.volume.with.backing.file",

core/src/main/java/org/apache/cloudstack/backup/RestoreBackupCommand.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public class RestoreBackupCommand extends Command {
3434
private List<String> backupVolumesUUIDs;
3535
private List<PrimaryDataStoreTO> restoreVolumePools;
3636
private List<String> restoreVolumePaths;
37+
private List<Long> restoreVolumeSizes;
3738
private List<String> backupFiles;
3839
private String diskType;
3940
private Boolean vmExists;
@@ -92,6 +93,14 @@ public void setRestoreVolumePaths(List<String> restoreVolumePaths) {
9293
this.restoreVolumePaths = restoreVolumePaths;
9394
}
9495

96+
public List<Long> getRestoreVolumeSizes() {
97+
return restoreVolumeSizes;
98+
}
99+
100+
public void setRestoreVolumeSizes(List<Long> restoreVolumeSizes) {
101+
this.restoreVolumeSizes = restoreVolumeSizes;
102+
}
103+
95104
public List<String> getBackupFiles() {
96105
return backupFiles;
97106
}

engine/components-api/src/main/java/com/cloud/ha/HighAvailabilityManager.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import com.cloud.deploy.DeploymentPlanner;
2222
import com.cloud.host.HostVO;
2323
import com.cloud.host.Status;
24+
import com.cloud.storage.Storage.StoragePoolType;
2425
import com.cloud.utils.component.Manager;
2526
import com.cloud.vm.VMInstanceVO;
2627
import org.apache.cloudstack.framework.config.ConfigKey;
@@ -32,6 +33,8 @@
3233
*/
3334
public interface HighAvailabilityManager extends Manager {
3435

36+
List<StoragePoolType> LIBVIRT_STORAGE_POOL_TYPES_WITH_HA_SUPPORT = List.of(StoragePoolType.NetworkFilesystem, StoragePoolType.SharedMountPoint);
37+
3538
ConfigKey<Boolean> ForceHA = new ConfigKey<>("Advanced", Boolean.class, "force.ha", "false",
3639
"Force High-Availability to happen even if the VM says no.", true, Cluster);
3740

engine/schema/src/main/java/com/cloud/host/dao/HostTagsDao.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,9 @@ public interface HostTagsDao extends GenericDao<HostTagVO, Long> {
4545
HostTagResponse newHostTagResponse(HostTagVO hostTag);
4646

4747
List<HostTagVO> searchByIds(Long... hostTagIds);
48+
49+
/**
50+
* List all host tags defined on hosts within a cluster
51+
*/
52+
List<String> listByClusterId(Long clusterId);
4853
}

engine/schema/src/main/java/com/cloud/host/dao/HostTagsDaoImpl.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.apache.cloudstack.framework.config.ConfigKey;
2424
import org.apache.cloudstack.framework.config.Configurable;
2525
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
26+
import org.apache.commons.collections4.CollectionUtils;
2627
import org.apache.commons.lang3.StringUtils;
2728
import org.springframework.stereotype.Component;
2829

@@ -43,9 +44,12 @@ public class HostTagsDaoImpl extends GenericDaoBase<HostTagVO, Long> implements
4344
private final SearchBuilder<HostTagVO> stSearch;
4445
private final SearchBuilder<HostTagVO> tagIdsearch;
4546
private final SearchBuilder<HostTagVO> ImplicitTagsSearch;
47+
private final GenericSearchBuilder<HostTagVO, String> tagSearch;
4648

4749
@Inject
4850
private ConfigurationDao _configDao;
51+
@Inject
52+
private HostDao hostDao;
4953

5054
public HostTagsDaoImpl() {
5155
HostSearch = createSearchBuilder();
@@ -72,6 +76,11 @@ public HostTagsDaoImpl() {
7276
ImplicitTagsSearch.and("hostId", ImplicitTagsSearch.entity().getHostId(), SearchCriteria.Op.EQ);
7377
ImplicitTagsSearch.and("isImplicit", ImplicitTagsSearch.entity().getIsImplicit(), SearchCriteria.Op.EQ);
7478
ImplicitTagsSearch.done();
79+
80+
tagSearch = createSearchBuilder(String.class);
81+
tagSearch.selectFields(tagSearch.entity().getTag());
82+
tagSearch.and("hostIdIN", tagSearch.entity().getHostId(), SearchCriteria.Op.IN);
83+
tagSearch.done();
7584
}
7685

7786
@Override
@@ -235,4 +244,15 @@ public List<HostTagVO> searchByIds(Long... tagIds) {
235244

236245
return tagList;
237246
}
247+
248+
@Override
249+
public List<String> listByClusterId(Long clusterId) {
250+
List<Long> hostIds = hostDao.listIdsByClusterId(clusterId);
251+
if (CollectionUtils.isEmpty(hostIds)) {
252+
return new ArrayList<>();
253+
}
254+
SearchCriteria<String> sc = tagSearch.create();
255+
sc.setParameters("hostIdIN", hostIds.toArray());
256+
return customSearch(sc, null);
257+
}
238258
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ protected void init() {
170170
CountSnapshotsByAccount.select(null, Func.COUNT, null);
171171
CountSnapshotsByAccount.and("account", CountSnapshotsByAccount.entity().getAccountId(), SearchCriteria.Op.EQ);
172172
CountSnapshotsByAccount.and("status", CountSnapshotsByAccount.entity().getState(), SearchCriteria.Op.NIN);
173+
CountSnapshotsByAccount.and("snapshotTypeNEQ", CountSnapshotsByAccount.entity().getSnapshotType(), SearchCriteria.Op.NIN);
173174
CountSnapshotsByAccount.and("removed", CountSnapshotsByAccount.entity().getRemoved(), SearchCriteria.Op.NULL);
174175
CountSnapshotsByAccount.done();
175176

@@ -220,6 +221,7 @@ public Long countSnapshotsForAccount(long accountId) {
220221
SearchCriteria<Long> sc = CountSnapshotsByAccount.create();
221222
sc.setParameters("account", accountId);
222223
sc.setParameters("status", State.Error, State.Destroyed);
224+
sc.setParameters("snapshotTypeNEQ", Snapshot.Type.GROUP.ordinal());
223225
return customSearch(sc, null).get(0);
224226
}
225227

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.util.HashMap;
2222
import java.util.List;
2323
import java.util.Map;
24+
import java.util.Set;
2425

2526
import com.cloud.hypervisor.Hypervisor;
2627
import com.cloud.utils.Pair;
@@ -192,4 +193,8 @@ List<VMInstanceVO> searchRemovedByRemoveDate(final Date startDate, final Date en
192193
int getVmCountByOfferingNotInDomain(Long serviceOfferingId, List<Long> domainIds);
193194

194195
List<VMInstanceVO> listByIdsIncludingRemoved(List<Long> ids);
196+
197+
List<VMInstanceVO> listDeleteProtectedVmsByAccountId(long accountId);
198+
199+
List<VMInstanceVO> listDeleteProtectedVmsByDomainIds(Set<Long> domainIds);
195200
}

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

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,13 @@
2525
import java.util.HashMap;
2626
import java.util.List;
2727
import java.util.Map;
28+
import java.util.Set;
2829
import java.util.stream.Collectors;
2930

3031
import javax.annotation.PostConstruct;
3132
import javax.inject.Inject;
3233

34+
import org.apache.cloudstack.api.ApiConstants;
3335
import org.apache.commons.collections.CollectionUtils;
3436
import org.springframework.stereotype.Component;
3537

@@ -106,6 +108,8 @@ public class VMInstanceDaoImpl extends GenericDaoBase<VMInstanceVO, Long> implem
106108
protected SearchBuilder<VMInstanceVO> IdsPowerStateSelectSearch;
107109
GenericSearchBuilder<VMInstanceVO, Integer> CountByOfferingId;
108110
GenericSearchBuilder<VMInstanceVO, Integer> CountUserVmNotInDomain;
111+
SearchBuilder<VMInstanceVO> DeleteProtectedVmSearchByAccount;
112+
SearchBuilder<VMInstanceVO> DeleteProtectedVmSearchByDomainIds;
109113

110114
@Inject
111115
ResourceTagDao tagsDao;
@@ -368,6 +372,19 @@ protected void init() {
368372
CountUserVmNotInDomain.and("domainIdsNotIn", CountUserVmNotInDomain.entity().getDomainId(), Op.NIN);
369373
CountUserVmNotInDomain.done();
370374

375+
DeleteProtectedVmSearchByAccount = createSearchBuilder();
376+
DeleteProtectedVmSearchByAccount.selectFields(DeleteProtectedVmSearchByAccount.entity().getUuid());
377+
DeleteProtectedVmSearchByAccount.and(ApiConstants.ACCOUNT_ID, DeleteProtectedVmSearchByAccount.entity().getAccountId(), Op.EQ);
378+
DeleteProtectedVmSearchByAccount.and(ApiConstants.DELETE_PROTECTION, DeleteProtectedVmSearchByAccount.entity().isDeleteProtection(), Op.EQ);
379+
DeleteProtectedVmSearchByAccount.and(ApiConstants.REMOVED, DeleteProtectedVmSearchByAccount.entity().getRemoved(), Op.NULL);
380+
DeleteProtectedVmSearchByAccount.done();
381+
382+
DeleteProtectedVmSearchByDomainIds = createSearchBuilder();
383+
DeleteProtectedVmSearchByDomainIds.selectFields(DeleteProtectedVmSearchByDomainIds.entity().getUuid());
384+
DeleteProtectedVmSearchByDomainIds.and(ApiConstants.DOMAIN_IDS, DeleteProtectedVmSearchByDomainIds.entity().getDomainId(), Op.IN);
385+
DeleteProtectedVmSearchByDomainIds.and(ApiConstants.DELETE_PROTECTION, DeleteProtectedVmSearchByDomainIds.entity().isDeleteProtection(), Op.EQ);
386+
DeleteProtectedVmSearchByDomainIds.and(ApiConstants.REMOVED, DeleteProtectedVmSearchByDomainIds.entity().getRemoved(), Op.NULL);
387+
DeleteProtectedVmSearchByDomainIds.done();
371388
}
372389

373390
@Override
@@ -1296,4 +1313,22 @@ public List<VMInstanceVO> listByIdsIncludingRemoved(List<Long> ids) {
12961313
sc.setParameters("ids", ids.toArray());
12971314
return listIncludingRemovedBy(sc);
12981315
}
1316+
1317+
@Override
1318+
public List<VMInstanceVO> listDeleteProtectedVmsByAccountId(long accountId) {
1319+
SearchCriteria<VMInstanceVO> sc = DeleteProtectedVmSearchByAccount.create();
1320+
sc.setParameters(ApiConstants.ACCOUNT_ID, accountId);
1321+
sc.setParameters(ApiConstants.DELETE_PROTECTION, true);
1322+
Filter filter = new Filter(VMInstanceVO.class, null, false, 0L, 10L);
1323+
return listBy(sc, filter);
1324+
}
1325+
1326+
@Override
1327+
public List<VMInstanceVO> listDeleteProtectedVmsByDomainIds(Set<Long> domainIds) {
1328+
SearchCriteria<VMInstanceVO> sc = DeleteProtectedVmSearchByDomainIds.create();
1329+
sc.setParameters(ApiConstants.DOMAIN_IDS, domainIds.toArray());
1330+
sc.setParameters(ApiConstants.DELETE_PROTECTION, true);
1331+
Filter filter = new Filter(VMInstanceVO.class, null, false, 0L, 10L);
1332+
return listBy(sc, filter);
1333+
}
12991334
}

engine/schema/src/main/java/org/apache/cloudstack/backup/dao/BackupScheduleDao.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,14 @@
2121
import java.util.List;
2222

2323
import com.cloud.utils.DateUtil;
24-
import org.apache.cloudstack.api.response.BackupScheduleResponse;
25-
import org.apache.cloudstack.backup.BackupSchedule;
2624
import org.apache.cloudstack.backup.BackupScheduleVO;
2725

2826
import com.cloud.utils.db.GenericDao;
2927

3028
public interface BackupScheduleDao extends GenericDao<BackupScheduleVO, Long> {
31-
BackupScheduleVO findByVM(Long vmId);
32-
3329
List<BackupScheduleVO> listByVM(Long vmId);
3430

3531
BackupScheduleVO findByVMAndIntervalType(Long vmId, DateUtil.IntervalType intervalType);
3632

3733
List<BackupScheduleVO> getSchedulesToExecute(Date currentTimestamp);
38-
39-
BackupScheduleResponse newBackupScheduleResponse(BackupSchedule schedule);
4034
}

0 commit comments

Comments
 (0)