mirror of https://github.com/apache/cloudstack.git
Added countIPs(long dcId, boolean onlyCountAllocated) to IPAddressDao and IPAddressDaoImpl.
This commit is contained in:
parent
473f1937e2
commit
12fc2b4c26
|
|
@ -40,6 +40,8 @@ public interface IPAddressDao extends GenericDao<IPAddressVO, Long> {
|
|||
|
||||
List<IPAddressVO> listStaticNatPublicIps(long networkId);
|
||||
|
||||
int countIPs(long dcId, boolean onlyCountAllocated);
|
||||
|
||||
int countIPs(long dcId, long vlanDbId, boolean onlyCountAllocated);
|
||||
|
||||
int countIPs(long dcId, Long accountId, String vlanId, String vlanGateway, String vlanNetmask);
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@ public class IPAddressDaoImpl extends GenericDaoBase<IPAddressVO, Long> implemen
|
|||
protected SearchBuilder<IPAddressVO> VlanDbIdSearchUnallocated;
|
||||
protected GenericSearchBuilder<IPAddressVO, Integer> AllIpCount;
|
||||
protected GenericSearchBuilder<IPAddressVO, Integer> AllocatedIpCount;
|
||||
protected GenericSearchBuilder<IPAddressVO, Integer> AllocatedIpCountForDc;
|
||||
protected GenericSearchBuilder<IPAddressVO, Integer> AllIpCountForDashboard;
|
||||
protected SearchBuilder<IPAddressVO> DeleteAllExceptGivenIp;
|
||||
protected GenericSearchBuilder<IPAddressVO, Long> AllocatedIpCountForAccount;
|
||||
|
|
@ -107,6 +108,12 @@ public class IPAddressDaoImpl extends GenericDaoBase<IPAddressVO, Long> implemen
|
|||
AllocatedIpCount.and("allocated", AllocatedIpCount.entity().getAllocatedTime(), Op.NNULL);
|
||||
AllocatedIpCount.done();
|
||||
|
||||
AllocatedIpCountForDc = createSearchBuilder(Integer.class);
|
||||
AllocatedIpCountForDc.select(null, Func.COUNT, AllocatedIpCountForDc.entity().getAddress());
|
||||
AllocatedIpCountForDc.and("dc", AllocatedIpCountForDc.entity().getDataCenterId(), Op.EQ);
|
||||
AllocatedIpCountForDc.and("allocated", AllocatedIpCountForDc.entity().getAllocatedTime(), Op.NNULL);
|
||||
AllocatedIpCountForDc.done();
|
||||
|
||||
AllIpCountForDashboard = createSearchBuilder(Integer.class);
|
||||
AllIpCountForDashboard.select(null, Func.COUNT, AllIpCountForDashboard.entity().getAddress());
|
||||
AllIpCountForDashboard.and("dc", AllIpCountForDashboard.entity().getDataCenterId(), Op.EQ);
|
||||
|
|
@ -281,6 +288,14 @@ public class IPAddressDaoImpl extends GenericDaoBase<IPAddressVO, Long> implemen
|
|||
return findOneBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int countIPs(long dcId, boolean onlyCountAllocated) {
|
||||
SearchCriteria<Integer> sc = onlyCountAllocated ? AllocatedIpCount.create() : AllIpCount.create();
|
||||
sc.setParameters("dc", dcId);
|
||||
|
||||
return customSearch(sc, null).get(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int countIPs(long dcId, long vlanId, boolean onlyCountAllocated) {
|
||||
SearchCriteria<Integer> sc = onlyCountAllocated ? AllocatedIpCount.create() : AllIpCount.create();
|
||||
|
|
|
|||
Loading…
Reference in New Issue