Skip to content

Commit 225d9e5

Browse files
committed
use filter on VO and cleanup
1 parent f39f287 commit 225d9e5

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
import java.util.Date;
2020
import java.util.List;
21-
import java.util.Set;
2221

2322
import com.cloud.hypervisor.Hypervisor.HypervisorType;
2423
import com.cloud.storage.ScopeType;
@@ -113,7 +112,8 @@ public interface VolumeDao extends GenericDao<VolumeVO, Long>, StateDao<Volume.S
113112
/**
114113
* Gets the Total Primary Storage space allocated for an account
115114
*
116-
* @param list of ids of virtual router VMs under this account
115+
* @param accountId
116+
* @param virtualRouters list of ids of virtual router VMs under this account
117117
* @return total Primary Storage space (in bytes) used
118118
*/
119119
long primaryStorageUsedForAccount(long accountId, List<Long> virtualRouters);

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

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

19-
import java.sql.Connection;
2019
import java.sql.PreparedStatement;
2120
import java.sql.ResultSet;
2221
import java.sql.SQLException;
2322
import java.util.ArrayList;
2423
import java.util.Collections;
2524
import java.util.Date;
26-
import java.util.HashSet;
2725
import java.util.List;
2826
import java.util.stream.Collectors;
2927

@@ -73,7 +71,6 @@ public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long> implements Vol
7371
protected final SearchBuilder<VolumeVO> RootDiskStateSearch;
7472
private final SearchBuilder<VolumeVO> storeAndInstallPathSearch;
7573
private final SearchBuilder<VolumeVO> volumeIdSearch;
76-
private final SearchBuilder<VolumeVO> encryptedIdSearch;
7774
protected GenericSearchBuilder<VolumeVO, Long> CountByAccount;
7875
protected GenericSearchBuilder<VolumeVO, SumCount> primaryStorageSearch;
7976
protected GenericSearchBuilder<VolumeVO, SumCount> primaryStorageSearch2;
@@ -84,7 +81,6 @@ public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long> implements Vol
8481
@Inject
8582
ResourceTagDao _tagsDao;
8683

87-
protected static final String SELECT_VM_SQL = "SELECT DISTINCT instance_id from volumes v where v.host_id = ? and v.mirror_state = ?";
8884
// need to account for zone-wide primary storage where storage_pool has
8985
// null-value pod and cluster, where hypervisor information is stored in
9086
// storage_pool
@@ -501,10 +497,6 @@ public VolumeDaoImpl() {
501497
volumeIdSearch.and("idIN", volumeIdSearch.entity().getId(), Op.IN);
502498
volumeIdSearch.done();
503499

504-
encryptedIdSearch = createSearchBuilder();
505-
encryptedIdSearch.and("encryptionMethod", encryptedIdSearch.entity().getId(), Op.NNULL);
506-
encryptedIdSearch.done();
507-
508500
poolAndPathSearch = createSearchBuilder();
509501
poolAndPathSearch.and("poolId", poolAndPathSearch.entity().getPoolId(), Op.EQ);
510502
poolAndPathSearch.and("path", poolAndPathSearch.entity().getPath(), Op.EQ);

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2437,6 +2437,13 @@ private Pair<List<Long>, Integer> searchForVolumeIdsAndCount(ListVolumesCmd cmd)
24372437
volumeSearchBuilder.and("uuid", volumeSearchBuilder.entity().getUuid(), SearchCriteria.Op.NNULL);
24382438
volumeSearchBuilder.and("instanceId", volumeSearchBuilder.entity().getInstanceId(), SearchCriteria.Op.EQ);
24392439
volumeSearchBuilder.and("dataCenterId", volumeSearchBuilder.entity().getDataCenterId(), SearchCriteria.Op.EQ);
2440+
if (cmd.isEncrypted() != null) {
2441+
if (cmd.isEncrypted()) {
2442+
volumeSearchBuilder.and("encryptFormat", volumeSearchBuilder.entity().getEncryptFormat(), SearchCriteria.Op.NNULL);
2443+
} else {
2444+
volumeSearchBuilder.and("encryptFormat", volumeSearchBuilder.entity().getEncryptFormat(), SearchCriteria.Op.NULL);
2445+
}
2446+
}
24402447

24412448
if (keyword != null) {
24422449
volumeSearchBuilder.and().op("keywordName", volumeSearchBuilder.entity().getName(), SearchCriteria.Op.LIKE);

0 commit comments

Comments
 (0)