CLOUDSTACK-6322 - Don't allow service instance creation with empty or null service-instance "name".

Signed-off-by: Daan Hoogland <daan@onecht.net>
This commit is contained in:
Sachchidanand Vaidya 2014-04-02 01:57:07 -07:00 committed by Daan Hoogland
parent eb195d0575
commit 085911f0a6

View File

@ -106,7 +106,8 @@ public class CreateServiceInstanceCmd extends BaseAsyncCreateCmd {
description = "The service offering ID that defines the resources consumed by the service appliance")
private Long serviceOfferingId;
@Parameter(name = ApiConstants.NAME, type = CommandType.STRING)
@Parameter(name = ApiConstants.NAME, type = CommandType.STRING,
required = true, description = "The name of the service instance")
private String name;
/// Implementation
@ -144,6 +145,10 @@ public class CreateServiceInstanceCmd extends BaseAsyncCreateCmd {
throw new InvalidParameterValueException("Invalid ID for right network " + rightNetworkId);
}
if (name.isEmpty()) {
throw new InvalidParameterValueException("service instance name is empty");
}
ServiceVirtualMachine svm = _vrouterService.createServiceInstance(zone, owner, template, serviceOffering, name, left, right);
if (svm == null) {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Unable to create service instance");