Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 ///////////////////////
/////////////////////////////////////////////////////
Expand Down Expand Up @@ -153,6 +156,10 @@ public String getState() {
return state;
}

public Boolean isEncrypted() {
return encrypted;
}

/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -847,7 +847,7 @@ public void setVolumeRepairResult(Map<String, String> volumeRepairResult) {
this.volumeRepairResult = volumeRepairResult;
}

public void setEncryptFormat(String encryptFormat) {
this.encryptFormat = encryptFormat;
public void setEncryptionFormat(String encryptionFormat) {
this.encryptionFormat = encryptionFormat;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 9 additions & 2 deletions server/src/main/java/com/cloud/api/query/QueryManagerImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -2396,7 +2396,7 @@ private Pair<List<VolumeJoinVO>, Integer> searchForVolumesInternal(ListVolumesCm
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();
Expand All @@ -2416,7 +2416,7 @@ private Pair<List<Long>, Integer> searchForVolumeIdsAndCount(ListVolumesCmd cmd)

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();
Expand All @@ -2436,6 +2436,13 @@ private Pair<List<Long>, Integer> searchForVolumeIdsAndCount(ListVolumesCmd cmd)
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public VolumeResponse newVolumeResponse(ResponseView view, VolumeJoinVO volume)

if (view == ResponseView.Full) {
volResponse.setPath(volume.getPath());
volResponse.setEncryptFormat(volume.getEncryptFormat());
volResponse.setEncryptionFormat(volume.getEncryptionFormat());
}

// populate owner.
Expand Down Expand Up @@ -279,6 +279,7 @@ public VolumeResponse newVolumeResponse(ResponseView view, VolumeJoinVO volume)

volResponse.setObjectName("volume");
volResponse.setExternalUuid(volume.getExternalUuid());
volResponse.setEncryptionFormat(volume.getEncryptionFormat());
return volResponse;
}

Expand Down
7 changes: 3 additions & 4 deletions server/src/main/java/com/cloud/api/query/vo/VolumeJoinVO.java
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
}
Expand Down Expand Up @@ -613,13 +613,12 @@ public void setExternalUuid(String externalUuid) {
this.externalUuid = externalUuid;
}

public String getEncryptFormat() {
return encryptFormat;
public String getEncryptionFormat() {
return encryptionFormat;
}

@Override
public Class<?> getEntityType() {
return Volume.class;
}

}