cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wid...@apache.org
Subject [34/50] [abbrv] git commit: updated refs/heads/rbd-snap-clone to 2355a81
Date Thu, 23 May 2013 21:20:09 GMT
CLOUDSTACK-2623. Provide appropriate AWS EC2 error codes in error thrown by CS AWSAPI. Since CS has very few generic errorcode groups, in AWSAPI parse the response message and translate the CS error to AWS EC2 error code.
Provide support for the following error codes -
AuthFailure, DependencyViolation, IncorrectState, InvalidAMIID.NotFound, InvalidAttachment.NotFound, InvalidDevice.InUse, InvalidFilter, InvalidGroup.Duplicate, InvalidGroup.InUse, InvalidGroup.NotFound
InvalidInstanceID.NotFound, InvalidKeyPair.Duplicate, InvalidKeyPair.Format, InvalidKeyPair.NotFound, InvalidParameterCombinatio, InvalidParameterValue, InvalidPermission.Duplicate, InvalidPermission.Malformed
InvalidSnapshot.NotFound, InvalidVolume.NotFound, InvalidVolumeID.Duplicate, InvalidZone.NotFound, MissingParameter, UnsupportedOperation, SignatureDoesNotMatch, InternalError, AddressLimitExceeded, InstanceLimitExceeded
VolumeLimitExceeded, Unavailable, ResourceLimitExceeded

CLOUDSTACK-2624. Support ModifyInstanceAttribute API in AWSAPI.
2 AWS instance attributes will be supported, 'InstanceType' and 'UserData'
As per AWS EC2, to modify both the attributes, the instance must be stopped. If not throw 'IncorrectInstanceState' error


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

Branch: refs/heads/rbd-snap-clone
Commit: 9a33fd181ffb9d3220edefd1f8d928915b09028a
Parents: 85ff507
Author: Likitha Shetty <likitha.shetty@citrix.com>
Authored: Wed May 22 16:33:08 2013 +0530
Committer: Likitha Shetty <likitha.shetty@citrix.com>
Committed: Wed May 22 18:17:11 2013 +0530

----------------------------------------------------------------------
 .../com/cloud/bridge/service/EC2MainServlet.java   |    2 +-
 .../com/cloud/bridge/service/EC2RestServlet.java   |  338 +++++---
 .../cloud/bridge/service/EC2SoapServiceImpl.java   |   87 +-
 .../service/core/ec2/EC2AddressFilterSet.java      |   16 +-
 .../core/ec2/EC2AvailabilityZonesFilterSet.java    |    9 +-
 .../cloud/bridge/service/core/ec2/EC2Engine.java   |  717 ++++++++++-----
 .../bridge/service/core/ec2/EC2GroupFilterSet.java |    9 +-
 .../bridge/service/core/ec2/EC2ImageFilterSet.java |    8 +-
 .../service/core/ec2/EC2InstanceFilterSet.java     |    8 +-
 .../service/core/ec2/EC2KeyPairFilterSet.java      |   16 +-
 .../core/ec2/EC2ModifyInstanceAttribute.java       |   64 ++
 .../bridge/service/core/ec2/EC2RegisterImage.java  |    5 +-
 .../service/core/ec2/EC2SnapshotFilterSet.java     |   10 +-
 .../bridge/service/core/ec2/EC2TagsFilterSet.java  |    9 +-
 .../service/core/ec2/EC2VolumeFilterSet.java       |    9 +-
 .../service/exception/EC2ServiceException.java     |  120 ++--
 awsapi/src/com/cloud/stack/CloudStackClient.java   |    5 +-
 17 files changed, 928 insertions(+), 504 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9a33fd18/awsapi/src/com/cloud/bridge/service/EC2MainServlet.java
