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:22 UTC
[44/50] [abbrv] git commit: updated refs/heads/marvin_refactor to
7c439fe
CLOUDSTACK-2120: mixed zone management - API: extend listClusters 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/ef00f1b0
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/ef00f1b0
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/ef00f1b0
Branch: refs/heads/marvin_refactor
Commit: ef00f1b04f8d9e4f7ea981c3174ae9f4a84d4a58
Parents: 271f875
Author: Jessica Wang <je...@citrix.com>
Authored: Sat Apr 27 21:38:03 2013 -0700
Committer: Jessica Wang <je...@citrix.com>
Committed: Sat Apr 27 21:38:03 2013 -0700
----------------------------------------------------------------------
.../api/command/admin/cluster/ListClustersCmd.java | 8 ++-
.../src/com/cloud/server/ManagementServerImpl.java | 47 +++++++++++----
2 files changed, 41 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ef00f1b0/api/src/org/apache/cloudstack/api/command/admin/cluster/ListClustersCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/cluster/ListClustersCmd.java b/api/src/org/apache/cloudstack/api/command/admin/cluster/ListClustersCmd.java
index 0417b18..f2dd349 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/cluster/ListClustersCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/cluster/ListClustersCmd.java
@@ -70,6 +70,9 @@ public class ListClustersCmd extends BaseListCmd {
@Parameter(name=ApiConstants.MANAGED_STATE, type=CommandType.STRING, description="whether this cluster is managed by cloudstack")
private String managedState;
+ @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 clusters")
private Boolean showCapacities;
@@ -114,7 +117,10 @@ public class ListClustersCmd extends BaseListCmd {
this.managedState = managedstate;
}
-
+ public String getZoneType() {
+ return zoneType;
+ }
+
public Boolean getShowCapacities() {
return showCapacities;
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ef00f1b0/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 5db8329..1799f77 100755
--- a/server/src/com/cloud/server/ManagementServerImpl.java
+++ b/server/src/com/cloud/server/ManagementServerImpl.java
@@ -616,48 +616,69 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
@Override
public Pair<List<? extends Cluster>, Integer> searchForClusters(ListClustersCmd cmd) {
- Filter searchFilter = new Filter(ClusterVO.class, "id", true, cmd.getStartIndex(), cmd.getPageSizeVal());
- SearchCriteria<ClusterVO> sc = _clusterDao.createSearchCriteria();
-
- Object id = cmd.getId();
+ Object id = cmd.getId();
Object name = cmd.getClusterName();
Object podId = cmd.getPodId();
Long zoneId = cmd.getZoneId();
Object hypervisorType = cmd.getHypervisorType();
Object clusterType = cmd.getClusterType();
Object allocationState = cmd.getAllocationState();
+ String zoneType = cmd.getZoneType();
String keyword = cmd.getKeyword();
-
zoneId = _accountMgr.checkAccessAndSpecifyAuthority(UserContext.current().getCaller(), zoneId);
-
+
+
+ Filter searchFilter = new Filter(ClusterVO.class, "id", true, cmd.getStartIndex(), cmd.getPageSizeVal());
+
+ SearchBuilder<ClusterVO> sb = _clusterDao.createSearchBuilder();
+ sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ);
+ sb.and("name", sb.entity().getName(), SearchCriteria.Op.LIKE);
+ sb.and("podId", sb.entity().getPodId(), SearchCriteria.Op.EQ);
+ sb.and("dataCenterId", sb.entity().getDataCenterId(), SearchCriteria.Op.EQ);
+ sb.and("hypervisorType", sb.entity().getHypervisorType(), SearchCriteria.Op.EQ);
+ sb.and("clusterType", sb.entity().getClusterType(), 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<ClusterVO> sc = sb.create();
if (id != null) {
- sc.addAnd("id", SearchCriteria.Op.EQ, id);
+ sc.setParameters("id", id);
}
if (name != null) {
- sc.addAnd("name", SearchCriteria.Op.LIKE, "%" + name + "%");
+ sc.setParameters("name", "%" + name + "%");
}
if (podId != null) {
- sc.addAnd("podId", SearchCriteria.Op.EQ, podId);
+ sc.setParameters("podId", podId);
}
if (zoneId != null) {
- sc.addAnd("dataCenterId", SearchCriteria.Op.EQ, zoneId);
+ sc.setParameters("dataCenterId", zoneId);
}
if (hypervisorType != null) {
- sc.addAnd("hypervisorType", SearchCriteria.Op.EQ, hypervisorType);
+ sc.setParameters("hypervisorType", hypervisorType);
}
if (clusterType != null) {
- sc.addAnd("clusterType", SearchCriteria.Op.EQ, clusterType);
+ sc.setParameters("clusterType", clusterType);
}
if (allocationState != null) {
- sc.addAnd("allocationState", SearchCriteria.Op.EQ, allocationState);
+ sc.setParameters("allocationState", allocationState);
}
+ if(zoneType != null) {
+ sc.setJoinParameters("zoneSb", "zoneNetworkType", zoneType);
+ }
+
if (keyword != null) {
SearchCriteria<ClusterVO> ssc = _clusterDao.createSearchCriteria();
ssc.addOr("name", SearchCriteria.Op.LIKE, "%" + keyword + "%");