mirror of https://github.com/apache/cloudstack.git
Added countIPs(long dcId, boolean onlyCountAllocated) to DataCenterIpAddressDao and DataCenterIpAddressDaoImpl.
This commit is contained in:
parent
45861fa1b7
commit
473f1937e2
|
|
@ -43,6 +43,8 @@ public interface DataCenterIpAddressDao extends GenericDao<DataCenterIpAddressVO
|
|||
|
||||
int countIPs(long podId, long dcId, boolean onlyCountAllocated);
|
||||
|
||||
int countIPs(long dcId, boolean onlyCountAllocated);
|
||||
|
||||
boolean deleteIpAddressByPod(long podId);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ public class DataCenterIpAddressDaoImpl extends GenericDaoBase<DataCenterIpAddre
|
|||
private final SearchBuilder<DataCenterIpAddressVO> AllFieldsSearch;
|
||||
private final GenericSearchBuilder<DataCenterIpAddressVO, Integer> AllIpCount;
|
||||
private final GenericSearchBuilder<DataCenterIpAddressVO, Integer> AllAllocatedIpCount;
|
||||
private final GenericSearchBuilder<DataCenterIpAddressVO, Integer> AllAllocatedIpCountForDc;
|
||||
|
||||
@Override
|
||||
@DB
|
||||
|
|
@ -221,6 +222,20 @@ public class DataCenterIpAddressDaoImpl extends GenericDaoBase<DataCenterIpAddre
|
|||
return count.get(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int countIPs(long dcId, boolean onlyCountAllocated) {
|
||||
SearchCriteria<Integer> sc;
|
||||
if (onlyCountAllocated) {
|
||||
sc = AllAllocatedIpCountForDc.create();
|
||||
} else {
|
||||
sc = AllIpCount.create();
|
||||
}
|
||||
|
||||
sc.setParameters("data_center_id", dcId);
|
||||
List<Integer> count = customSearch(sc, null);
|
||||
return count.get(0);
|
||||
}
|
||||
|
||||
public DataCenterIpAddressDaoImpl() {
|
||||
super();
|
||||
|
||||
|
|
@ -244,5 +259,11 @@ public class DataCenterIpAddressDaoImpl extends GenericDaoBase<DataCenterIpAddre
|
|||
AllAllocatedIpCount.and("pod", AllAllocatedIpCount.entity().getPodId(), SearchCriteria.Op.EQ);
|
||||
AllAllocatedIpCount.and("removed", AllAllocatedIpCount.entity().getTakenAt(), SearchCriteria.Op.NNULL);
|
||||
AllAllocatedIpCount.done();
|
||||
|
||||
AllAllocatedIpCountForDc = createSearchBuilder(Integer.class);
|
||||
AllAllocatedIpCountForDc.select(null, Func.COUNT, AllAllocatedIpCountForDc.entity().getId());
|
||||
AllAllocatedIpCountForDc.and("data_center_id", AllAllocatedIpCountForDc.entity().getDataCenterId(), SearchCriteria.Op.EQ);
|
||||
AllAllocatedIpCountForDc.and("removed", AllAllocatedIpCountForDc.entity().getTakenAt(), SearchCriteria.Op.NNULL);
|
||||
AllAllocatedIpCountForDc.done();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue