mirror of
https://github.com/apache/cloudstack.git
synced 2025-12-15 18:12:35 +01:00
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.
This commit is contained in:
parent
b80c3dc9c6
commit
11f5bd25f8
@ -1068,9 +1068,8 @@ public class EC2Engine {
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
CloudStackAccount caller = getCurrentAccount();
|
CloudStackAccount caller = getCurrentAccount();
|
||||||
if (null == request.getFormat() || null == request.getName() || null == request.getOsTypeName() ||
|
if (null == request.getName())
|
||||||
null == request.getLocation() || null == request.getZoneName())
|
throw new EC2ServiceException(ClientError.Unsupported, "Missing parameter - name");
|
||||||
throw new EC2ServiceException(ServerError.InternalError, "Missing parameter - location/architecture/name");
|
|
||||||
|
|
||||||
List<CloudStackTemplate> templates = getApi().registerTemplate((request.getDescription() == null ? request.getName() : request.getDescription()),
|
List<CloudStackTemplate> templates = getApi().registerTemplate((request.getDescription() == null ? request.getName() : request.getDescription()),
|
||||||
request.getFormat(), request.getHypervisor(), request.getName(), toOSTypeId(request.getOsTypeName()), request.getLocation(),
|
request.getFormat(), request.getHypervisor(), request.getName(), toOSTypeId(request.getOsTypeName()), request.getLocation(),
|
||||||
|
|||||||
@ -16,6 +16,9 @@
|
|||||||
// under the License.
|
// under the License.
|
||||||
package com.cloud.bridge.service.core.ec2;
|
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 {
|
public class EC2RegisterImage {
|
||||||
|
|
||||||
private String location;
|
private String location;
|
||||||
@ -67,14 +70,19 @@ public class EC2RegisterImage {
|
|||||||
*/
|
*/
|
||||||
public void setArchitecture( String param ) {
|
public void setArchitecture( String param ) {
|
||||||
if (null != param) {
|
if (null != param) {
|
||||||
String parts[] = param.split( ":" );
|
if (!param.contains(":") || param.split(":").length < 4) {
|
||||||
if (3 <= parts.length) {
|
throw new EC2ServiceException( ClientError.InvalidParameterValue, "Supported format for " +
|
||||||
format = parts[0];
|
"'architecture' is format:zonename:ostypename:hypervisor" );
|
||||||
zoneName = parts[1];
|
}
|
||||||
osTypeName = parts[2];
|
String parts[] = param.split( ":" );
|
||||||
hypervisor = parts[3];
|
format = parts[0];
|
||||||
}
|
zoneName = parts[1];
|
||||||
}
|
osTypeName = parts[2];
|
||||||
|
hypervisor = parts[3];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw new EC2ServiceException(ClientError.Unsupported, "Missing Parameter -" + " architecture");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFormat() {
|
public String getFormat() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user