From d893ba881b6ea00de00910a0d5f259b1397e16de Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Wed, 24 Apr 2013 11:26:43 -0700 Subject: [PATCH] CLOUDSTACK-2120: mixed zone management - (1) extend listVolumes API to to take in zonetype. (2) UI: populate Volumes list page with instances whose zonetype matches selected option in zone type dropdown on top menu. --- .../cloudstack/api/command/user/vm/ListVMsCmd.java | 3 +-- .../api/command/user/volume/ListVolumesCmd.java | 7 +++++++ server/src/com/cloud/api/query/QueryManagerImpl.java | 5 +++++ ui/scripts/storage.js | 12 +++++++++--- 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/api/src/org/apache/cloudstack/api/command/user/vm/ListVMsCmd.java b/api/src/org/apache/cloudstack/api/command/user/vm/ListVMsCmd.java index d93d65708b4..b2a2ce071f1 100644 --- a/api/src/org/apache/cloudstack/api/command/user/vm/ListVMsCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/vm/ListVMsCmd.java @@ -75,8 +75,7 @@ public class ListVMsCmd extends BaseListTaggedResourcesCmd { @Parameter(name=ApiConstants.STATE, type=CommandType.STRING, description="state of the virtual machine") private String state; - @Parameter(name=ApiConstants.ZONE_ID, type=CommandType.UUID, entityType=ZoneResponse.class, - description="the availability zone ID") + @Parameter(name=ApiConstants.ZONE_ID, type=CommandType.UUID, entityType=ZoneResponse.class, description="the availability zone ID") private Long zoneId; @Parameter(name=ApiConstants.ZONE_TYPE, type=CommandType.STRING, description="the network type of the zone that the virtual machine belongs to") diff --git a/api/src/org/apache/cloudstack/api/command/user/volume/ListVolumesCmd.java b/api/src/org/apache/cloudstack/api/command/user/volume/ListVolumesCmd.java index 4c78eedeb08..91316b02167 100644 --- a/api/src/org/apache/cloudstack/api/command/user/volume/ListVolumesCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/volume/ListVolumesCmd.java @@ -67,6 +67,9 @@ public class ListVolumesCmd extends BaseListTaggedResourcesCmd { description="the ID of the availability zone") 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; + ///////////////////////////////////////////////////// /////////////////// Accessors /////////////////////// ///////////////////////////////////////////////////// @@ -100,6 +103,10 @@ public class ListVolumesCmd extends BaseListTaggedResourcesCmd { return zoneId; } + public String getZoneType() { + return zoneType; + } + ///////////////////////////////////////////////////// /////////////// API Implementation/////////////////// ///////////////////////////////////////////////////// diff --git a/server/src/com/cloud/api/query/QueryManagerImpl.java b/server/src/com/cloud/api/query/QueryManagerImpl.java index d0b42378340..ea260c37a89 100644 --- a/server/src/com/cloud/api/query/QueryManagerImpl.java +++ b/server/src/com/cloud/api/query/QueryManagerImpl.java @@ -1522,6 +1522,7 @@ public class QueryManagerImpl extends ManagerBase implements QueryService { Map tags = cmd.getTags(); Long zoneId = cmd.getZoneId(); + String zoneType = cmd.getZoneType(); Long podId = null; if (_accountMgr.isAdmin(caller.getType())) { podId = cmd.getPodId(); @@ -1549,6 +1550,7 @@ public class QueryManagerImpl extends ManagerBase implements QueryService { sb.and("volumeType", sb.entity().getVolumeType(), SearchCriteria.Op.LIKE); sb.and("instanceId", sb.entity().getVmId(), SearchCriteria.Op.EQ); sb.and("dataCenterId", sb.entity().getDataCenterId(), SearchCriteria.Op.EQ); + sb.and("dataCenterType", sb.entity().getDataCenterType(), SearchCriteria.Op.EQ); sb.and("podId", sb.entity().getPodId(), SearchCriteria.Op.EQ); // Only return volumes that are not destroyed sb.and("state", sb.entity().getState(), SearchCriteria.Op.NEQ); @@ -1608,6 +1610,9 @@ public class QueryManagerImpl extends ManagerBase implements QueryService { if (zoneId != null) { sc.setParameters("dataCenterId", zoneId); } + if (zoneType != null) { + sc.setParameters("dataCenterType", zoneType); + } if (podId != null) { sc.setParameters("podId", podId); } diff --git a/ui/scripts/storage.js b/ui/scripts/storage.js index 1acc9c792e4..cf4076945ac 100644 --- a/ui/scripts/storage.js +++ b/ui/scripts/storage.js @@ -398,12 +398,18 @@ if(args.context != null) { if("instances" in args.context) { - $.extend(data, { - virtualMachineId: args.context.instances[0].id - }); + $.extend(data, { + virtualMachineId: args.context.instances[0].id + }); } } + if(args.context.zoneType != null && args.context.zoneType.length > 0) { //Basic type or Advanced type + $.extend(data, { + zonetype: args.context.zoneType + }); + } + $.ajax({ url: createURL('listVolumes'), data: data,