----------------------------------------------------------------------
diff --git a/awsapi/src/com/cloud/bridge/service/EC2MainServlet.java b/awsapi/src/com/cloud/bridge/service/EC2MainServlet.java
index 8361f6e..4cf5f88 100644
--- a/awsapi/src/com/cloud/bridge/service/EC2MainServlet.java
+++ b/awsapi/src/com/cloud/bridge/service/EC2MainServlet.java
@@ -94,7 +94,7 @@ public class EC2MainServlet extends HttpServlet{
         if(!isEC2APIEnabled){
             //response.sendError(404, "EC2 API is disabled.");
             response.setStatus(404);
-            faultResponse(response, "404" , "EC2 API is disabled.");
+            faultResponse(response, "Unavailable" , "EC2 API is disabled");
             return;
         }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9a33fd18/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 83645a3..40cabb6 100644
--- a/awsapi/src/com/cloud/bridge/service/EC2RestServlet.java
+++ b/awsapi/src/com/cloud/bridge/service/EC2RestServlet.java
@@ -39,7 +39,6 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
-import java.util.Set;
 import java.util.UUID;
 
 import javax.inject.Inject;
@@ -92,10 +91,9 @@ import com.amazon.ec2.DescribeVolumesResponse;
 import com.amazon.ec2.DetachVolumeResponse;
 import com.amazon.ec2.DisassociateAddressResponse;
 import com.amazon.ec2.GetPasswordDataResponse;
-import com.amazon.ec2.GroupItemType;
 import com.amazon.ec2.ImportKeyPairResponse;
-import com.amazon.ec2.LaunchPermissionItemType;
 import com.amazon.ec2.ModifyImageAttributeResponse;
+import com.amazon.ec2.ModifyInstanceAttributeResponse;
 import com.amazon.ec2.RebootInstancesResponse;
 import com.amazon.ec2.RegisterImageResponse;
 import com.amazon.ec2.ReleaseAddressResponse;
@@ -105,9 +103,7 @@ import com.amazon.ec2.RunInstancesResponse;
 import com.amazon.ec2.StartInstancesResponse;
 import com.amazon.ec2.StopInstancesResponse;
 import com.amazon.ec2.TerminateInstancesResponse;
-import com.cloud.bridge.model.CloudStackUserVO;
 import com.cloud.bridge.model.UserCredentialsVO;
-import com.cloud.bridge.persist.dao.CloudStackConfigurationDao;
 import com.cloud.bridge.persist.dao.CloudStackUserDaoImpl;
 import com.cloud.bridge.persist.dao.OfferingDaoImpl;
 import com.cloud.bridge.persist.dao.UserCredentialsDaoImpl;
@@ -143,6 +139,7 @@ import com.cloud.bridge.service.core.ec2.EC2InstanceFilterSet;
 import com.cloud.bridge.service.core.ec2.EC2IpPermission;
 import com.cloud.bridge.service.core.ec2.EC2KeyPairFilterSet;
 import com.cloud.bridge.service.core.ec2.EC2ModifyImageAttribute;
+import com.cloud.bridge.service.core.ec2.EC2ModifyInstanceAttribute;
 import com.cloud.bridge.service.core.ec2.EC2RebootInstances;
 import com.cloud.bridge.service.core.ec2.EC2RegisterImage;
 import com.cloud.bridge.service.core.ec2.EC2ReleaseAddress;
@@ -151,8 +148,6 @@ import com.cloud.bridge.service.core.ec2.EC2SecurityGroup;
 import com.cloud.bridge.service.core.ec2.EC2SnapshotFilterSet;
 import com.cloud.bridge.service.core.ec2.EC2StartInstances;
 import com.cloud.bridge.service.core.ec2.EC2StopInstances;
-import com.cloud.bridge.service.core.ec2.EC2TagKeyValue;
-import com.cloud.bridge.service.core.ec2.EC2TagTypeId;
 import com.cloud.bridge.service.core.ec2.EC2Tags;
 import com.cloud.bridge.service.core.ec2.EC2TagsFilterSet;
 import com.cloud.bridge.service.core.ec2.EC2Volume;
@@ -289,6 +284,7 @@ public class EC2RestServlet extends HttpServlet {
             else if (action.equalsIgnoreCase( "DetachVolume"              )) detachVolume(request, response);  
             else if (action.equalsIgnoreCase( "DisassociateAddress"       )) disassociateAddress(request, response);
             else if (action.equalsIgnoreCase( "ModifyImageAttribute"      )) modifyImageAttribute(request, response);  
+            else if (action.equalsIgnoreCase( "ModifyInstanceAttribute"   )) modifyInstanceAttribute(request, response);
             else if (action.equalsIgnoreCase( "RebootInstances"           )) rebootInstances(request, response);  
             else if (action.equalsIgnoreCase( "RegisterImage"             )) registerImage(request, response);  
             else if (action.equalsIgnoreCase( "ReleaseAddress"            )) releaseAddress(request, response);
@@ -318,8 +314,14 @@ public class EC2RestServlet extends HttpServlet {
         } catch( EC2ServiceException e ) {
             response.setStatus(e.getErrorCode());
 
-            if (e.getCause() != null && e.getCause() instanceof AxisFault)
-                faultResponse(response, ((AxisFault)e.getCause()).getFaultCode().getLocalPart(), e.getMessage());
+            if (e.getCause() != null && e.getCause() instanceof AxisFault) {
+                String errorCode = ((AxisFault)e.getCause()).getFaultCode().getLocalPart();
+                if (errorCode.startsWith("Client.")) // only in a SOAP API client error code is prefixed with Client.
+                    errorCode = errorCode.split("Client.")[1];
+                else if (errorCode.startsWith("Server.")) // only in a SOAP API server error code is prefixed with Server.
+                    errorCode = errorCode.split("Server.")[1];
+                faultResponse(response, errorCode, e.getMessage());
+            }
             else {
                 logger.error("EC2ServiceException: " + e.getMessage(), e);
                 endResponse(response, e.toString());
@@ -395,11 +397,6 @@ public class EC2RestServlet extends HttpServlet {
             endResponse(response, "SetUserKeys exception " + e.getMessage());
             return;
         }
-
-        // prime UserContext here
-//    	logger.debug("initializing context");
-        UserContext context = UserContext.current();
-
         try {
             txn = Transaction.open(Transaction.AWSAPI_DB);
             // -> use the keys to see if the account actually exists
@@ -681,17 +678,23 @@ public class EC2RestServlet extends HttpServlet {
         String[] volumeId = request.getParameterValues( "VolumeId" );
         if ( null != volumeId && 0 < volumeId.length ) 
             EC2request.setId( volumeId[0] );
-        else { response.sendError(530, "Missing VolumeId parameter" ); return; }
+        else {
+            throw new EC2ServiceException( ClientError.MissingParamter, "Missing required parameter - VolumeId");
+        }
 
         String[] instanceId = request.getParameterValues( "InstanceId" );
         if ( null != instanceId && 0 < instanceId.length ) 
             EC2request.setInstanceId( instanceId[0] );
-        else { response.sendError(530, "Missing InstanceId parameter" ); return; }
+        else {
+            throw new EC2ServiceException( ClientError.MissingParamter, "Missing required parameter - InstanceId");
+        }
 
         String[] device = request.getParameterValues( "Device" );
         if ( null != device && 0 < device.length ) 
             EC2request.setDevice( device[0] );
-        else { response.sendError(530, "Missing Device parameter" ); return; }
+        else {
+            throw new EC2ServiceException( ClientError.MissingParamter, "Missing required parameter - Device");
+        }
 
         // -> execute the request
         AttachVolumeResponse EC2response = EC2SoapServiceImpl.toAttachVolumeResponse( ServiceProvider.getInstance().getEC2Engine().attachVolume( EC2request ));
@@ -709,7 +712,9 @@ public class EC2RestServlet extends HttpServlet {
         String[] groupName = request.getParameterValues( "GroupName" );
         if ( null != groupName && 0 < groupName.length ) 
             EC2request.setName( groupName[0] );
-        else { response.sendError(530, "Missing GroupName parameter" ); return; }
+        else {
+            throw new EC2ServiceException( ClientError.MissingParamter, "Missing required parameter - GroupName");
+        }
 
         // -> not clear how many parameters there are until we fail to get IpPermissions.n.IpProtocol
         int nCount = 1, mCount;
@@ -772,8 +777,7 @@ public class EC2RestServlet extends HttpServlet {
         } while( true );
 
         if (1 == nCount) {
-            response.sendError(530, "At least one IpPermissions required" );
-            return; 		
+            throw new EC2ServiceException( ClientError.MissingParamter, "Missing required parameter - IpPermissions");
         }
 
         // -> execute the request
@@ -790,7 +794,9 @@ public class EC2RestServlet extends HttpServlet {
         String[] groupName = request.getParameterValues( "GroupName" );
         if ( null != groupName && 0 < groupName.length ) 
             EC2request.setName( groupName[0] );
-        else { response.sendError(530, "Missing GroupName parameter" ); return; }
+        else {
+            throw new EC2ServiceException( ClientError.MissingParamter, "Missing required parameter 'Groupname'");
+        }
 
         // -> not clear how many parameters there are until we fail to get IpPermissions.n.IpProtocol
         int nCount = 1;
@@ -852,8 +858,9 @@ public class EC2RestServlet extends HttpServlet {
 
         } while( true );
 
-        if (1 == nCount) { response.sendError(530, "At least one IpPermissions required" ); return; }
-
+        if (1 == nCount) {
+            throw new EC2ServiceException( ClientError.MissingParamter, "Missing required parameter - IpPermissions");
+        }
 
         // -> execute the request
         AuthorizeSecurityGroupIngressResponse EC2response = EC2SoapServiceImpl.toAuthorizeSecurityGroupIngressResponse( 
@@ -868,7 +875,9 @@ public class EC2RestServlet extends HttpServlet {
         String[] volumeId = request.getParameterValues( "VolumeId" );
         if ( null != volumeId && 0 < volumeId.length ) 
             EC2request.setId(volumeId[0]);
-        else { response.sendError(530, "Missing VolumeId parameter" ); return; }
+        else {
+            throw new EC2ServiceException( ClientError.MissingParamter, "Missing required parameter 'VolumeId'");
+        }
 
         String[] instanceId = request.getParameterValues( "InstanceId" );
         if ( null != instanceId && 0 < instanceId.length ) 
@@ -890,7 +899,9 @@ public class EC2RestServlet extends HttpServlet {
         String[] volumeId = request.getParameterValues( "VolumeId" );
         if ( null != volumeId && 0 < volumeId.length ) 
             EC2request.setId(volumeId[0]);
-        else { response.sendError(530, "Missing VolumeId parameter" ); return; }
+        else {
+            throw new EC2ServiceException( ClientError.MissingParamter, "Missing required parameter - VolumeId");
+        }
 
         // -> execute the request
         DeleteVolumeResponse EC2response = EC2SoapServiceImpl.toDeleteVolumeResponse( ServiceProvider.getInstance().getEC2Engine().deleteVolume( EC2request ));
@@ -904,7 +915,9 @@ public class EC2RestServlet extends HttpServlet {
         String[] zoneName = request.getParameterValues( "AvailabilityZone" );
         if ( null != zoneName && 0 < zoneName.length ) 
             EC2request.setZoneName( zoneName[0] );
-        else { response.sendError(530, "Missing AvailabilityZone parameter" ); return; }
+        else {
+            throw new EC2ServiceException( ClientError.MissingParamter, "Missing parameter - AvailabilityZone");
+        }
 
         String[] size = request.getParameterValues( "Size" );
         String[] snapshotId = request.getParameterValues("SnapshotId");
@@ -922,9 +935,9 @@ public class EC2RestServlet extends HttpServlet {
         } else if (useSnapshot && !useSize) {
             EC2request.setSnapshotId(snapshotId[0]);
         } else if (useSize && useSnapshot) {
-            response.sendError(530, "Size and SnapshotId parameters are mutually exclusive" ); return;
+            throw new EC2ServiceException( ClientError.InvalidParameterCombination, "Parameters 'Size' and 'SnapshotId' are mutually exclusive");
         } else {
-            response.sendError(530, "Size or SnapshotId has to be specified" ); return;
+            throw new EC2ServiceException( ClientError.MissingParamter, "Parameter 'Size' or 'SnapshotId' has to be specified");
         }
 
 
@@ -941,12 +954,15 @@ public class EC2RestServlet extends HttpServlet {
         String[] name = request.getParameterValues( "GroupName" );
         if ( null != name && 0 < name.length ) 
             groupName = name[0];
-        else { response.sendError(530, "Missing GroupName parameter" ); return; }
-
+        else {
+            throw new EC2ServiceException( ClientError.MissingParamter, "Missing required parameter - GroupName");
+        }
         String[] desc = request.getParameterValues( "GroupDescription" );
         if ( null != desc && 0 < desc.length ) 
             groupDescription = desc[0];
-        else { response.sendError(530, "Missing GroupDescription parameter" ); return; }
+        else {
+            throw new EC2ServiceException( ClientError.MissingParamter, "Missing required parameter - GroupDescription");
+        }
 
         // -> execute the request
         CreateSecurityGroupResponse EC2response = EC2SoapServiceImpl.toCreateSecurityGroupResponse( ServiceProvider.getInstance().getEC2Engine().createSecurityGroup( groupName, groupDescription ));
@@ -960,7 +976,9 @@ public class EC2RestServlet extends HttpServlet {
         String[] name = request.getParameterValues( "GroupName" );
         if ( null != name && 0 < name.length ) 
             groupName = name[0];
-        else { response.sendError(530, "Missing GroupName parameter" ); return; }
+        else {
+            throw new EC2ServiceException( ClientError.MissingParamter, "Missing required parameter - GroupName");
+        }
 
         // -> execute the request
         DeleteSecurityGroupResponse EC2response = EC2SoapServiceImpl.toDeleteSecurityGroupResponse( ServiceProvider.getInstance().getEC2Engine().deleteSecurityGroup( groupName ));
@@ -974,7 +992,9 @@ public class EC2RestServlet extends HttpServlet {
         String[] snapSet = request.getParameterValues( "SnapshotId" );
         if ( null != snapSet && 0 < snapSet.length ) 
             snapshotId = snapSet[0];
-        else { response.sendError(530, "Missing SnapshotId parameter" ); return; }
+        else {
+            throw new EC2ServiceException( ClientError.MissingParamter, "Missing required parameter - SnapshotId");
+        }
 
         // -> execute the request
         DeleteSnapshotResponse EC2response = EC2SoapServiceImpl.toDeleteSnapshotResponse( ServiceProvider.getInstance().getEC2Engine().deleteSnapshot( snapshotId ));
@@ -988,7 +1008,9 @@ public class EC2RestServlet extends HttpServlet {
         String[] volSet = request.getParameterValues( "VolumeId" );
         if ( null != volSet && 0 < volSet.length ) 
             volumeId = volSet[0];
-        else { response.sendError(530, "Missing VolumeId parameter" ); return; }
+        else {
+            throw new EC2ServiceException( ClientError.MissingParamter, "Missing required parameter - VolumeId");
+        }
 
         // -> execute the request
         EC2Engine engine = ServiceProvider.getInstance().getEC2Engine();
@@ -1003,7 +1025,9 @@ public class EC2RestServlet extends HttpServlet {
         String[] imageId = request.getParameterValues( "ImageId" );
         if ( null != imageId && 0 < imageId.length ) 
             image.setId( imageId[0] );
-        else { response.sendError(530, "Missing ImageId parameter" ); return; }
+        else {
+            throw new EC2ServiceException( ClientError.MissingParamter, "Missing required parameter - ImageId");
+        }
 
         // -> execute the request
         DeregisterImageResponse EC2response = EC2SoapServiceImpl.toDeregisterImageResponse( ServiceProvider.getInstance().getEC2Engine().deregisterImage( image ));
@@ -1017,16 +1041,25 @@ public class EC2RestServlet extends HttpServlet {
         String[] instanceId = request.getParameterValues( "InstanceId" );
         if ( null != instanceId && 0 < instanceId.length ) 
             EC2request.setInstanceId( instanceId[0] );
-        else { response.sendError(530, "Missing InstanceId parameter" ); return; }
+        else {
+            throw new EC2ServiceException( ClientError.MissingParamter, "Missing required parameter - InstanceId");
+        }
 
         String[] name = request.getParameterValues( "Name" );
         if ( null != name && 0 < name.length ) 
             EC2request.setName( name[0] );
-        else { response.sendError(530, "Missing Name parameter" ); return; }
+        else {
+            throw new EC2ServiceException( ClientError.MissingParamter, "Missing required parameter - Name");
+        }
 
         String[] description = request.getParameterValues( "Description" );
-        if ( null != description && 0 < description.length ) 
+        if ( null != description && 0 < description.length ) {
+            if (description[0].length() > 255)
+                throw new EC2ServiceException( ClientError.InvalidParameterValue,
+                        "Length of the value of parameter Description should be less than 255");
             EC2request.setDescription( description[0] );
+        }
+
 
         // -> execute the request
         CreateImageResponse EC2response = EC2SoapServiceImpl.toCreateImageResponse( ServiceProvider.getInstance().getEC2Engine().createImage( EC2request ));
@@ -1040,16 +1073,23 @@ public class EC2RestServlet extends HttpServlet {
         String[] location = request.getParameterValues( "ImageLocation" );
         if ( null != location && 0 < location.length ) 
             EC2request.setLocation( location[0] );
-        else { response.sendError(530, "Missing ImageLocation parameter" ); return; }
+        else {
+            throw new EC2ServiceException( ClientError.MissingParamter, "Missing parameter - ImageLocation");
+        }
 
         String[] cloudRedfined = request.getParameterValues( "Architecture" );
         if ( null != cloudRedfined && 0 < cloudRedfined.length ) 
             EC2request.setArchitecture( cloudRedfined[0] );
-        else { response.sendError(530, "Missing Architecture parameter" ); return; }
+        else {
+            throw new EC2ServiceException( ClientError.MissingParamter, "Missing required parameter - Architecture");
+        }
 
         String[] name = request.getParameterValues( "Name" );
         if ( null != name && 0 < name.length ) 
             EC2request.setName( name[0] );
+        else {
+               throw new EC2ServiceException( ClientError.MissingParamter, "Missing required parameter - Name");
+        }
 
         String[] description = request.getParameterValues( "Description" );
         if ( null != description && 0 < description.length ) 
@@ -1068,9 +1108,8 @@ public class EC2RestServlet extends HttpServlet {
        if ( imageId != null && imageId.length > 0 )
             ec2request.setImageId( imageId[0]);
        else {
-            response.sendError(530, "Missing ImageId parameter" );
-            return;
-        }
+           throw new EC2ServiceException( ClientError.MissingParamter, "Missing required parameter - ImageId");
+       }
 
         String[] description = request.getParameterValues( "Description.Value" );
         if ( description != null && description.length > 0 ) {
@@ -1082,8 +1121,8 @@ public class EC2RestServlet extends HttpServlet {
             if (ec2request.getLaunchPermissionSet().length > 0)
                 ec2request.setAttribute(ImageAttribute.launchPermission);
             else {
-                response.sendError(530, "Missing Attribute parameter - Description/LaunchPermission should be provided" );
-                return;
+                throw new EC2ServiceException( ClientError.MissingParamter,
+                        "Missing required parameter - Description/LaunchPermission should be provided");
             }
         }
 
@@ -1135,8 +1174,7 @@ public class EC2RestServlet extends HttpServlet {
         if ( imageId != null && imageId.length > 0)
             ec2request.setImageId(imageId[0]);
         else {
-            response.sendError(530, "Missing ImageId parameter" );
-            return;
+            throw new EC2ServiceException( ClientError.MissingParamter, "Missing required parameter - ImageId");
         }
 
         String[] attribute = request.getParameterValues( "Attribute" );
@@ -1144,12 +1182,11 @@ public class EC2RestServlet extends HttpServlet {
             if (attribute[0].equalsIgnoreCase("launchPermission"))
                 ec2request.setAttribute(ImageAttribute.launchPermission);
             else {
-                response.sendError(501, "Unsupported Attribute - only launchPermission supported" );
-                return;
+                throw new EC2ServiceException( ClientError.MissingParamter,
+                        "Missing required parameter - Description/LaunchPermission should be provided");
             }
         } else {
-            response.sendError(530, "Missing Attribute parameter" );
-            return;
+            throw new EC2ServiceException( ClientError.MissingParamter, "Missing required parameter - Attribute");
         }
 
         EC2ImageLaunchPermission launchPermission = new EC2ImageLaunchPermission();
@@ -1170,12 +1207,13 @@ public class EC2RestServlet extends HttpServlet {
         String[] imageId = request.getParameterValues( "ImageId" );
         if ( null != imageId && 0 < imageId.length ) 
             EC2request.setTemplateId( imageId[0] );
-        else { response.sendError(530, "Missing ImageId parameter" ); return; }
+        else {
+            throw new EC2ServiceException( ClientError.MissingParamter, "Missing required parameter - ImageId");
+        }
 
         String[] minCount = request.getParameterValues( "MinCount" );
         if ( minCount == null || minCount.length < 1) {
-            response.sendError(530, "Missing MinCount parameter" );
-            return;
+            throw new EC2ServiceException( ClientError.MissingParamter, "Missing required parameter - MinCount");
         } else if ( Integer.parseInt(minCount[0]) < 1) {
             throw new EC2ServiceException(ClientError.InvalidParameterValue,
                     "Value of parameter MinCount should be greater than 0");
@@ -1185,8 +1223,7 @@ public class EC2RestServlet extends HttpServlet {
 
         String[] maxCount = request.getParameterValues( "MaxCount" );
         if ( maxCount == null || maxCount.length < 1) {
-            response.sendError(530, "Missing MaxCount parameter" );
-            return;
+            throw new EC2ServiceException( ClientError.MissingParamter, "Missing required parameter - MaxCount");
         } else if ( Integer.parseInt(maxCount[0]) < 1) {
             throw new EC2ServiceException(ClientError.InvalidParameterValue,
                     "Value of parameter MaxCount should be greater than 0");
@@ -1250,7 +1287,9 @@ public class EC2RestServlet extends HttpServlet {
                 }
             }
         }	
-        if (0 == count) { response.sendError(530, "Missing InstanceId parameter" ); return; }
+        if (0 == count) {
+            throw new EC2ServiceException( ClientError.MissingParamter, "Missing required parameter - InstanceId");
+        }
 
         // -> execute the request
         RebootInstancesResponse EC2response = EC2SoapServiceImpl.toRebootInstancesResponse( ServiceProvider.getInstance().getEC2Engine().rebootInstances(EC2request));
@@ -1274,7 +1313,9 @@ public class EC2RestServlet extends HttpServlet {
                 }
             }
         }	
-        if (0 == count) { response.sendError(530, "Missing InstanceId parameter" ); return; }
+        if (0 == count) {
+            throw new EC2ServiceException( ClientError.MissingParamter, "Missing required parameter - InstanceId");
+        }
 
         // -> execute the request
         StartInstancesResponse EC2response = EC2SoapServiceImpl.toStartInstancesResponse( ServiceProvider.getInstance().getEC2Engine().startInstances(EC2request));
@@ -1298,7 +1339,9 @@ public class EC2RestServlet extends HttpServlet {
                 }
             }
         }	
-        if (0 == count) { response.sendError(530, "Missing InstanceId parameter" ); return; }
+        if (0 == count) {
+            throw new EC2ServiceException( ClientError.MissingParamter, "Missing required parameter - InstanceId");
+        }
 
         String[] force = request.getParameterValues("Force");
         if ( force != null) {
@@ -1327,7 +1370,9 @@ public class EC2RestServlet extends HttpServlet {
                 }
             }
         }		
-        if (0 == count) { response.sendError(530, "Missing InstanceId parameter" ); return; }
+        if (0 == count) {
+            throw new EC2ServiceException( ClientError.MissingParamter, "Missing required parameter - InstanceId");
+        }
 
         // -> execute the request
         EC2request.setDestroyInstances( true );
@@ -1364,7 +1409,8 @@ public class EC2RestServlet extends HttpServlet {
         }
 
         // -> execute the request
-        DescribeAvailabilityZonesResponse EC2response = EC2SoapServiceImpl.toDescribeAvailabilityZonesResponse( ServiceProvider.getInstance().getEC2Engine().handleRequest( EC2request ));
+        DescribeAvailabilityZonesResponse EC2response = EC2SoapServiceImpl.toDescribeAvailabilityZonesResponse(
+                ServiceProvider.getInstance().getEC2Engine().describeAvailabilityZones( EC2request ));
         serializeResponse(response, EC2response);
     }
 
@@ -1404,8 +1450,7 @@ public class EC2RestServlet extends HttpServlet {
         if (imageId != null && imageId.length > 0)
             ec2request.setImageId(imageId[0]);
         else {
-            response.sendError(530, "Missing ImageId parameter");
-            return;
+            throw new EC2ServiceException( ClientError.MissingParamter, "Missing required parameter - ImageId");
         }
 
         String[] attribute = request.getParameterValues( "Attribute" );
@@ -1415,12 +1460,11 @@ public class EC2RestServlet extends HttpServlet {
             else if (attribute[0].equalsIgnoreCase("launchPermission"))
                 ec2request.setAttribute(ImageAttribute.launchPermission);
             else {
-                response.sendError(501, "Unsupported Attribute - description and launchPermission supported" );
-                return;
+            	throw new EC2ServiceException( ClientError.InvalidParameterValue,
+                        "Only values supported for paramter Attribute are - Description/LaunchPermission");
             }
         } else {
-            response.sendError(530, "Missing Attribute parameter");
-            return;
+            throw new EC2ServiceException( ClientError.MissingParamter, "Missing required parameter - Attribute");
         }
 
         DescribeImageAttributeResponse EC2response = EC2SoapServiceImpl.toDescribeImageAttributeResponse( ServiceProvider.getInstance().getEC2Engine().describeImageAttribute( ec2request ));
@@ -1501,9 +1545,8 @@ public class EC2RestServlet extends HttpServlet {
         EC2Engine engine = ServiceProvider.getInstance().getEC2Engine();
 
         String publicIp = request.getParameter( "PublicIp" );
-        if (publicIp == null) { 
-            response.sendError(530, "Missing PublicIp parameter");
-            return;
+        if (publicIp == null) {
+            throw new EC2ServiceException( ClientError.MissingParamter, "Missing required parameter - PublicIp");
         }
 
         EC2ReleaseAddress ec2Request = new EC2ReleaseAddress();
@@ -1522,13 +1565,11 @@ public class EC2RestServlet extends HttpServlet {
 
         String publicIp = request.getParameter( "PublicIp" );
         if (null == publicIp) {
-            response.sendError(530, "Missing PublicIp parameter" );
-            return;
+            throw new EC2ServiceException( ClientError.MissingParamter, "Missing required parameter - PublicIp");
         }
         String instanceId = request.getParameter( "InstanceId" );
         if (null == instanceId) {
-            response.sendError(530, "Missing InstanceId parameter" );
-            return;
+            throw new EC2ServiceException( ClientError.MissingParamter, "Missing required parameter - InstanceId");
         }
 
         EC2AssociateAddress ec2Request = new EC2AssociateAddress();
@@ -1548,8 +1589,7 @@ public class EC2RestServlet extends HttpServlet {
 
         String publicIp = request.getParameter( "PublicIp" );
         if (null == publicIp) {
-            response.sendError(530, "Missing PublicIp parameter" );
-            return;
+            throw new EC2ServiceException( ClientError.MissingParamter, "Missing required parameter - PublicIp");
         }
 
         EC2DisassociateAddress ec2Request = new EC2DisassociateAddress();
@@ -1597,27 +1637,20 @@ public class EC2RestServlet extends HttpServlet {
     private void describeInstanceAttribute( HttpServletRequest request, HttpServletResponse response ) 
             throws ADBException, XMLStreamException, IOException {
         EC2DescribeInstances EC2request = new EC2DescribeInstances();
-        String instanceType = null;
+        String[] instanceId = request.getParameterValues( "InstanceId" );
+        if ( instanceId != null && instanceId.length > 0)
+            EC2request.addInstanceId( instanceId[0] );
+        else
+            throw new EC2ServiceException( ClientError.MissingParamter, "Missing required parameter - InstanceId");
 
-        // -> we are only handling queries about the "Attribute=instanceType"
-        Enumeration<?> names = request.getParameterNames();
-        while( names.hasMoreElements()) {
-            String key = (String)names.nextElement();
-            if (key.startsWith("Attribute")) {
-                String[] value = request.getParameterValues( key );
-                if (null != value && 0 < value.length && value[0].equalsIgnoreCase( "instanceType" )) { 
-                    instanceType = value[0];
-                    break;
-                }
+        String[] attribute = request.getParameterValues( "Attribute" );
+        if (attribute != null && attribute.length > 0) {
+               if ( !attribute[0].equalsIgnoreCase("instanceType") ) {
+                throw new EC2ServiceException( ClientError.InvalidParameterValue,
+                        "Only value supported for paramter Attribute is 'instanceType'");
             }
-        }		
-        if ( null != instanceType ) {
-            String[] value = request.getParameterValues( "InstanceId" );
-            EC2request.addInstanceId( value[0] );
-        }
-        else {
-            response.sendError(501, "Unsupported - only instanceType supported" ); 
-            return;
+        } else {
+            throw new EC2ServiceException( ClientError.MissingParamter, "Missing required parameter - Attribute");
         }
 
         // -> execute the request
@@ -1625,6 +1658,38 @@ public class EC2RestServlet extends HttpServlet {
         serializeResponse(response, EC2response);
     }
 
+    private void modifyInstanceAttribute(HttpServletRequest request, HttpServletResponse response)
+            throws ADBException, XMLStreamException, IOException {
+        EC2ModifyInstanceAttribute ec2Request = new EC2ModifyInstanceAttribute();
+
+        String[] instanceId = request.getParameterValues( "InstanceId" );
+        if ( instanceId != null && instanceId.length > 0 )
+             ec2Request.setInstanceId(instanceId[0]);
+        else {
+            throw new EC2ServiceException( ClientError.MissingParamter, "Missing required parameter - InstanceId");
+        }
+
+        String[] instanceType = request.getParameterValues( "InstanceType.Value" );
+        String[] userData  = request.getParameterValues( "UserData.Value" );
+
+        if ( instanceType != null && userData != null ) {
+            throw new EC2ServiceException( ClientError.InvalidParameterCombination, "Only one attribute can be" +
+                    " specified at a time");
+        }
+        if ( instanceType != null && instanceType.length > 0 ) {
+            ec2Request.setInstanceType(instanceType[0]);
+        } else if ( userData != null && userData.length > 0 ) {
+            ec2Request.setUserData(userData[0]);
+        } else {
+            throw new EC2ServiceException( ClientError.MissingParamter,
+                    "Missing parameter - InstanceType/UserData should be provided");
+        }
+
+        // -> execute the request
+        ModifyInstanceAttributeResponse EC2response = EC2SoapServiceImpl.toModifyInstanceAttributeResponse(
+                ServiceProvider.getInstance().getEC2Engine().modifyInstanceAttribute( ec2Request ));
+        serializeResponse(response, EC2response);
+    }
 
     private void describeSnapshots( HttpServletRequest request, HttpServletResponse response ) 
             throws ADBException, XMLStreamException, IOException 
@@ -1653,7 +1718,8 @@ public class EC2RestServlet extends HttpServlet {
 
         // -> execute the request
         EC2Engine engine = ServiceProvider.getInstance().getEC2Engine();
-        DescribeSnapshotsResponse EC2response = EC2SoapServiceImpl.toDescribeSnapshotsResponse( engine.handleRequest( EC2request ));
+        DescribeSnapshotsResponse EC2response = EC2SoapServiceImpl.toDescribeSnapshotsResponse(
+                engine.describeSnapshots( EC2request ));
         serializeResponse(response, EC2response);
             }
 
@@ -1685,7 +1751,9 @@ public class EC2RestServlet extends HttpServlet {
         }
 
         // -> execute the request
-        DescribeVolumesResponse EC2response = EC2SoapServiceImpl.toDescribeVolumesResponse( ServiceProvider.getInstance().getEC2Engine().handleRequest( EC2request ));
+        EC2Engine engine = ServiceProvider.getInstance().getEC2Engine();
+        DescribeVolumesResponse EC2response = EC2SoapServiceImpl.toDescribeVolumesResponse(
+                ServiceProvider.getInstance().getEC2Engine().describeVolumes( EC2request ), engine);
         serializeResponse(response, EC2response);
             }
 
@@ -1779,10 +1847,13 @@ public class EC2RestServlet extends HttpServlet {
             throws ADBException, XMLStreamException, IOException {
 
         String keyName = request.getParameter("KeyName");
+        if ( keyName == null ) {
+            throw new EC2ServiceException( ClientError.MissingParamter, "Missing required parameter - KeyName");
+        }
+
         String publicKeyMaterial = request.getParameter("PublicKeyMaterial");
-        if (keyName==null && publicKeyMaterial==null) {
-            response.sendError(530, "Missing parameter");
-            return;
+        if ( publicKeyMaterial == null ) {
+            throw new EC2ServiceException( ClientError.MissingParamter, "Missing required parameter - PublicKeyMaterial");
         }
 
         if (!publicKeyMaterial.contains(" "))
@@ -1804,9 +1875,8 @@ public class EC2RestServlet extends HttpServlet {
     private void createKeyPair(HttpServletRequest request, HttpServletResponse response)
             throws ADBException, XMLStreamException, IOException { 
         String keyName = request.getParameter("KeyName");
-        if (keyName==null) { 
-            response.sendError(530, "Missing KeyName parameter");
-            return;
+        if (keyName==null) {
+            throw new EC2ServiceException( ClientError.MissingParamter, "Missing required parameter - KeyName");
         }
 
         EC2CreateKeyPair ec2Request = new EC2CreateKeyPair();
@@ -1823,8 +1893,7 @@ public class EC2RestServlet extends HttpServlet {
             throws ADBException, XMLStreamException, IOException {
         String keyName = request.getParameter("KeyName");
         if (keyName==null) {
-            response.sendError(530, "Missing KeyName parameter");
-            return;
+            throw new EC2ServiceException( ClientError.MissingParamter, "Missing required parameter - KeyName");
         }
 
         EC2DeleteKeyPair ec2Request = new EC2DeleteKeyPair();
@@ -1839,8 +1908,7 @@ public class EC2RestServlet extends HttpServlet {
             throws ADBException, XMLStreamException, IOException {
         String instanceId = request.getParameter("InstanceId");
         if (instanceId==null) {
-            response.sendError(530, "Missing InstanceId parameter");
-            return;
+            throw new EC2ServiceException( ClientError.MissingParamter, "Missing required parameter - InstanceId");
         }
 
         GetPasswordDataResponse EC2Response = EC2SoapServiceImpl.toGetPasswordData(
@@ -1881,8 +1949,7 @@ public class EC2RestServlet extends HttpServlet {
             nCount++;
         } while (true);
         if ( resourceIdList.isEmpty() ) {
-            response.sendError(530, "At least one Resource is required" );
-            return null;
+            throw new EC2ServiceException( ClientError.MissingParamter, "Missing required parameter - ResourceId");
         }
         ec2Request = EC2SoapServiceImpl.toResourceTypeAndIds(ec2Request, resourceIdList);
 
@@ -1899,8 +1966,7 @@ public class EC2RestServlet extends HttpServlet {
             nCount++;
         } while (true);
         if ( resourceTagList.isEmpty() ) {
-            response.sendError(530, "At least one Tag is required" );
-            return null;
+            throw new EC2ServiceException( ClientError.MissingParamter, "Missing required parameter - ResourceTag");
         }
         ec2Request = EC2SoapServiceImpl.toResourceTag(ec2Request, resourceTagList);
 
@@ -1944,69 +2010,76 @@ public class EC2RestServlet extends HttpServlet {
         String[] awsAccess = request.getParameterValues( "AWSAccessKeyId" );
         if ( null != awsAccess && 0 < awsAccess.length ) 
             cloudAccessKey = awsAccess[0];
-        else { response.sendError(530, "Missing AWSAccessKeyId parameter" ); return false; }
+        else {
+            throw new EC2ServiceException( ClientError.MissingParamter, "Missing required parameter - AWSAccessKeyId");
+        }
 
         String[] clientSig = request.getParameterValues( "Signature" );
         if ( null != clientSig && 0 < clientSig.length ) 
             signature = clientSig[0];
-        else { response.sendError(530, "Missing Signature parameter" ); return false; }
+        else {
+            throw new EC2ServiceException( ClientError.MissingParamter, "Missing required parameter - Signature");
+        }
 
         String[] method = request.getParameterValues( "SignatureMethod" );
         if ( null != method && 0 < method.length ) 
         {
             sigMethod = method[0];
             if (!sigMethod.equals( "HmacSHA256" ) && !sigMethod.equals( "HmacSHA1" )) {
-                response.sendError(531, "Unsupported SignatureMethod value: " + sigMethod + " expecting: HmacSHA256 or HmacSHA1" ); 
-                return false;
+            	throw new EC2ServiceException( ClientError.InvalidParameterValue,
+                         "Unsupported SignatureMethod value: " + sigMethod + " expecting: HmacSHA256 or HmacSHA1");
             }
+        } else {
+            throw new EC2ServiceException( ClientError.MissingParamter, "Missing required parameter - SignatureMethod");
         }
-        else { response.sendError(530, "Missing SignatureMethod parameter" ); return false; }
 
         String[] version = request.getParameterValues( "Version" );
         if ( null != version && 0 < version.length ) 
         {
             if (!version[0].equals( wsdlVersion )) {
-                response.sendError(531, "Unsupported Version value: " + version[0] + " expecting: " + wsdlVersion ); 
-                return false;
+                throw new EC2ServiceException( ClientError.InvalidParameterValue,
+                        "Unsupported Version value: " + version[0] + " expecting: " + wsdlVersion);
             }
+        } else {
+            throw new EC2ServiceException( ClientError.MissingParamter, "Missing required parameter - Version");
         }
-        else { response.sendError(530, "Missing Version parameter" ); return false; }
 
         String[] sigVersion = request.getParameterValues( "SignatureVersion" );
         if ( null != sigVersion && 0 < sigVersion.length ) 
         {
             if (!sigVersion[0].equals( "2" )) {
-                response.sendError(531, "Unsupported SignatureVersion value: " + sigVersion[0] + " expecting: 2" ); 
-                return false;
+                throw new EC2ServiceException( ClientError.InvalidParameterValue,
+                     "Unsupported SignatureVersion value: " + sigVersion[0] + " expecting: 2");
             }
         }
-        else { response.sendError(530, "Missing SignatureVersion parameter" ); return false; }
+        else {
+            throw new EC2ServiceException( ClientError.MissingParamter, "Missing required parameter - SignatureVersion");
+        }
 
         // -> can have only one but not both { Expires | Timestamp } headers
         String[] expires = request.getParameterValues( "Expires" );
         if ( null != expires && 0 < expires.length ) 
         {
             // -> contains the date and time at which the signature included in the request EXPIRES
-            if (hasSignatureExpired( expires[0] )) {
-                response.sendError(531, "Expires parameter indicates signature has expired: " + expires[0] ); 
-                return false;
+            if (hasSignatureExpired( expires[0] )) { //InvalidSecurity.RequestHasExpired
+                 throw new EC2ServiceException( ClientError.InvalidSecurity_RequestHasExpired,
+                        "Expires parameter indicates signature has expired: " + expires[0]);
             }
         }
         else 
         {    // -> contains the date and time at which the request is SIGNED
             String[] time = request.getParameterValues( "Timestamp" );
             if ( null == time || 0 == time.length ) {
-                response.sendError(530, "Missing Timestamp and Expires parameter, one is required" ); 
-                return false; 
+                throw new EC2ServiceException( ClientError.MissingParamter, "Missing required parameter -" +
+                          " Timestamp/Expires");
             }
         } 
 
         // [B] Use the access key to get the users secret key from the cloud DB
         cloudSecretKey = userDao.getSecretKeyByAccessKey( cloudAccessKey );
         if ( cloudSecretKey == null ) {
-            logger.debug("No Secret key found for Access key '" + cloudAccessKey + "' in the the EC2 service");
-            throw new EC2ServiceException( ClientError.AuthFailure, "No Secret key found for Access key '" + cloudAccessKey +
-                    "' in the the EC2 service" );
+            logger.debug( "Access key '" + cloudAccessKey + "' not found in the the EC2 service ");
+            throw new EC2ServiceException( ClientError.AuthFailure, "Access key '" + cloudAccessKey + "' not found in the the EC2 service ");
         }
 
         // [C] Verify the signature
@@ -2050,8 +2123,9 @@ public class EC2RestServlet extends HttpServlet {
             UserContext.current().initContext( cloudAccessKey, cloudSecretKey, cloudAccessKey, "REST request", null );
             return true;
         }
-        else throw new PermissionDeniedException("Invalid signature");
-            }
+        else throw new EC2ServiceException( ClientError.SignatureDoesNotMatch,
+                "The request signature calculated does not match the signature provided by the user.");
+    }
 
     /**
      * We check this to reduce replay attacks.

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9a33fd18/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 dc0d993..f6ac971 100644
--- a/awsapi/src/com/cloud/bridge/service/EC2SoapServiceImpl.java
+++ b/awsapi/src/com/cloud/bridge/service/EC2SoapServiceImpl.java
@@ -53,6 +53,7 @@ import com.cloud.bridge.service.core.ec2.EC2DescribeKeyPairs;
 import com.cloud.bridge.service.core.ec2.EC2DescribeKeyPairsResponse;
 import com.cloud.bridge.service.core.ec2.EC2ImageFilterSet;
 import com.cloud.bridge.service.core.ec2.EC2ImageLaunchPermission;
+import com.cloud.bridge.service.core.ec2.EC2ModifyInstanceAttribute;
 import com.cloud.bridge.service.core.ec2.EC2ResourceTag;
 import com.cloud.bridge.service.core.ec2.EC2DescribeSecurityGroups;
 import com.cloud.bridge.service.core.ec2.EC2DescribeSecurityGroupsResponse;
@@ -96,7 +97,6 @@ import com.cloud.bridge.service.core.ec2.EC2Volume;
 import com.cloud.bridge.service.core.ec2.EC2VolumeFilterSet;
 import com.cloud.bridge.service.exception.EC2ServiceException;
 import com.cloud.bridge.service.exception.EC2ServiceException.ClientError;
-import com.cloud.bridge.service.exception.EC2ServiceException.ServerError;
 import com.cloud.bridge.util.EC2RestAuth;
 
 
@@ -273,8 +273,8 @@ public class EC2SoapServiceImpl implements AmazonEC2SkeletonInterface  {
         List<String> resourceTypeList = new ArrayList<String>();
         for (String resourceId : resourceIdList) {
             if (!resourceId.contains(":") || resourceId.split(":").length != 2) {
-                throw new EC2ServiceException( ClientError.InvalidResourceId_Format,
-                        "Invalid Format. ResourceId format is resource-type:resource-uuid");
+                throw new EC2ServiceException( ClientError.InvalidParameterValue,
+                        "Invalid usage. ResourceId format is resource-type:resource-uuid");
             }
             String resourceType = resourceId.split(":")[0];
             if (resourceTypeList.isEmpty())
@@ -356,7 +356,7 @@ public class EC2SoapServiceImpl implements AmazonEC2SkeletonInterface  {
             request.setFilterSet( toAvailabiltyZonesFilterSet(fst));
         }
 
-		return toDescribeAvailabilityZonesResponse( engine.handleRequest( request ));
+		return toDescribeAvailabilityZonesResponse( engine.describeAvailabilityZones( request ));
 	}
 
 	/**
@@ -422,11 +422,11 @@ public class EC2SoapServiceImpl implements AmazonEC2SkeletonInterface  {
 	    EmptyElementType instanceType = diag.getInstanceType();
 		
 	    // -> toEC2DescribeInstances
-	    if (null != instanceType) {
-		    request.addInstanceId( diat.getInstanceId());
+           if (null != instanceType) {
+                   request.addInstanceId( diat.getInstanceId());
 		    return toDescribeInstanceAttributeResponse( engine.describeInstances( request ));
 	    }
-	    throw new EC2ServiceException( ClientError.Unsupported, "Unsupported - only instanceType supported");
+           throw new EC2ServiceException( ClientError.Unsupported, "Unsupported - only instanceType supported");
 	}
 
 	
@@ -549,7 +549,7 @@ public class EC2SoapServiceImpl implements AmazonEC2SkeletonInterface  {
             request = toSnapshotFilterSet( request, fst, timeFilters );
 		}
 
-		return toDescribeSnapshotsResponse(engine.handleRequest(request));
+        return toDescribeSnapshotsResponse(engine.describeSnapshots(request));
 	}
 
     public DescribeTagsResponse describeTags(DescribeTags decsribeTags) {
@@ -588,7 +588,7 @@ public class EC2SoapServiceImpl implements AmazonEC2SkeletonInterface  {
             request = toVolumeFilterSet( request, fst, timeFilters );
 		}
 		
-		return toDescribeVolumesResponse( engine.handleRequest( request ));
+        return toDescribeVolumesResponse( engine.describeVolumes( request ), engine);
 	}
 	
 	public DetachVolumeResponse detachVolume(DetachVolume detachVolume) {
@@ -629,6 +629,26 @@ public class EC2SoapServiceImpl implements AmazonEC2SkeletonInterface  {
 		throw new EC2ServiceException( ClientError.Unsupported, "Unsupported - can only modify image description or launchPermission");
 	}	
 
+    public ModifyInstanceAttributeResponse modifyInstanceAttribute(ModifyInstanceAttribute modifyInstanceAttribute) {
+        EC2ModifyInstanceAttribute request = new EC2ModifyInstanceAttribute();
+
+        ModifyInstanceAttributeType modifyInstanceAttribute2 = modifyInstanceAttribute.getModifyInstanceAttribute();
+        ModifyInstanceAttributeTypeChoice_type0 mia = modifyInstanceAttribute2.getModifyInstanceAttributeTypeChoice_type0();
+
+        request.setInstanceId(modifyInstanceAttribute2.getInstanceId());
+
+        // we only support instanceType and userData
+        if (mia.getInstanceType() != null) {
+            request.setInstanceType(mia.getInstanceType().getValue());
+        } else if (mia.getUserData() != null) {
+            request.setUserData(mia.getUserData().getValue());
+        } else {
+            throw new EC2ServiceException( ClientError.MissingParamter,
+                    "Missing required parameter - InstanceType/UserData should be provided");
+        }
+        return toModifyInstanceAttributeResponse(engine.modifyInstanceAttribute(request));
+    }
+
     private void setAccountOrGroupList(LaunchPermissionItemType[] items, EC2ModifyImageAttribute request, String operation){
         EC2ImageLaunchPermission launchPermission = new EC2ImageLaunchPermission();
 
@@ -858,26 +878,20 @@ public class EC2SoapServiceImpl implements AmazonEC2SkeletonInterface  {
 		response.setUnmonitorInstancesResponse( param1 );
 		return response;
 	}
-	
-	
-	public static DescribeImageAttributeResponse toDescribeImageAttributeResponse(EC2DescribeImagesResponse engineResponse) {
-		DescribeImageAttributeResponse response = new DescribeImageAttributeResponse();
-		DescribeImageAttributeResponseType param1 = new DescribeImageAttributeResponseType();
-		
-		EC2Image[] imageSet = engineResponse.getImageSet();
-		if ( 0 < imageSet.length ) {
-		     DescribeImageAttributeResponseTypeChoice_type0 param2 = new DescribeImageAttributeResponseTypeChoice_type0();
-		     NullableAttributeValueType param3 = new NullableAttributeValueType();
-		     param3.setValue( imageSet[0].getDescription());
-		     param2.setDescription( param3 );
-		     param1.setDescribeImageAttributeResponseTypeChoice_type0( param2 );
-		     param1.setImageId( imageSet[0].getId());	
-		}
-		
-		param1.setRequestId( UUID.randomUUID().toString());
-        response.setDescribeImageAttributeResponse( param1 );
-		return response;
-	}
+
+    /**
+     * @param modifyInstanceAttribute
+     * @return	
+     */
+    public static ModifyInstanceAttributeResponse toModifyInstanceAttributeResponse(Boolean status) {
+        ModifyInstanceAttributeResponse miat = new ModifyInstanceAttributeResponse();
+
+        ModifyInstanceAttributeResponseType param = new ModifyInstanceAttributeResponseType();
+        param.set_return(status);
+        param.setRequestId(UUID.randomUUID().toString());
+        miat.setModifyInstanceAttributeResponse(param);
+        return miat;
+    }
 	
 	public static DescribeImageAttributeResponse toDescribeImageAttributeResponse(EC2ImageAttributes engineResponse) {
        DescribeImageAttributeResponse response = new DescribeImageAttributeResponse();
@@ -1311,7 +1325,7 @@ public class EC2SoapServiceImpl implements AmazonEC2SkeletonInterface  {
     }
 
 	// toMethods
-	public static DescribeVolumesResponse toDescribeVolumesResponse( EC2DescribeVolumesResponse engineResponse ) 
+	public static DescribeVolumesResponse toDescribeVolumesResponse( EC2DescribeVolumesResponse engineResponse, EC2Engine engine ) 
 	{
 	    DescribeVolumesResponse      response = new DescribeVolumesResponse();
 	    DescribeVolumesResponseType    param1 = new DescribeVolumesResponseType();
@@ -1342,8 +1356,8 @@ public class EC2SoapServiceImpl implements AmazonEC2SkeletonInterface  {
 	        	AttachmentSetItemResponseType param5 = new AttachmentSetItemResponseType();
 	        	param5.setVolumeId(vol.getId().toString());
 	        	param5.setInstanceId(vol.getInstanceId().toString());
-	        	String devicePath = engine.cloudDeviceIdToDevicePath( vol.getHypervisor(), vol.getDeviceId());
-	        	param5.setDevice( devicePath );
+                String devicePath = engine.cloudDeviceIdToDevicePath( vol.getHypervisor(), vol.getDeviceId());
+                param5.setDevice( devicePath );
                 param5.setStatus(vol.getAttachmentState());
                 if (vol.getAttached() == null) {
                     param5.setAttachTime( cal );
@@ -1876,7 +1890,10 @@ public class EC2SoapServiceImpl implements AmazonEC2SkeletonInterface  {
 		param1.setVolumeId( engineResponse.getId().toString());
         Long volSize = new Long( engineResponse.getSize());
         param1.setSize( volSize.toString());  
-        param1.setSnapshotId( "" );
+        if (engineResponse.getSnapshotId() != null)
+            param1.setSnapshotId( engineResponse.getSnapshotId() );
+        else
+            param1.setSnapshotId( "" );
         param1.setAvailabilityZone( engineResponse.getZoneName());
 		if ( null != engineResponse.getState())
 		     param1.setStatus( engineResponse.getState());
@@ -2503,10 +2520,6 @@ public class EC2SoapServiceImpl implements AmazonEC2SkeletonInterface  {
 	public ImportVolumeResponse importVolume(ImportVolume importVolume) {
 		throw new EC2ServiceException(ClientError.Unsupported, "This operation is not available");
 	}
-	
-	public ModifyInstanceAttributeResponse modifyInstanceAttribute(ModifyInstanceAttribute modifyInstanceAttribute) {
-		throw new EC2ServiceException(ClientError.Unsupported, "This operation is not available");
-	}
 
 	public ModifySnapshotAttributeResponse modifySnapshotAttribute(ModifySnapshotAttribute modifySnapshotAttribute) {
 		throw new EC2ServiceException(ClientError.Unsupported, "This operation is not available");

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9a33fd18/awsapi/src/com/cloud/bridge/service/core/ec2/EC2AddressFilterSet.java
----------------------------------------------------------------------
diff --git a/awsapi/src/com/cloud/bridge/service/core/ec2/EC2AddressFilterSet.java b/awsapi/src/com/cloud/bridge/service/core/ec2/EC2AddressFilterSet.java
index 1823b26..153fdde 100644
--- a/awsapi/src/com/cloud/bridge/service/core/ec2/EC2AddressFilterSet.java
+++ b/awsapi/src/com/cloud/bridge/service/core/ec2/EC2AddressFilterSet.java
@@ -26,6 +26,9 @@ import java.util.Map;
 
 import org.apache.log4j.Logger;
 
+import com.cloud.bridge.service.exception.EC2ServiceException;
+import com.cloud.bridge.service.exception.EC2ServiceException.ClientError;
+
 public class EC2AddressFilterSet {
 	protected final static Logger logger = Logger.getLogger(EC2KeyPairFilterSet.class);
 	
@@ -43,16 +46,9 @@ public class EC2AddressFilterSet {
 		String filterName = param.getName();
 		String value = (String) filterTypes.get( filterName );
 		
-		if (null == value) {
-			// Changing this to silently ignore
-			logger.error("Unsupported filter [" + filterName + "] - 1");
-			return;
-		}
-		
-		if (null != value && value.equalsIgnoreCase( "null" )) {
-			logger.error("Unsupported filter [" + filterName + "] - 2");
-			return;
-		}	
+        if ( value == null || value.equalsIgnoreCase("null") ) {
+            throw new EC2ServiceException( ClientError.InvalidFilter, "Filter '" + filterName + "' is invalid");
+        }
 
 		// ToDo we could add checks to make sure the type of a filters value is correct (e.g., an integer)
 		filterSet.add( param );

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9a33fd18/awsapi/src/com/cloud/bridge/service/core/ec2/EC2AvailabilityZonesFilterSet.java
----------------------------------------------------------------------
diff --git a/awsapi/src/com/cloud/bridge/service/core/ec2/EC2AvailabilityZonesFilterSet.java b/awsapi/src/com/cloud/bridge/service/core/ec2/EC2AvailabilityZonesFilterSet.java
index aa3897a..7dba8ab 100644
--- a/awsapi/src/com/cloud/bridge/service/core/ec2/EC2AvailabilityZonesFilterSet.java
+++ b/awsapi/src/com/cloud/bridge/service/core/ec2/EC2AvailabilityZonesFilterSet.java
@@ -26,6 +26,7 @@ import java.util.Map;
 
 
 import com.cloud.bridge.service.exception.EC2ServiceException;
+import com.cloud.bridge.service.exception.EC2ServiceException.ClientError;
 
 
 public class EC2AvailabilityZonesFilterSet {
@@ -43,11 +44,9 @@ public class EC2AvailabilityZonesFilterSet {
         String filterName = param.getName();
         String value = (String) filterTypes.get( filterName );
 
-        if (null == value) 
-            throw new EC2ServiceException( "Unsupported filter [" + filterName + "]", 501 );
-
-        if (null != value && value.equalsIgnoreCase( "null" ))
-            throw new EC2ServiceException( "Unsupported filter [" + filterName + "]", 501 );
+        if ( value == null || value.equalsIgnoreCase("null") ) {
+            throw new EC2ServiceException( ClientError.InvalidFilter, "Filter '" + filterName + "' is invalid");
+        }
 
         filterSet.add( param );
     }


Mime
View raw message