Skip to content

Commit 2534840

Browse files
committed
list by isEncrypted
1 parent 7aacbcb commit 2534840

5 files changed

Lines changed: 18 additions & 2 deletions

File tree

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ public class ApiConstants {
263263
public static final String IS_CLEANUP_REQUIRED = "iscleanuprequired";
264264
public static final String IS_DYNAMIC = "isdynamic";
265265
public static final String IS_EDGE = "isedge";
266+
public static final String IS_ENCRYPTED = "isencrypted";
266267
public static final String IS_EXTRACTABLE = "isextractable";
267268
public static final String IS_FEATURED = "isfeatured";
268269
public static final String IS_PORTABLE = "isportable";

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ public class ListVolumesCmd extends BaseListRetrieveOnlyResourceCountCmd impleme
9696
@Parameter(name = ApiConstants.STATE, type = CommandType.STRING, description = "state of the volume. Possible values are: Ready, Allocated, Destroy, Expunging, Expunged.")
9797
private String state;
9898

99+
@Parameter(name = ApiConstants.IS_ENCRYPTED, type = CommandType.BOOLEAN, description = "list only volumes that are encrypted", since = "4.20",
100+
authorized = { RoleType.Admin })
101+
private Boolean encrypted;
99102
/////////////////////////////////////////////////////
100103
/////////////////// Accessors ///////////////////////
101104
/////////////////////////////////////////////////////
@@ -153,6 +156,10 @@ public String getState() {
153156
return state;
154157
}
155158

159+
public Boolean isEncrypted() {
160+
return encrypted;
161+
}
162+
156163
/////////////////////////////////////////////////////
157164
/////////////// API Implementation///////////////////
158165
/////////////////////////////////////////////////////

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import java.util.Date;
2020
import java.util.List;
21+
import java.util.Set;
2122

2223
import com.cloud.hypervisor.Hypervisor.HypervisorType;
2324
import com.cloud.storage.ScopeType;

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,14 @@
1616
// under the License.
1717
package com.cloud.storage.dao;
1818

19+
import java.sql.Connection;
1920
import java.sql.PreparedStatement;
2021
import java.sql.ResultSet;
2122
import java.sql.SQLException;
2223
import java.util.ArrayList;
2324
import java.util.Collections;
2425
import java.util.Date;
26+
import java.util.HashSet;
2527
import java.util.List;
2628

2729
import javax.inject.Inject;
@@ -67,6 +69,7 @@ public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long> implements Vol
6769
protected final SearchBuilder<VolumeVO> RootDiskStateSearch;
6870
private final SearchBuilder<VolumeVO> storeAndInstallPathSearch;
6971
private final SearchBuilder<VolumeVO> volumeIdSearch;
72+
private final SearchBuilder<VolumeVO> encryptedIdSearch;
7073
protected GenericSearchBuilder<VolumeVO, Long> CountByAccount;
7174
protected GenericSearchBuilder<VolumeVO, SumCount> primaryStorageSearch;
7275
protected GenericSearchBuilder<VolumeVO, SumCount> primaryStorageSearch2;
@@ -489,6 +492,10 @@ public VolumeDaoImpl() {
489492
volumeIdSearch.and("idIN", volumeIdSearch.entity().getId(), Op.IN);
490493
volumeIdSearch.done();
491494

495+
encryptedIdSearch = createSearchBuilder();
496+
encryptedIdSearch.and("encryptionMethod", encryptedIdSearch.entity().getId(), Op.NNULL);
497+
encryptedIdSearch.done();
498+
492499
poolAndPathSearch = createSearchBuilder();
493500
poolAndPathSearch.and("poolId", poolAndPathSearch.entity().getPoolId(), Op.EQ);
494501
poolAndPathSearch.and("path", poolAndPathSearch.entity().getPath(), Op.EQ);

server/src/main/java/com/cloud/api/query/QueryManagerImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2396,7 +2396,7 @@ private Pair<List<VolumeJoinVO>, Integer> searchForVolumesInternal(ListVolumesCm
23962396
private Pair<List<Long>, Integer> searchForVolumeIdsAndCount(ListVolumesCmd cmd) {
23972397

23982398
Account caller = CallContext.current().getCallingAccount();
2399-
List<Long> permittedAccounts = new ArrayList<Long>();
2399+
List<Long> permittedAccounts = new ArrayList<>();
24002400

24012401
Long id = cmd.getId();
24022402
Long vmInstanceId = cmd.getVirtualMachineId();
@@ -2416,7 +2416,7 @@ private Pair<List<Long>, Integer> searchForVolumeIdsAndCount(ListVolumesCmd cmd)
24162416

24172417
List<Long> ids = getIdsListFromCmd(cmd.getId(), cmd.getIds());
24182418

2419-
Ternary<Long, Boolean, ListProjectResourcesCriteria> domainIdRecursiveListProject = new Ternary<Long, Boolean, ListProjectResourcesCriteria>(cmd.getDomainId(), cmd.isRecursive(), null);
2419+
Ternary<Long, Boolean, ListProjectResourcesCriteria> domainIdRecursiveListProject = new Ternary<>(cmd.getDomainId(), cmd.isRecursive(), null);
24202420
accountMgr.buildACLSearchParameters(caller, id, cmd.getAccountName(), cmd.getProjectId(), permittedAccounts, domainIdRecursiveListProject, cmd.listAll(), false);
24212421
Long domainId = domainIdRecursiveListProject.first();
24222422
Boolean isRecursive = domainIdRecursiveListProject.second();

0 commit comments

Comments
 (0)