mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
list by isEncrypted (#8643)
* list by isEncrypted * use filter on VO and cleanup * add encryption type to volume response * Update api/src/main/java/org/apache/cloudstack/api/command/user/volume/ListVolumesCmd.java Co-authored-by: Suresh Kumar Anaparti <sureshkumar.anaparti@gmail.com>
This commit is contained in:
parent
503ae64a3d
commit
4de975ff25
@ -263,6 +263,7 @@ public class ApiConstants {
|
||||
public static final String IS_CLEANUP_REQUIRED = "iscleanuprequired";
|
||||
public static final String IS_DYNAMIC = "isdynamic";
|
||||
public static final String IS_EDGE = "isedge";
|
||||
public static final String IS_ENCRYPTED = "isencrypted";
|
||||
public static final String IS_EXTRACTABLE = "isextractable";
|
||||
public static final String IS_FEATURED = "isfeatured";
|
||||
public static final String IS_PORTABLE = "isportable";
|
||||
|
||||
@ -96,6 +96,9 @@ public class ListVolumesCmd extends BaseListRetrieveOnlyResourceCountCmd impleme
|
||||
@Parameter(name = ApiConstants.STATE, type = CommandType.STRING, description = "state of the volume. Possible values are: Ready, Allocated, Destroy, Expunging, Expunged.")
|
||||
private String state;
|
||||
|
||||
@Parameter(name = ApiConstants.IS_ENCRYPTED, type = CommandType.BOOLEAN, description = "list only volumes that are encrypted", since = "4.19.1",
|
||||
authorized = { RoleType.Admin })
|
||||
private Boolean encrypted;
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
@ -153,6 +156,10 @@ public class ListVolumesCmd extends BaseListRetrieveOnlyResourceCountCmd impleme
|
||||
return state;
|
||||
}
|
||||
|
||||
public Boolean isEncrypted() {
|
||||
return encrypted;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@ -298,8 +298,8 @@ public class VolumeResponse extends BaseResponseWithTagInformation implements Co
|
||||
private Map<String, String> volumeRepairResult;
|
||||
|
||||
@SerializedName(ApiConstants.ENCRYPT_FORMAT)
|
||||
@Param(description = "the encrypt format of the volume", since = "4.19.1")
|
||||
private String encryptFormat;
|
||||
@Param(description = "the format of the disk encryption if applicable", since = "4.19.1")
|
||||
private String encryptionFormat;
|
||||
|
||||
public String getPath() {
|
||||
return path;
|
||||
@ -847,7 +847,7 @@ public class VolumeResponse extends BaseResponseWithTagInformation implements Co
|
||||
this.volumeRepairResult = volumeRepairResult;
|
||||
}
|
||||
|
||||
public void setEncryptFormat(String encryptFormat) {
|
||||
this.encryptFormat = encryptFormat;
|
||||
public void setEncryptionFormat(String encryptionFormat) {
|
||||
this.encryptionFormat = encryptionFormat;
|
||||
}
|
||||
}
|
||||
|
||||
@ -112,7 +112,8 @@ public interface VolumeDao extends GenericDao<VolumeVO, Long>, StateDao<Volume.S
|
||||
/**
|
||||
* Gets the Total Primary Storage space allocated for an account
|
||||
*
|
||||
* @param list of ids of virtual router VMs under this account
|
||||
* @param accountId
|
||||
* @param virtualRouters list of ids of virtual router VMs under this account
|
||||
* @return total Primary Storage space (in bytes) used
|
||||
*/
|
||||
long primaryStorageUsedForAccount(long accountId, List<Long> virtualRouters);
|
||||
|
||||
@ -75,7 +75,6 @@ public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long> implements Vol
|
||||
@Inject
|
||||
ResourceTagDao _tagsDao;
|
||||
|
||||
protected static final String SELECT_VM_SQL = "SELECT DISTINCT instance_id from volumes v where v.host_id = ? and v.mirror_state = ?";
|
||||
// need to account for zone-wide primary storage where storage_pool has
|
||||
// null-value pod and cluster, where hypervisor information is stored in
|
||||
// storage_pool
|
||||
|
||||
@ -2396,7 +2396,7 @@ public class QueryManagerImpl extends MutualExclusiveIdsManagerBase implements Q
|
||||
private Pair<List<Long>, Integer> searchForVolumeIdsAndCount(ListVolumesCmd cmd) {
|
||||
|
||||
Account caller = CallContext.current().getCallingAccount();
|
||||
List<Long> permittedAccounts = new ArrayList<Long>();
|
||||
List<Long> permittedAccounts = new ArrayList<>();
|
||||
|
||||
Long id = cmd.getId();
|
||||
Long vmInstanceId = cmd.getVirtualMachineId();
|
||||
@ -2416,7 +2416,7 @@ public class QueryManagerImpl extends MutualExclusiveIdsManagerBase implements Q
|
||||
|
||||
List<Long> ids = getIdsListFromCmd(cmd.getId(), cmd.getIds());
|
||||
|
||||
Ternary<Long, Boolean, ListProjectResourcesCriteria> domainIdRecursiveListProject = new Ternary<Long, Boolean, ListProjectResourcesCriteria>(cmd.getDomainId(), cmd.isRecursive(), null);
|
||||
Ternary<Long, Boolean, ListProjectResourcesCriteria> domainIdRecursiveListProject = new Ternary<>(cmd.getDomainId(), cmd.isRecursive(), null);
|
||||
accountMgr.buildACLSearchParameters(caller, id, cmd.getAccountName(), cmd.getProjectId(), permittedAccounts, domainIdRecursiveListProject, cmd.listAll(), false);
|
||||
Long domainId = domainIdRecursiveListProject.first();
|
||||
Boolean isRecursive = domainIdRecursiveListProject.second();
|
||||
@ -2436,6 +2436,13 @@ public class QueryManagerImpl extends MutualExclusiveIdsManagerBase implements Q
|
||||
volumeSearchBuilder.and("uuid", volumeSearchBuilder.entity().getUuid(), SearchCriteria.Op.NNULL);
|
||||
volumeSearchBuilder.and("instanceId", volumeSearchBuilder.entity().getInstanceId(), SearchCriteria.Op.EQ);
|
||||
volumeSearchBuilder.and("dataCenterId", volumeSearchBuilder.entity().getDataCenterId(), SearchCriteria.Op.EQ);
|
||||
if (cmd.isEncrypted() != null) {
|
||||
if (cmd.isEncrypted()) {
|
||||
volumeSearchBuilder.and("encryptFormat", volumeSearchBuilder.entity().getEncryptFormat(), SearchCriteria.Op.NNULL);
|
||||
} else {
|
||||
volumeSearchBuilder.and("encryptFormat", volumeSearchBuilder.entity().getEncryptFormat(), SearchCriteria.Op.NULL);
|
||||
}
|
||||
}
|
||||
|
||||
if (keyword != null) {
|
||||
volumeSearchBuilder.and().op("keywordName", volumeSearchBuilder.entity().getName(), SearchCriteria.Op.LIKE);
|
||||
|
||||
@ -180,7 +180,7 @@ public class VolumeJoinDaoImpl extends GenericDaoBaseWithTagInformation<VolumeJo
|
||||
|
||||
if (view == ResponseView.Full) {
|
||||
volResponse.setPath(volume.getPath());
|
||||
volResponse.setEncryptFormat(volume.getEncryptFormat());
|
||||
volResponse.setEncryptionFormat(volume.getEncryptionFormat());
|
||||
}
|
||||
|
||||
// populate owner.
|
||||
@ -279,6 +279,7 @@ public class VolumeJoinDaoImpl extends GenericDaoBaseWithTagInformation<VolumeJo
|
||||
|
||||
volResponse.setObjectName("volume");
|
||||
volResponse.setExternalUuid(volume.getExternalUuid());
|
||||
volResponse.setEncryptionFormat(volume.getEncryptionFormat());
|
||||
return volResponse;
|
||||
}
|
||||
|
||||
|
||||
@ -276,7 +276,7 @@ public class VolumeJoinVO extends BaseViewWithTagInformationVO implements Contro
|
||||
private String externalUuid = null;
|
||||
|
||||
@Column(name = "encrypt_format")
|
||||
private String encryptFormat;
|
||||
private String encryptionFormat = null;
|
||||
|
||||
public VolumeJoinVO() {
|
||||
}
|
||||
@ -613,13 +613,12 @@ public class VolumeJoinVO extends BaseViewWithTagInformationVO implements Contro
|
||||
this.externalUuid = externalUuid;
|
||||
}
|
||||
|
||||
public String getEncryptFormat() {
|
||||
return encryptFormat;
|
||||
public String getEncryptionFormat() {
|
||||
return encryptionFormat;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getEntityType() {
|
||||
return Volume.class;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user