Updated Branches: refs/heads/master 099677a12 -> ee02311fa
CLOUDSTACK-2120: mixed zone management - (1) extend listHosts API to to take in zonetype. (2) UI: populate Hosts/SecondaryStorages list page with ones whose zonetype matches selected option in zone type dropdown on top menu. Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/ee02311f Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/ee02311f Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/ee02311f Branch: refs/heads/master Commit: ee02311fae2b8991ed1dc13e58d8dbe627262a8d Parents: 099677a Author: Jessica Wang <jessicaw...@apache.org> Authored: Thu Apr 25 09:51:40 2013 -0700 Committer: Jessica Wang <jessicaw...@apache.org> Committed: Thu Apr 25 09:51:57 2013 -0700 ---------------------------------------------------------------------- .../api/command/admin/host/ListHostsCmd.java | 7 ++++ .../src/com/cloud/api/query/QueryManagerImpl.java | 5 +++ ui/scripts/system.js | 27 +++++++++++++- 3 files changed, 37 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ee02311f/api/src/org/apache/cloudstack/api/command/admin/host/ListHostsCmd.java ---------------------------------------------------------------------- diff --git a/api/src/org/apache/cloudstack/api/command/admin/host/ListHostsCmd.java b/api/src/org/apache/cloudstack/api/command/admin/host/ListHostsCmd.java index 5ec7cf3..69c6980 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/host/ListHostsCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/host/ListHostsCmd.java @@ -75,6 +75,9 @@ public class ListHostsCmd extends BaseListCmd { description="the Zone ID for the host") private Long zoneId; + @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.VIRTUAL_MACHINE_ID, type=CommandType.UUID, entityType = UserVmResponse.class, required=false, description="lists hosts in the same cluster as this VM and flag hosts with enough CPU/RAm to host this VM") private Long virtualMachineId; @@ -124,6 +127,10 @@ public class ListHostsCmd extends BaseListCmd { return zoneId; } + public String getZoneType() { + return zoneType; + } + public Long getVirtualMachineId() { return virtualMachineId; } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ee02311f/server/src/com/cloud/api/query/QueryManagerImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/api/query/QueryManagerImpl.java b/server/src/com/cloud/api/query/QueryManagerImpl.java index 6690b24..f92b4fc 100644 --- a/server/src/com/cloud/api/query/QueryManagerImpl.java +++ b/server/src/com/cloud/api/query/QueryManagerImpl.java @@ -1400,6 +1400,7 @@ public class QueryManagerImpl extends ManagerBase implements QueryService { public Pair<List<HostJoinVO>, Integer> searchForServersInternal(ListHostsCmd cmd) { Long zoneId = _accountMgr.checkAccessAndSpecifyAuthority(UserContext.current().getCaller(), cmd.getZoneId()); + String zoneType = cmd.getZoneType(); Object name = cmd.getHostName(); Object type = cmd.getType(); Object state = cmd.getState(); @@ -1421,6 +1422,7 @@ public class QueryManagerImpl extends ManagerBase implements QueryService { sb.and("type", sb.entity().getType(), SearchCriteria.Op.LIKE); sb.and("status", sb.entity().getStatus(), SearchCriteria.Op.EQ); sb.and("dataCenterId", sb.entity().getZoneId(), SearchCriteria.Op.EQ); + sb.and("dataCenterType", sb.entity().getZoneType(), SearchCriteria.Op.EQ); sb.and("podId", sb.entity().getPodId(), SearchCriteria.Op.EQ); sb.and("clusterId", sb.entity().getClusterId(), SearchCriteria.Op.EQ); sb.and("resourceState", sb.entity().getResourceState(), SearchCriteria.Op.EQ); @@ -1465,6 +1467,9 @@ public class QueryManagerImpl extends ManagerBase implements QueryService { if (zoneId != null) { sc.setParameters("dataCenterId", zoneId); } + if (zoneType != null) { + sc.setParameters("dataCenterType", zoneType); + } if (pod != null) { sc.setParameters("podId", pod); } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ee02311f/ui/scripts/system.js ---------------------------------------------------------------------- diff --git a/ui/scripts/system.js b/ui/scripts/system.js index 8f07ee4..3aaa830 100644 --- a/ui/scripts/system.js +++ b/ui/scripts/system.js @@ -5534,9 +5534,16 @@ var searchByArgs = args.filterBy.search.value.length ? '&name=' + args.filterBy.search.value : ''; + var data = { page: args.page, pageSize: pageSize, type: 'routing', listAll: true }; + if(args.context.zoneType != null && args.context.zoneType.length > 0) { //Basic type or Advanced type + $.extend(data, { + zonetype: args.context.zoneType + }); + } + $.ajax({ url: createURL('listHosts' + searchByArgs), - data: { page: args.page, pageSize: pageSize, type: 'routing', listAll: true }, + data: data, success: function (json) { args.response.success({ data: json.listhostsresponse.host }); }, @@ -5628,9 +5635,16 @@ var searchByArgs = args.filterBy.search.value.length ? '&name=' + args.filterBy.search.value : ''; + var data = { type: 'SecondaryStorage', page: args.page, pageSize: pageSize, listAll: true }; + if(args.context.zoneType != null && args.context.zoneType.length > 0) { //Basic type or Advanced type + $.extend(data, { + zonetype: args.context.zoneType + }); + } + $.ajax({ url: createURL('listHosts' + searchByArgs), - data: { type: 'SecondaryStorage', page: args.page, pageSize: pageSize, listAll: true }, + data: data, success: function (json) { args.response.success({ data: json.listhostsresponse.host }); }, @@ -8909,6 +8923,10 @@ array1.push("&hostid=" + args.context.instances[0].hostid); } + if(args.context.zoneType != null && args.context.zoneType.length > 0) { //Basic type or Advanced type + array1.push("&zonetype=" + args.context.zoneType); + } + $.ajax({ url: createURL("listHosts&type=Routing" + array1.join("") + "&page=" + args.page + "&pagesize=" + pageSize), dataType: "json", @@ -10515,6 +10533,11 @@ } } array1.push("&zoneid=" + args.context.zones[0].id); + + if(args.context.zoneType != null && args.context.zoneType.length > 0) { //Basic type or Advanced type + array1.push("&zonetype=" + args.context.zoneType); + } + $.ajax({ url: createURL("listHosts&type=SecondaryStorage&page=" + args.page + "&pagesize=" + pageSize + array1.join("")), dataType: "json",