incubator-cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From prachida...@apache.org
Subject [1/2] git commit: refs/heads/4.1 - CLOUDSTACK-1117 [EC2 Query API] DescribeImageAttribute fails
Date Fri, 08 Feb 2013 02:26:04 GMT
CLOUDSTACK-1117 [EC2 Query API] DescribeImageAttribute fails

EC2DescribeImageAttribute fails with 'Unsupported - only description supported' error. And
this is observed for both the supported attributes 'Description' and 'LaunchPermission'


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

Branch: refs/heads/4.1
Commit: b97f468b0361b7dcb339f8748dcbff3a77d67950
Parents: c92f1f9
Author: Likitha Shetty <Likitha.Shetty@citrix.com>
Authored: Thu Feb 7 17:52:48 2013 -0800
Committer: Prachi Damle <prachi@cloud.com>
Committed: Thu Feb 7 18:25:11 2013 -0800

----------------------------------------------------------------------
 .../com/cloud/bridge/service/EC2RestServlet.java   |   33 ++++++++++-----
 1 files changed, 22 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/b97f468b/awsapi/src/com/cloud/bridge/service/EC2RestServlet.java
----------------------------------------------------------------------
diff --git a/awsapi/src/com/cloud/bridge/service/EC2RestServlet.java b/awsapi/src/com/cloud/bridge/service/EC2RestServlet.java
index 4612b60..c3a86a0 100644
--- a/awsapi/src/com/cloud/bridge/service/EC2RestServlet.java
+++ b/awsapi/src/com/cloud/bridge/service/EC2RestServlet.java
@@ -113,6 +113,7 @@ import com.cloud.bridge.service.core.ec2.EC2CreateVolume;
 import com.cloud.bridge.service.core.ec2.EC2DeleteKeyPair;
 import com.cloud.bridge.service.core.ec2.EC2DescribeAddresses;
 import com.cloud.bridge.service.core.ec2.EC2DescribeAvailabilityZones;
+import com.cloud.bridge.service.core.ec2.EC2DescribeImageAttribute;
 import com.cloud.bridge.service.core.ec2.EC2DescribeImages;
 import com.cloud.bridge.service.core.ec2.EC2DescribeInstances;
 import com.cloud.bridge.service.core.ec2.EC2DescribeKeyPairs;
@@ -1311,25 +1312,35 @@ public class EC2RestServlet extends HttpServlet {
 
     private void describeImageAttribute( HttpServletRequest request, HttpServletResponse
response ) 
             throws ADBException, XMLStreamException, IOException {
-        EC2DescribeImages EC2request = new EC2DescribeImages();
+        EC2DescribeImageAttribute ec2request = new EC2DescribeImageAttribute();
 
-        // -> only works for queries about descriptions
-        String[] descriptions = request.getParameterValues( "Description" );
-        if ( null != descriptions && 0 < descriptions.length ) {
-            String[] value = request.getParameterValues( "ImageId" );
-            EC2request.addImageSet( value[0] );
-        }	
+        String[] imageId = request.getParameterValues( "ImageId" );
+        if (imageId != null && imageId.length > 0)
+            ec2request.setImageId(imageId[0]);
         else {
-            response.sendError(501, "Unsupported - only description supported" ); 
+            response.sendError(530, "Missing ImageId parameter");
             return;
         }
 
-        // -> execute the request
-        DescribeImageAttributeResponse EC2response = EC2SoapServiceImpl.toDescribeImageAttributeResponse(
ServiceProvider.getInstance().getEC2Engine().describeImages( EC2request ));
+        String[] attribute = request.getParameterValues( "Attribute" );
+        if (attribute != null && attribute.length > 0) {
+            if (attribute[0].equalsIgnoreCase("description"))
+                ec2request.setAttribute(ImageAttribute.description);
+            else if (attribute[0].equalsIgnoreCase("launchPermission"))
+                ec2request.setAttribute(ImageAttribute.launchPermission);
+            else {
+                response.sendError(501, "Unsupported Attribute - description and launchPermission
supported" );
+                return;
+            }
+        } else {
+            response.sendError(530, "Missing Attribute parameter");
+            return;
+        }
+
+        DescribeImageAttributeResponse EC2response = EC2SoapServiceImpl.toDescribeImageAttributeResponse(
ServiceProvider.getInstance().getEC2Engine().describeImageAttribute( ec2request ));
         serializeResponse(response, EC2response);
     }
 
-
     private void describeInstances( HttpServletRequest request, HttpServletResponse response
) 
             throws ADBException, XMLStreamException, IOException 
             {


Mime
View raw message