incubator-cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From prachida...@apache.org
Subject git commit: CS-15145: Summary: ec2-register: need better error handling for negative cases.
Date Mon, 23 Jul 2012 22:47:20 GMT
Updated Branches:
  refs/heads/master b80c3dc9c -> 11f5bd25f


CS-15145: Summary: ec2-register: need better error handling for negative cases.

The negative cases for which the error handling is improved,
1. run ec2-register with incorrect field separator for architecture parameter.
2. run ec2-register without providing required parameters.


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

Branch: refs/heads/master
Commit: 11f5bd25f80362001b478c60eef669e35296bcb2
Parents: b80c3dc
Author: Likitha Shetty <likitha.shetty@citrix.com>
Authored: Mon Jul 23 15:44:30 2012 -0700
Committer: prachi <prachi@cloud.com>
Committed: Mon Jul 23 15:46:03 2012 -0700

----------------------------------------------------------------------
 .../cloud/bridge/service/core/ec2/EC2Engine.java   |    5 +--
 .../bridge/service/core/ec2/EC2RegisterImage.java  |   24 ++++++++++-----
 2 files changed, 18 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/11f5bd25/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 c64a073..1363d0d 100644
--- a/awsapi/src/com/cloud/bridge/service/core/ec2/EC2Engine.java
+++ b/awsapi/src/com/cloud/bridge/service/core/ec2/EC2Engine.java
@@ -1068,9 +1068,8 @@ public class EC2Engine {
 	{
 		try {
 		    CloudStackAccount caller = getCurrentAccount();
-			if (null == request.getFormat()   || null == request.getName() || null == request.getOsTypeName()
||
-					null == request.getLocation() || null == request.getZoneName())
-				throw new EC2ServiceException(ServerError.InternalError, "Missing parameter - location/architecture/name");
+            if (null == request.getName())
+                throw new EC2ServiceException(ClientError.Unsupported, "Missing parameter
- name");
 
 			List<CloudStackTemplate> templates = getApi().registerTemplate((request.getDescription()
== null ? request.getName() : request.getDescription()), 
 					request.getFormat(), request.getHypervisor(), request.getName(), toOSTypeId(request.getOsTypeName()),
request.getLocation(), 

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/11f5bd25/awsapi/src/com/cloud/bridge/service/core/ec2/EC2RegisterImage.java
----------------------------------------------------------------------
diff --git a/awsapi/src/com/cloud/bridge/service/core/ec2/EC2RegisterImage.java b/awsapi/src/com/cloud/bridge/service/core/ec2/EC2RegisterImage.java
index 3fd36ba..d713297 100644
--- a/awsapi/src/com/cloud/bridge/service/core/ec2/EC2RegisterImage.java
+++ b/awsapi/src/com/cloud/bridge/service/core/ec2/EC2RegisterImage.java
@@ -16,6 +16,9 @@
 // under the License.
 package com.cloud.bridge.service.core.ec2;
 
+import com.cloud.bridge.service.exception.EC2ServiceException;
+import com.cloud.bridge.service.exception.EC2ServiceException.ClientError;
+
 public class EC2RegisterImage {
 
 	private String  location;
@@ -67,14 +70,19 @@ public class EC2RegisterImage {
 	 */
 	public void setArchitecture( String param ) {
 		if (null != param) {
-			String parts[] = param.split( ":" );
-			if (3 <= parts.length) {
-				format = parts[0];
-				zoneName = parts[1];
-				osTypeName = parts[2];
-				hypervisor = parts[3];
-			}
-		}
+            if (!param.contains(":") || param.split(":").length < 4) {
+                throw new EC2ServiceException(  ClientError.InvalidParameterValue, "Supported
format for " +
+                    "'architecture' is format:zonename:ostypename:hypervisor" );
+            }
+            String parts[] = param.split( ":" );
+            format = parts[0];
+            zoneName = parts[1];
+            osTypeName = parts[2];
+            hypervisor = parts[3];
+        }
+        else {
+            throw new EC2ServiceException(ClientError.Unsupported, "Missing Parameter -"
+ " architecture");
+        }
 	}
 	
 	public String getFormat() {


Mime
View raw message