You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by ch...@apache.org on 2015/04/17 21:19:24 UTC
[1/3] stratos git commit: [STRATOS-1280] - Return 409 Conflict status
if cartridge group already exists
Repository: stratos
Updated Branches:
refs/heads/master 2a822d99d -> db77fe036
[STRATOS-1280] - Return 409 Conflict status if cartridge group already exists
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/b65ede05
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/b65ede05
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/b65ede05
Branch: refs/heads/master
Commit: b65ede0590aaaa7559f25a35927e73eab68f18c9
Parents: 2a822d9
Author: Chamila de Alwis <ch...@apache.org>
Authored: Fri Apr 17 23:16:13 2015 +0530
Committer: Chamila de Alwis <ch...@apache.org>
Committed: Fri Apr 17 23:16:13 2015 +0530
----------------------------------------------------------------------
.../services/impl/AutoscalerServiceImpl.java | 11 ++++++-----
.../stratos/rest/endpoint/api/StratosApiV41.java | 18 +++++++++++++-----
.../rest/endpoint/api/StratosApiV41Utils.java | 1 +
3 files changed, 20 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/b65ede05/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/services/impl/AutoscalerServiceImpl.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/services/impl/AutoscalerServiceImpl.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/services/impl/AutoscalerServiceImpl.java
index 589af4b..a9a76a7 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/services/impl/AutoscalerServiceImpl.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/services/impl/AutoscalerServiceImpl.java
@@ -516,15 +516,15 @@ public class AutoscalerServiceImpl implements AutoscalerService {
String msg = "Cartridge group can not be null service name can not be empty.";
log.error(msg);
throw new IllegalArgumentException(msg);
-
}
if (log.isInfoEnabled()) {
log.info(String.format("Adding cartridge group: [group-name] %s", servicegroup.getName()));
}
+
String groupName = servicegroup.getName();
if (RegistryManager.getInstance().serviceGroupExist(groupName)) {
- throw new InvalidServiceGroupException("Cartridge group with the name " + groupName + " already exist.");
+ throw new InvalidServiceGroupException("Cartridge group with the name " + groupName + " already exists.");
}
if (log.isDebugEnabled()) {
@@ -533,7 +533,7 @@ public class AutoscalerServiceImpl implements AutoscalerService {
String[] subGroups = servicegroup.getCartridges();
if (log.isDebugEnabled()) {
- log.debug("SubGroups" + subGroups);
+ log.debug("SubGroups" + Arrays.toString(subGroups));
if (subGroups != null) {
log.debug("subGroups:size" + subGroups.length);
} else {
@@ -550,7 +550,7 @@ public class AutoscalerServiceImpl implements AutoscalerService {
String[] startupOrders = dependencies.getStartupOrders();
if (log.isDebugEnabled()) {
- log.debug("StartupOrders " + startupOrders);
+ log.debug("StartupOrders " + Arrays.toString(startupOrders));
if (startupOrders != null) {
log.debug("StartupOrder:size " + startupOrders.length);
@@ -558,10 +558,11 @@ public class AutoscalerServiceImpl implements AutoscalerService {
log.debug("StartupOrder: is null");
}
}
+
String[] scalingDependents = dependencies.getScalingDependants();
if (log.isDebugEnabled()) {
- log.debug("ScalingDependent " + scalingDependents);
+ log.debug("ScalingDependent " + Arrays.toString(scalingDependents));
if (scalingDependents != null) {
log.debug("ScalingDependents:size " + scalingDependents.length);
http://git-wip-us.apache.org/repos/asf/stratos/blob/b65ede05/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java
index bf1ceec..d5fdc5a 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java
@@ -422,11 +422,19 @@ public class StratosApiV41 extends AbstractApi {
@SuperTenantService(true)
public Response addServiceGroup(
GroupBean serviceGroupDefinition) throws RestAPIException {
- StratosApiV41Utils.addServiceGroup(serviceGroupDefinition);
- URI url = uriInfo.getAbsolutePathBuilder().path(serviceGroupDefinition.getName()).build();
- return Response.created(url).entity(new SuccessResponseBean(Response.Status.CREATED.getStatusCode(),
- String.format("Service Group added successfully: [service-group] %s",
- serviceGroupDefinition.getName()))).build();
+ try {
+ StratosApiV41Utils.addServiceGroup(serviceGroupDefinition);
+ URI url = uriInfo.getAbsolutePathBuilder().path(serviceGroupDefinition.getName()).build();
+ return Response.created(url).entity(new SuccessResponseBean(Response.Status.CREATED.getStatusCode(),
+ String.format("Service Group added successfully: [service-group] %s",
+ serviceGroupDefinition.getName()))).build();
+ } catch (RestAPIException e) {
+ if (e.getCause().getMessage().contains("already exists")) {
+ return Response.status(Response.Status.CONFLICT).build();
+ } else {
+ throw e;
+ }
+ }
}
/**
http://git-wip-us.apache.org/repos/asf/stratos/blob/b65ede05/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java
index 166da5b..d6a76c1 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java
@@ -884,6 +884,7 @@ public class StratosApiV41Utils {
StratosManagerServiceClient smServiceClient = getStratosManagerServiceClient();
smServiceClient.addUsedCartridgesInCartridgeGroups(serviceGroupDefinition.getName(), cartridgeNames);
} catch (Exception e) {
+ // TODO: InvalidServiceGroupException is not received, only AxisFault. Need to fix get the custom exception
String message = "Could not add cartridge group";
log.error(message, e);
throw new RestAPIException(message, e);
[2/3] stratos git commit: [STRATOS-1277] - Return 409 Conflict status
if deployment policy and application policy already exists
Posted by ch...@apache.org.
[STRATOS-1277] - Return 409 Conflict status if deployment policy and application policy already exists
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/477c366b
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/477c366b
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/477c366b
Branch: refs/heads/master
Commit: 477c366bbdd3541b48a84ef72104fb392c74c190
Parents: b65ede0
Author: Chamila de Alwis <ch...@apache.org>
Authored: Sat Apr 18 00:11:39 2015 +0530
Committer: Chamila de Alwis <ch...@apache.org>
Committed: Sat Apr 18 00:11:39 2015 +0530
----------------------------------------------------------------------
.../rest/endpoint/api/StratosApiV41.java | 42 ++++++++++++++------
.../rest/endpoint/api/StratosApiV41Utils.java | 10 ++---
2 files changed, 34 insertions(+), 18 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/477c366b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java
index d5fdc5a..371c709 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java
@@ -172,13 +172,21 @@ public class StratosApiV41 extends AbstractApi {
public Response addDeploymentPolicy(
DeploymentPolicyBean deploymentPolicyDefinitionBean) throws RestAPIException {
- String deploymentPolicyID = deploymentPolicyDefinitionBean.getId();
- // TODO :: Deployment policy validation
- StratosApiV41Utils.addDeploymentPolicy(deploymentPolicyDefinitionBean);
- URI url = uriInfo.getAbsolutePathBuilder().path(deploymentPolicyID).build();
- return Response.created(url).entity(new SuccessResponseBean(Response.Status.CREATED.getStatusCode(),
- String.format("Deployment policy added successfully: " + "[deployment-policy-id] %s",
- deploymentPolicyID))).build();
+ try {
+ String deploymentPolicyID = deploymentPolicyDefinitionBean.getId();
+ // TODO :: Deployment policy validation
+ StratosApiV41Utils.addDeploymentPolicy(deploymentPolicyDefinitionBean);
+ URI url = uriInfo.getAbsolutePathBuilder().path(deploymentPolicyID).build();
+ return Response.created(url).entity(new SuccessResponseBean(Response.Status.CREATED.getStatusCode(),
+ String.format("Deployment policy added successfully: " + "[deployment-policy-id] %s",
+ deploymentPolicyID))).build();
+ } catch (RestAPIException e) {
+ if (e.getCause().getMessage().contains("already exists")) {
+ return Response.status(Response.Status.CONFLICT).build();
+ } else {
+ throw e;
+ }
+ }
}
/**
@@ -704,11 +712,19 @@ public class StratosApiV41 extends AbstractApi {
@AuthorizationAction("/permission/admin/manage/addApplicationPolicy")
public Response addApplicationPolicy(
ApplicationPolicyBean applicationPolicy) throws RestAPIException {
- StratosApiV41Utils.addApplicationPolicy(applicationPolicy);
- URI url = uriInfo.getAbsolutePathBuilder().path(applicationPolicy.getId()).build();
- return Response.created(url).entity(new SuccessResponseBean(Response.Status.CREATED.getStatusCode(),
- String.format("Application policy added successfully: [application-policy] %s",
- applicationPolicy.getId()))).build();
+ try {
+ StratosApiV41Utils.addApplicationPolicy(applicationPolicy);
+ URI url = uriInfo.getAbsolutePathBuilder().path(applicationPolicy.getId()).build();
+ return Response.created(url).entity(new SuccessResponseBean(Response.Status.CREATED.getStatusCode(),
+ String.format("Application policy added successfully: [application-policy] %s",
+ applicationPolicy.getId()))).build();
+ } catch (RestAPIException e) {
+ if (e.getMessage().contains("already exists")) {
+ return Response.status(Response.Status.CONFLICT).build();
+ } else {
+ throw e;
+ }
+ }
}
/**
@@ -855,7 +871,7 @@ public class StratosApiV41 extends AbstractApi {
@AuthorizationAction("/permission/protected/manage/getApplicationSignUp")
public Response getApplicationSignUp(
@PathParam("applicationId") String applicationId) throws RestAPIException {
- ApplicationSignUpBean applicationSignUpBean = null;
+ ApplicationSignUpBean applicationSignUpBean;
try {
applicationSignUpBean = StratosApiV41Utils.getApplicationSignUp(applicationId);
if (applicationSignUpBean == null) {
http://git-wip-us.apache.org/repos/asf/stratos/blob/477c366b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java
index d6a76c1..63f7300 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java
@@ -573,7 +573,7 @@ public class StratosApiV41Utils {
}
serviceClient.addApplicationPolicy(applicationPolicy);
} catch (RemoteException e) {
- String msg = "Could not add application policy" + e.getLocalizedMessage();
+ String msg = "Could not add application policy. " + e.getLocalizedMessage();
log.error(msg, e);
throw new RestAPIException(msg);
} catch (AutoscalerServiceInvalidPolicyExceptionException e) {
@@ -581,7 +581,7 @@ public class StratosApiV41Utils {
log.error(msg, e);
throw new RestAPIException(msg);
} catch (AutoscalerServiceRemoteExceptionException e) {
- String msg = "Could not add application policy" + e.getLocalizedMessage();
+ String msg = "Could not add application policy. " + e.getLocalizedMessage();
log.error(msg, e);
throw new RestAPIException(msg);
} catch (AutoscalerServiceInvalidApplicationPolicyExceptionException e) {
@@ -2121,13 +2121,13 @@ public class StratosApiV41Utils {
}
} catch (AutoscalerServiceDeploymentPolicyNotExistsExceptionException e) {
String msg =
- "Deployment policy already exist [Deployment-policy-id]" + deployementPolicyDefinitionBean.getId();
+ "Deployment policy already exists [Deployment-policy-id]" + deployementPolicyDefinitionBean.getId();
log.error(msg, e);
throw new RestAPIException(msg);
} catch (Exception e) {
- String msg = "Could not add deployment policy";
+ String msg = "Could not add deployment policy.";
log.error(msg, e);
- throw new RestAPIException(msg);
+ throw new RestAPIException(msg, e);
}
}
[3/3] stratos git commit: Return 409 Conflict status if application,
autoscaling policy and kubernetes cluster already exists or
application already deployed
Posted by ch...@apache.org.
Return 409 Conflict status if application, autoscaling policy and kubernetes cluster already exists or application already deployed
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/db77fe03
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/db77fe03
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/db77fe03
Branch: refs/heads/master
Commit: db77fe036ad8c261c914396722edc8f09768d864
Parents: 477c366
Author: Chamila de Alwis <ch...@apache.org>
Authored: Sat Apr 18 00:48:21 2015 +0530
Committer: Chamila de Alwis <ch...@apache.org>
Committed: Sat Apr 18 00:48:21 2015 +0530
----------------------------------------------------------------------
.../common/client/AutoscalerServiceClient.java | 2 +-
.../rest/endpoint/api/StratosApiV40Utils.java | 2 +-
.../rest/endpoint/api/StratosApiV41.java | 70 ++++++++++++++------
.../rest/endpoint/api/StratosApiV41Utils.java | 2 +-
4 files changed, 54 insertions(+), 22 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/db77fe03/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/client/AutoscalerServiceClient.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/client/AutoscalerServiceClient.java b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/client/AutoscalerServiceClient.java
index 3949bec..2b7d0cb 100644
--- a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/client/AutoscalerServiceClient.java
+++ b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/client/AutoscalerServiceClient.java
@@ -146,7 +146,7 @@ public class AutoscalerServiceClient {
stub.deleteApplication(applicationId);
}
- public boolean deployAutoscalingPolicy(AutoscalePolicy autoScalePolicy) throws RemoteException,
+ public boolean addAutoscalingPolicy(AutoscalePolicy autoScalePolicy) throws RemoteException,
AutoscalerServiceInvalidPolicyExceptionException {
return stub.addAutoScalingPolicy(autoScalePolicy);
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/db77fe03/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV40Utils.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV40Utils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV40Utils.java
index 6c83add..2cdea8c 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV40Utils.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV40Utils.java
@@ -160,7 +160,7 @@ public class StratosApiV40Utils {
try {
autoscalerServiceClient
- .deployAutoscalingPolicy(autoscalePolicy);
+ .addAutoscalingPolicy(autoscalePolicy);
} catch (RemoteException e) {
log.error(e.getMessage(), e);
throw new RestAPIException(e.getMessage(), e);
http://git-wip-us.apache.org/repos/asf/stratos/blob/db77fe03/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java
index 371c709..4df702f 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java
@@ -627,12 +627,20 @@ public class StratosApiV41 extends AbstractApi {
@Consumes("application/json")
@AuthorizationAction("/permission/protected/manage/addApplication")
public Response addApplication(ApplicationBean applicationDefinition) throws RestAPIException {
- StratosApiV41Utils.addApplication(applicationDefinition, getConfigContext(), getUsername(), getTenantDomain());
+ try {
+ StratosApiV41Utils.addApplication(applicationDefinition, getConfigContext(), getUsername(), getTenantDomain());
- URI url = uriInfo.getAbsolutePathBuilder().path(applicationDefinition.getApplicationId()).build();
- return Response.created(url).entity(new SuccessResponseBean(Response.Status.CREATED.getStatusCode(),
- String.format("Application added successfully: [application] %s",
- applicationDefinition.getApplicationId()))).build();
+ URI url = uriInfo.getAbsolutePathBuilder().path(applicationDefinition.getApplicationId()).build();
+ return Response.created(url).entity(new SuccessResponseBean(Response.Status.CREATED.getStatusCode(),
+ String.format("Application added successfully: [application] %s",
+ applicationDefinition.getApplicationId()))).build();
+ } catch (RestAPIException e) {
+ if (e.getMessage().contains("already exists")) {
+ return Response.status(Response.Status.CONFLICT).build();
+ } else {
+ throw e;
+ }
+ }
}
/**
@@ -694,9 +702,17 @@ public class StratosApiV41 extends AbstractApi {
public Response deployApplication(
@PathParam("applicationId") String applicationId,
@PathParam("applicationPolicyId") String applicationPolicyId) throws RestAPIException {
- StratosApiV41Utils.deployApplication(applicationId, applicationPolicyId);
- return Response.accepted().entity(new SuccessResponseBean(Response.Status.ACCEPTED.getStatusCode(),
- String.format("Application deployed successfully: [application] %s", applicationId))).build();
+ try {
+ StratosApiV41Utils.deployApplication(applicationId, applicationPolicyId);
+ return Response.accepted().entity(new SuccessResponseBean(Response.Status.ACCEPTED.getStatusCode(),
+ String.format("Application deployed successfully: [application] %s", applicationId))).build();
+ } catch (RestAPIException e) {
+ if (e.getMessage().contains("already in DEPLOYED")) {
+ return Response.status(Response.Status.CONFLICT).build();
+ } else {
+ throw e;
+ }
+ }
}
/**
@@ -1124,11 +1140,19 @@ public class StratosApiV41 extends AbstractApi {
public Response addAutoscalingPolicy(
AutoscalePolicyBean autoscalePolicy) throws RestAPIException {
- StratosApiV41Utils.addAutoscalingPolicy(autoscalePolicy);
- URI url = uriInfo.getAbsolutePathBuilder().path(autoscalePolicy.getId()).build();
- return Response.created(url).entity(new SuccessResponseBean(Response.Status.CREATED.getStatusCode(),
- String.format("Autoscaling policy added successfully: [autoscale-policy] %s",
- autoscalePolicy.getId()))).build();
+ try {
+ StratosApiV41Utils.addAutoscalingPolicy(autoscalePolicy);
+ URI url = uriInfo.getAbsolutePathBuilder().path(autoscalePolicy.getId()).build();
+ return Response.created(url).entity(new SuccessResponseBean(Response.Status.CREATED.getStatusCode(),
+ String.format("Autoscaling policy added successfully: [autoscale-policy] %s",
+ autoscalePolicy.getId()))).build();
+ } catch (RestAPIException e) {
+ if (e.getMessage().contains("already exists")) {
+ return Response.status(Response.Status.CONFLICT).build();
+ } else {
+ throw e;
+ }
+ }
}
/**
@@ -1779,7 +1803,7 @@ public class StratosApiV41 extends AbstractApi {
public Response notifyRepository(
GitNotificationPayloadBean payload) throws RestAPIException {
if (log.isInfoEnabled()) {
- log.info(String.format("Git update"));
+ log.info(String.format("Git update notification received."));
}
StratosApiV41Utils.notifyArtifactUpdatedEvent(payload);
@@ -1942,11 +1966,19 @@ public class StratosApiV41 extends AbstractApi {
public Response addKubernetesHostCluster(
KubernetesClusterBean kubernetesCluster) throws RestAPIException {
- StratosApiV41Utils.addKubernetesCluster(kubernetesCluster);
- URI url = uriInfo.getAbsolutePathBuilder().path(kubernetesCluster.getClusterId()).build();
- return Response.created(url).entity(new SuccessResponseBean(Response.Status.CREATED.getStatusCode(),
- String.format("Kubernetes Host Cluster added successfully: [kub-host-cluster] %s",
- kubernetesCluster.getClusterId()))).build();
+ try {
+ StratosApiV41Utils.addKubernetesCluster(kubernetesCluster);
+ URI url = uriInfo.getAbsolutePathBuilder().path(kubernetesCluster.getClusterId()).build();
+ return Response.created(url).entity(new SuccessResponseBean(Response.Status.CREATED.getStatusCode(),
+ String.format("Kubernetes Host Cluster added successfully: [kub-host-cluster] %s",
+ kubernetesCluster.getClusterId()))).build();
+ } catch (RestAPIException e) {
+ if (e.getMessage().contains("already exists")) {
+ return Response.status(Response.Status.CONFLICT).build();
+ } else {
+ throw e;
+ }
+ }
}
/**
http://git-wip-us.apache.org/repos/asf/stratos/blob/db77fe03/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java
index 63f7300..03bb67d 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java
@@ -541,7 +541,7 @@ public class StratosApiV41Utils {
try {
autoscalerServiceClient
- .deployAutoscalingPolicy(autoscalePolicy);
+ .addAutoscalingPolicy(autoscalePolicy);
} catch (RemoteException e) {
log.error(e.getMessage(), e);
throw new RestAPIException(e.getMessage(), e);