Return-Path: X-Original-To: apmail-incubator-cloudstack-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-cloudstack-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id EC251D976 for ; Mon, 23 Jul 2012 22:47:20 +0000 (UTC) Received: (qmail 81799 invoked by uid 500); 23 Jul 2012 22:47:20 -0000 Delivered-To: apmail-incubator-cloudstack-commits-archive@incubator.apache.org Received: (qmail 81776 invoked by uid 500); 23 Jul 2012 22:47:20 -0000 Mailing-List: contact cloudstack-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: cloudstack-dev@incubator.apache.org Delivered-To: mailing list cloudstack-commits@incubator.apache.org Received: (qmail 81769 invoked by uid 99); 23 Jul 2012 22:47:20 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 23 Jul 2012 22:47:20 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 7594E16F07; Mon, 23 Jul 2012 22:47:20 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: prachidamle@apache.org To: cloudstack-commits@incubator.apache.org X-Mailer: ASF-Git Admin Mailer Subject: git commit: CS-15145: Summary: ec2-register: need better error handling for negative cases. Message-Id: <20120723224720.7594E16F07@tyr.zones.apache.org> Date: Mon, 23 Jul 2012 22:47:20 +0000 (UTC) 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 Authored: Mon Jul 23 15:44:30 2012 -0700 Committer: prachi 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 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() {