You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by wi...@apache.org on 2015/09/23 14:00:13 UTC

[3/9] git commit: updated refs/heads/master to a0f8f56

Added countIPs(long dcId, boolean onlyCountAllocated) to DataCenterIpAddressDao and DataCenterIpAddressDaoImpl.


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/473f1937
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/473f1937
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/473f1937

Branch: refs/heads/master
Commit: 473f1937e2c13bc7cca0b42c7585fe16accf7415
Parents: 45861fa
Author: Boris Schrijver <bo...@pcextreme.nl>
Authored: Wed Sep 16 22:15:00 2015 +0200
Committer: Boris Schrijver <bo...@pcextreme.nl>
Committed: Wed Sep 16 22:15:00 2015 +0200

----------------------------------------------------------------------
 .../cloud/dc/dao/DataCenterIpAddressDao.java    |  2 ++
 .../dc/dao/DataCenterIpAddressDaoImpl.java      | 21 ++++++++++++++++++++
 2 files changed, 23 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/473f1937/engine/schema/src/com/cloud/dc/dao/DataCenterIpAddressDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/dc/dao/DataCenterIpAddressDao.java b/engine/schema/src/com/cloud/dc/dao/DataCenterIpAddressDao.java
index 7f1ec4d..e5843b6 100644
--- a/engine/schema/src/com/cloud/dc/dao/DataCenterIpAddressDao.java
+++ b/engine/schema/src/com/cloud/dc/dao/DataCenterIpAddressDao.java
@@ -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);
 
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/473f1937/engine/schema/src/com/cloud/dc/dao/DataCenterIpAddressDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/dc/dao/DataCenterIpAddressDaoImpl.java b/engine/schema/src/com/cloud/dc/dao/DataCenterIpAddressDaoImpl.java
index ca79eed..cf68322 100644
--- a/engine/schema/src/com/cloud/dc/dao/DataCenterIpAddressDaoImpl.java
+++ b/engine/schema/src/com/cloud/dc/dao/DataCenterIpAddressDaoImpl.java
@@ -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();
     }
 }