Updated Branches: refs/heads/master 45dbd9cdc -> 774b2ebf9
CLOUDSTACK-2120: mixed zone management - API: extend listSystemVMs 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/774b2ebf Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/774b2ebf Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/774b2ebf Branch: refs/heads/master Commit: 774b2ebf9d2faacde31973b35384cf0450865e9d Parents: 45dbd9c Author: Jessica Wang <jessica.w...@citrix.com> Authored: Sat Apr 27 11:41:53 2013 -0700 Committer: Jessica Wang <jessica.w...@citrix.com> Committed: Sat Apr 27 11:41:53 2013 -0700 ---------------------------------------------------------------------- .../command/admin/systemvm/ListSystemVMsCmd.java | 7 +++++++ .../src/com/cloud/server/ManagementServerImpl.java | 11 +++++++++++ 2 files changed, 18 insertions(+), 0 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/774b2ebf/api/src/org/apache/cloudstack/api/command/admin/systemvm/ListSystemVMsCmd.java ---------------------------------------------------------------------- diff --git a/api/src/org/apache/cloudstack/api/command/admin/systemvm/ListSystemVMsCmd.java b/api/src/org/apache/cloudstack/api/command/admin/systemvm/ListSystemVMsCmd.java index f230a20..b5a0f3f 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/systemvm/ListSystemVMsCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/systemvm/ListSystemVMsCmd.java @@ -74,6 +74,9 @@ public class ListSystemVMsCmd extends BaseListCmd { description="the storage ID where vm's volumes belong to", since="3.0.1") private Long storageId; + @Parameter(name=ApiConstants.ZONE_TYPE, type=CommandType.STRING, description="the network type of the zone that the virtual machine belongs to") + private String zoneType; + ///////////////////////////////////////////////////// /////////////////// Accessors /////////////////////// ///////////////////////////////////////////////////// @@ -110,6 +113,10 @@ public class ListSystemVMsCmd extends BaseListCmd { return storageId; } + public String getZoneType() { + return zoneType; + } + ///////////////////////////////////////////////////// /////////////// API Implementation/////////////////// ///////////////////////////////////////////////////// http://git-wip-us.apache.org/repos/asf/cloudstack/blob/774b2ebf/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 0da8d4f..050f57b 100755 --- a/server/src/com/cloud/server/ManagementServerImpl.java +++ b/server/src/com/cloud/server/ManagementServerImpl.java @@ -2640,6 +2640,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe public Pair<List<? extends VirtualMachine>, Integer> searchForSystemVm(ListSystemVMsCmd cmd) { String type = cmd.getSystemVmType(); Long zoneId = _accountMgr.checkAccessAndSpecifyAuthority(UserContext.current().getCaller(), cmd.getZoneId()); + String zoneType = cmd.getZoneType(); Long id = cmd.getId(); String name = cmd.getSystemVmName(); String state = cmd.getState(); @@ -2666,6 +2667,12 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe sb.join("volumeSearch", volumeSearch, sb.entity().getId(), volumeSearch.entity().getInstanceId(), JoinBuilder.JoinType.INNER); } + 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<VMInstanceVO> sc = sb.create(); if (keyword != null) { @@ -2706,6 +2713,10 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe sc.setJoinParameters("volumeSearch", "poolId", storageId); } + if(zoneType != null) { + sc.setJoinParameters("zoneSb", "zoneNetworkType", zoneType); + } + Pair<List<VMInstanceVO>, Integer> result = _vmInstanceDao.searchAndCount(sc, searchFilter); return new Pair<List<? extends VirtualMachine>, Integer>(result.first(), result.second()); }