Skip to content

Commit 07ec36b

Browse files
committed
list by isEncrypted
1 parent d5241d3 commit 07ec36b

5 files changed

Lines changed: 18 additions & 3 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
@@ -94,6 +94,9 @@ public class ListVolumesCmd extends BaseListRetrieveOnlyResourceCountCmd impleme
9494
@Parameter(name = ApiConstants.STATE, type = CommandType.STRING, description = "state of the volume. Possible values are: Ready, Allocated, Destroy, Expunging, Expunged.")
9595
private String state;
9696

97+
@Parameter(name = ApiConstants.IS_ENCRYPTED, type = CommandType.BOOLEAN, description = "list only volumes that are encrypted", since = "4.20",
98+
authorized = { RoleType.Admin })
99+
private Boolean encrypted;
97100
/////////////////////////////////////////////////////
98101
/////////////////// Accessors ///////////////////////
99102
/////////////////////////////////////////////////////
@@ -151,6 +154,10 @@ public String getState() {
151154
return state;
152155
}
153156

157+
public Boolean isEncrypted() {
158+
return encrypted;
159+
}
160+
154161
/////////////////////////////////////////////////////
155162
/////////////// API Implementation///////////////////
156163
/////////////////////////////////////////////////////

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

Lines changed: 1 addition & 1 deletion
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;
@@ -157,5 +158,4 @@ public interface VolumeDao extends GenericDao<VolumeVO, Long>, StateDao<Volume.S
157158
List<VolumeVO> listByIds(List<Long> ids);
158159

159160
List<VolumeVO> listAllocatedVolumesForAccountDiskOfferingIdsAndNotForVms(long accountId, List<Long> diskOfferingIds, List<Long> vmIds);
160-
161161
}

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
import java.util.stream.Collectors;
2729

@@ -71,6 +73,7 @@ public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long> implements Vol
7173
protected final SearchBuilder<VolumeVO> RootDiskStateSearch;
7274
private final SearchBuilder<VolumeVO> storeAndInstallPathSearch;
7375
private final SearchBuilder<VolumeVO> volumeIdSearch;
76+
private final SearchBuilder<VolumeVO> encryptedIdSearch;
7477
protected GenericSearchBuilder<VolumeVO, Long> CountByAccount;
7578
protected GenericSearchBuilder<VolumeVO, SumCount> primaryStorageSearch;
7679
protected GenericSearchBuilder<VolumeVO, SumCount> primaryStorageSearch2;
@@ -498,6 +501,10 @@ public VolumeDaoImpl() {
498501
volumeIdSearch.and("idIN", volumeIdSearch.entity().getId(), Op.IN);
499502
volumeIdSearch.done();
500503

504+
encryptedIdSearch = createSearchBuilder();
505+
encryptedIdSearch.and("encryptionMethod", encryptedIdSearch.entity().getId(), Op.NNULL);
506+
encryptedIdSearch.done();
507+
501508
poolAndPathSearch = createSearchBuilder();
502509
poolAndPathSearch.and("poolId", poolAndPathSearch.entity().getPoolId(), Op.EQ);
503510
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
@@ -2397,7 +2397,7 @@ private Pair<List<VolumeJoinVO>, Integer> searchForVolumesInternal(ListVolumesCm
23972397
private Pair<List<Long>, Integer> searchForVolumeIdsAndCount(ListVolumesCmd cmd) {
23982398

23992399
Account caller = CallContext.current().getCallingAccount();
2400-
List<Long> permittedAccounts = new ArrayList<Long>();
2400+
List<Long> permittedAccounts = new ArrayList<>();
24012401

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

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

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

0 commit comments

Comments
 (0)