You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ni...@apache.org on 2013/06/12 10:07:21 UTC

git commit: updated refs/heads/master to 215b638

Updated Branches:
  refs/heads/master e73aafc09 -> 215b638e8


CLOUDSTACK-2347:  Zone filter for listSnapshots API

Added new optional parameter zone id in listSnapshots API which allows to list snapshots with additional criteria.
   Signed off by :- Nitin Mehta <ni...@citrix.com>


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/215b638e
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/215b638e
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/215b638e

Branch: refs/heads/master
Commit: 215b638e8eb22fd433ebdc396d4b7a38b0f6796a
Parents: e73aafc
Author: Harikrishna Patnala <ha...@citrix.com>
Authored: Wed Jun 12 13:35:16 2013 +0530
Committer: Nitin Mehta <ni...@citrix.com>
Committed: Wed Jun 12 13:35:58 2013 +0530

----------------------------------------------------------------------
 .../api/command/user/snapshot/ListSnapshotsCmd.java          | 8 ++++++++
 .../org/apache/cloudstack/api/response/SnapshotResponse.java | 7 +++++++
 server/src/com/cloud/api/ApiResponseHelper.java              | 3 ++-
 .../src/com/cloud/storage/snapshot/SnapshotManagerImpl.java  | 6 ++++++
 4 files changed, 23 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/215b638e/api/src/org/apache/cloudstack/api/command/user/snapshot/ListSnapshotsCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/snapshot/ListSnapshotsCmd.java b/api/src/org/apache/cloudstack/api/command/user/snapshot/ListSnapshotsCmd.java
index d7e6bc8..e4ae769 100644
--- a/api/src/org/apache/cloudstack/api/command/user/snapshot/ListSnapshotsCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/snapshot/ListSnapshotsCmd.java
@@ -26,6 +26,7 @@ import org.apache.cloudstack.api.Parameter;
 import org.apache.cloudstack.api.response.ListResponse;
 import org.apache.cloudstack.api.response.SnapshotResponse;
 import org.apache.cloudstack.api.response.VolumeResponse;
+import org.apache.cloudstack.api.response.ZoneResponse;
 import org.apache.log4j.Logger;
 
 import com.cloud.async.AsyncJob;
@@ -62,6 +63,9 @@ public class ListSnapshotsCmd extends BaseListTaggedResourcesCmd {
     @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.ZONE_ID, type = CommandType.UUID, entityType = ZoneResponse.class, description = "list snapshots by zone id")
+    private Long zoneId;
+
     /////////////////////////////////////////////////////
     /////////////////// Accessors ///////////////////////
     /////////////////////////////////////////////////////
@@ -89,6 +93,10 @@ public class ListSnapshotsCmd extends BaseListTaggedResourcesCmd {
     public String getZoneType() {
         return zoneType;
     }
+
+    public Long getZoneId() {
+        return zoneId;
+    }
     
     /////////////////////////////////////////////////////
     /////////////// API Implementation///////////////////

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/215b638e/api/src/org/apache/cloudstack/api/response/SnapshotResponse.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/response/SnapshotResponse.java b/api/src/org/apache/cloudstack/api/response/SnapshotResponse.java
index 7484ac9..ca74a18 100644
--- a/api/src/org/apache/cloudstack/api/response/SnapshotResponse.java
+++ b/api/src/org/apache/cloudstack/api/response/SnapshotResponse.java
@@ -93,6 +93,10 @@ public class SnapshotResponse extends BaseResponse implements ControlledEntityRe
     @Param(description = "the state of the snapshot. BackedUp means that snapshot is ready to be used; Creating - the snapshot is being allocated on the primary storage; BackingUp - the snapshot is being backed up on secondary storage")
     private Snapshot.State state;
 
+    @SerializedName(ApiConstants.ZONE_ID)
+    @Param(description = "id of the availability zone")
+    private String zoneId;
+
     @SerializedName(ApiConstants.ZONE_NAME)
     @Param(description = "name of the availability zone")
     private String zoneName;
@@ -181,6 +185,9 @@ public class SnapshotResponse extends BaseResponse implements ControlledEntityRe
         this.projectName = projectName;
     }
 
+    public void setZoneId(String zoneId) {
+        this.zoneId = zoneId;
+    }
     public void setZoneName(String zoneName) {
         this.zoneName = zoneName;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/215b638e/server/src/com/cloud/api/ApiResponseHelper.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiResponseHelper.java b/server/src/com/cloud/api/ApiResponseHelper.java
index 0c98abc..4f75b99 100755
--- a/server/src/com/cloud/api/ApiResponseHelper.java
+++ b/server/src/com/cloud/api/ApiResponseHelper.java
@@ -439,7 +439,8 @@ public class ApiResponseHelper implements ResponseGenerator {
             DataCenter zone = ApiDBUtils.findZoneById(volume.getDataCenterId());
             if (zone != null) {
             	snapshotResponse.setZoneName(zone.getName());
-            	snapshotResponse.setZoneType(zone.getNetworkType().toString());                
+            	snapshotResponse.setZoneType(zone.getNetworkType().toString());
+                snapshotResponse.setZoneId(zone.getUuid());
             }
         }
         snapshotResponse.setCreated(snapshot.getCreated());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/215b638e/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java b/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java
index 92d80ee..02e3428 100755
--- a/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java
+++ b/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java
@@ -574,6 +574,7 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
         String intervalTypeStr = cmd.getIntervalType();
         String zoneType = cmd.getZoneType();
         Map<String, String> tags = cmd.getTags();
+        Long zoneId = cmd.getZoneId();
         
         Account caller = UserContext.current().getCaller();
         List<Long> permittedAccounts = new ArrayList<Long>();
@@ -602,6 +603,7 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
         sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ);
         sb.and("snapshotTypeEQ", sb.entity().getsnapshotType(), SearchCriteria.Op.IN);
         sb.and("snapshotTypeNEQ", sb.entity().getsnapshotType(), SearchCriteria.Op.NEQ);
+        sb.and("dataCenterId", sb.entity().getDataCenterId(), SearchCriteria.Op.EQ);
         
         if (tags != null && !tags.isEmpty()) {
             SearchBuilder<ResourceTagVO> tagSearch = _resourceTagDao.createSearchBuilder();
@@ -641,6 +643,10 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
         if(zoneType != null) {
             sc.setJoinParameters("zoneSb", "zoneNetworkType", zoneType);          
         }
+
+        if (zoneId != null) {
+            sc.setParameters("dataCenterId", zoneId);
+        }
         
         if (name != null) {
             sc.setParameters("name", "%" + name + "%");