incubator-cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From prachida...@apache.org
Subject git commit: refs/heads/master - CLOUDSTACK-1134: [EC2 Query API] DescribeSnapshots, 'n' ListVolumes get fired on CS for displaying 'n' Snapshots taken from the same Volume
Date Thu, 14 Feb 2013 01:54:43 GMT
Updated Branches:
  refs/heads/master 35cf56862 -> f0086df0c


CLOUDSTACK-1134: [EC2 Query API] DescribeSnapshots, 'n' ListVolumes get fired on CS for displaying
'n' Snapshots taken from the same Volume

For snapshots taken from the same volume re-use the response obtained by calling listVolumes


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

Branch: refs/heads/master
Commit: f0086df0c79ac0b68a1ddce1797ae1a90b3ea995
Parents: 35cf568
Author: Likitha Shetty <Likitha.Shetty@citrix.com>
Authored: Wed Feb 13 17:51:55 2013 -0800
Committer: Prachi Damle <prachi@cloud.com>
Committed: Wed Feb 13 17:54:23 2013 -0800

----------------------------------------------------------------------
 .../cloud/bridge/service/EC2SoapServiceImpl.java   |    5 ++-
 .../cloud/bridge/service/core/ec2/EC2Engine.java   |   29 +++++++++++----
 2 files changed, 25 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f0086df0/awsapi/src/com/cloud/bridge/service/EC2SoapServiceImpl.java
----------------------------------------------------------------------
diff --git a/awsapi/src/com/cloud/bridge/service/EC2SoapServiceImpl.java b/awsapi/src/com/cloud/bridge/service/EC2SoapServiceImpl.java
index 9fc581b..cebac0b 100644
--- a/awsapi/src/com/cloud/bridge/service/EC2SoapServiceImpl.java
+++ b/awsapi/src/com/cloud/bridge/service/EC2SoapServiceImpl.java
@@ -1905,7 +1905,10 @@ public class EC2SoapServiceImpl implements AmazonEC2SkeletonInterface
 {
 	         param3.setStartTime( cal );
 	         
 	         param3.setOwnerId(ownerId);
-	         param3.setVolumeSize( snap.getVolumeSize().toString());
+             if ( snap.getVolumeSize() == null )
+                 param3.setVolumeSize("0");
+             else
+                 param3.setVolumeSize( snap.getVolumeSize().toString() );
 	         param3.setDescription( snap.getName());
 	         param3.setOwnerAlias( snap.getAccountName() );
 	         

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f0086df0/awsapi/src/com/cloud/bridge/service/core/ec2/EC2Engine.java
----------------------------------------------------------------------
diff --git a/awsapi/src/com/cloud/bridge/service/core/ec2/EC2Engine.java b/awsapi/src/com/cloud/bridge/service/core/ec2/EC2Engine.java
index a835d8a..281ecbd 100644
--- a/awsapi/src/com/cloud/bridge/service/core/ec2/EC2Engine.java
+++ b/awsapi/src/com/cloud/bridge/service/core/ec2/EC2Engine.java
@@ -25,9 +25,12 @@ import java.security.SignatureException;
 import java.sql.SQLException;
 import java.text.ParseException;
 import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
+import java.util.Set;
 import java.util.UUID;
 
 import javax.inject.Inject;
@@ -443,25 +446,35 @@ public class EC2Engine extends ManagerBase {
      */
     public EC2DescribeSnapshotsResponse handleRequest( EC2DescribeSnapshots request ) 
     {
-        EC2DescribeVolumesResponse volumes = new EC2DescribeVolumesResponse();
         EC2SnapshotFilterSet sfs = request.getFilterSet();
         EC2TagKeyValue[] tagKeyValueSet = request.getResourceTagSet();
 
         try { 
-            // -> query to get the volume size for each snapshot
             EC2DescribeSnapshotsResponse response = listSnapshots( request.getSnapshotSet(),
                     getResourceTags(tagKeyValueSet));
             if (response == null) {
                 return new EC2DescribeSnapshotsResponse();
             }
             EC2Snapshot[] snapshots = response.getSnapshotSet();
-            for (EC2Snapshot snap : snapshots) {
-                volumes = listVolumes(snap.getVolumeId(), null, volumes, null);
-                EC2Volume[] volSet = volumes.getVolumeSet();
-                if (0 < volSet.length) snap.setVolumeSize(volSet[0].getSize());
-                volumes.reset();
+            // -> query to get the volume size for each snapshot
+            HashMap<String, Long> volumeIdSize = new HashMap<String, Long>();
+            for( EC2Snapshot snap : snapshots ) {
+                Boolean duplicateVolume = false;
+                Long size = null;
+                if ( volumeIdSize.containsKey(snap.getVolumeId()) ) {
+                    size = volumeIdSize.get(snap.getVolumeId());
+                    duplicateVolume = true;
+                    break;
+                }
+                if ( !duplicateVolume ) {
+                    EC2DescribeVolumesResponse volumes = new EC2DescribeVolumesResponse();
+                    volumes = listVolumes(snap.getVolumeId(), null, volumes, null);
+                    EC2Volume[] volumeSet = volumes.getVolumeSet();
+                    if (volumeSet.length > 0) size = volumeSet[0].getSize();
+                    volumeIdSize.put(snap.getVolumeId(), size);
+                }
+                snap.setVolumeSize(size);
             }
-
             if ( null == sfs )
                 return response;
             else return sfs.evaluate( response );


Mime
View raw message