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.

This commit is contained in:
Jessica Wang 2013-04-25 09:51:40 -07:00
parent 099677a124
commit ee02311fae
3 changed files with 37 additions and 2 deletions

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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",