You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ts...@apache.org on 2013/04/29 15:14:21 UTC

[43/50] [abbrv] git commit: updated refs/heads/marvin_refactor to 7c439fe

CLOUDSTACK-2120: mixed zone management - API: extend listPods API to to take in zonetype.


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

Branch: refs/heads/marvin_refactor
Commit: 271f8759be06a6a150809f454b469d2301c25d1b
Parents: 2ec28ce
Author: Jessica Wang <je...@citrix.com>
Authored: Sat Apr 27 18:29:46 2013 -0700
Committer: Jessica Wang <je...@citrix.com>
Committed: Sat Apr 27 18:30:21 2013 -0700

----------------------------------------------------------------------
 .../api/command/admin/pod/ListPodsByCmd.java       |    7 +++
 .../src/com/cloud/server/ManagementServerImpl.java |   42 ++++++++++-----
 2 files changed, 36 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/271f8759/api/src/org/apache/cloudstack/api/command/admin/pod/ListPodsByCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/pod/ListPodsByCmd.java b/api/src/org/apache/cloudstack/api/command/admin/pod/ListPodsByCmd.java
index 3dace42..db233ae 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/pod/ListPodsByCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/pod/ListPodsByCmd.java
@@ -55,6 +55,9 @@ public class ListPodsByCmd extends BaseListCmd {
     @Parameter(name=ApiConstants.ALLOCATION_STATE, type=CommandType.STRING, description="list pods by allocation state")
     private String allocationState;
 
+    @Parameter(name=ApiConstants.ZONE_TYPE, type=CommandType.STRING, description="the network type of the zone that the virtual machine belongs to")
+    private String zoneType;
+    
     @Parameter(name=ApiConstants.SHOW_CAPACITIES, type=CommandType.BOOLEAN, description="flag to display the capacity of the pods")
     private Boolean showCapacities;
 
@@ -78,6 +81,10 @@ public class ListPodsByCmd extends BaseListCmd {
         return allocationState;
     }
 
+    public String getZoneType() {
+        return zoneType;
+    }
+    
     public Boolean getShowCapacities() {
         return showCapacities;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/271f8759/server/src/com/cloud/server/ManagementServerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/server/ManagementServerImpl.java b/server/src/com/cloud/server/ManagementServerImpl.java
index 050f57b..5db8329 100755
--- a/server/src/com/cloud/server/ManagementServerImpl.java
+++ b/server/src/com/cloud/server/ManagementServerImpl.java
@@ -1068,17 +1068,29 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
 
     @Override
     public Pair<List<? extends Pod>, Integer> searchForPods(ListPodsByCmd cmd) {
-        Filter searchFilter = new Filter(HostPodVO.class, "dataCenterId", true, cmd.getStartIndex(), cmd.getPageSizeVal());
-        SearchCriteria<HostPodVO> sc = _hostPodDao.createSearchCriteria();
-
         String podName = cmd.getPodName();
         Long id = cmd.getId();
-        Long zoneId = cmd.getZoneId();
+        Long zoneId = cmd.getZoneId();        
         Object keyword = cmd.getKeyword();
         Object allocationState = cmd.getAllocationState();
-
+        String zoneType = cmd.getZoneType();
         zoneId = _accountMgr.checkAccessAndSpecifyAuthority(UserContext.current().getCaller(), zoneId);
 
+    	
+    	Filter searchFilter = new Filter(HostPodVO.class, "dataCenterId", true, cmd.getStartIndex(), cmd.getPageSizeVal());
+        SearchBuilder<HostPodVO> sb = _hostPodDao.createSearchBuilder();        
+        sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ);
+        sb.and("name", sb.entity().getName(), SearchCriteria.Op.LIKE);          
+        sb.and("dataCenterId", sb.entity().getDataCenterId(), SearchCriteria.Op.EQ);         
+        sb.and("allocationState", sb.entity().getAllocationState(), SearchCriteria.Op.EQ);
+        
+        if(zoneType != null) {
+            SearchBuilder<DataCenterVO> zoneSb = _dcDao.createSearchBuilder();
+            zoneSb.and("zoneNetworkType", zoneSb.entity().getNetworkType(), SearchCriteria.Op.EQ);    
+            sb.join("zoneSb", zoneSb, sb.entity().getDataCenterId(), zoneSb.entity().getId(), JoinBuilder.JoinType.INNER);
+        }
+               
+        SearchCriteria<HostPodVO> sc = sb.create();
         if (keyword != null) {
             SearchCriteria<HostPodVO> ssc = _hostPodDao.createSearchCriteria();
             ssc.addOr("name", SearchCriteria.Op.LIKE, "%" + keyword + "%");
@@ -1088,21 +1100,25 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
         }
 
         if (id != null) {
-            sc.addAnd("id", SearchCriteria.Op.EQ, id);
+            sc.setParameters("id", id);
         }
-
+        
         if (podName != null) {
-            sc.addAnd("name", SearchCriteria.Op.LIKE, "%" + podName + "%");
+            sc.setParameters("name", "%" + podName + "%");
         }
-
+        
         if (zoneId != null) {
-            sc.addAnd("dataCenterId", SearchCriteria.Op.EQ, zoneId);
+            sc.setParameters("dataCenterId", zoneId);
         }
-
+        
         if (allocationState != null) {
-            sc.addAnd("allocationState", SearchCriteria.Op.EQ, allocationState);
+            sc.setParameters("allocationState", allocationState);
+        }        
+    
+        if(zoneType != null) {
+            sc.setJoinParameters("zoneSb", "zoneNetworkType", zoneType);          
         }
-
+        
         Pair<List<HostPodVO>, Integer> result = _hostPodDao.searchAndCount(sc, searchFilter);
         return new Pair<List<? extends Pod>, Integer>(result.first(), result.second());
     }