Repository: stratos Updated Branches: refs/heads/tenant-isolation 4642ea9c8 -> 371f2f9d7
Fixing application deployment issues Project: http://git-wip-us.apache.org/repos/asf/stratos/repo Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/ecce38fe Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/ecce38fe Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/ecce38fe Branch: refs/heads/tenant-isolation Commit: ecce38fe187bbc734de62aa300bab914610b371c Parents: ff6c34a Author: Dinithi <[email protected]> Authored: Wed Jul 15 14:27:02 2015 +0530 Committer: Dinithi <[email protected]> Committed: Wed Jul 15 14:27:02 2015 +0530 ---------------------------------------------------------------------- .../services/impl/AutoscalerServiceImpl.java | 11 +++ .../common/client/AutoscalerServiceClient.java | 4 + .../rest/endpoint/api/StratosApiV41Utils.java | 16 ++++ .../util/converter/ObjectConverter.java | 3 +- .../src/main/resources/AutoscalerService.wsdl | 88 ++++++++++++++++---- 5 files changed, 103 insertions(+), 19 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/stratos/blob/ecce38fe/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 82723a9..c8b72e9 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 @@ -863,6 +863,17 @@ public class AutoscalerServiceImpl implements AutoscalerService { throw new AutoScalerException("Error occurred while retrieving cartridge group", e); } } + + public DeploymentPolicy getDeploymentPolicyByTenant(String deploymentPolicyId, int tenantId) { + DeploymentPolicy[] deploymentPolicies = getDeploymentPolicies(); + for(DeploymentPolicy deploymentPolicy : deploymentPolicies) { + if(deploymentPolicy.getId().equals(deploymentPolicyId ) && deploymentPolicy.getTenantId() == tenantId) { + return deploymentPolicy; + } + } + return null; + } + @Override public String findClusterId(String applicationId, String alias) { try { http://git-wip-us.apache.org/repos/asf/stratos/blob/ecce38fe/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 01c779b..f44271c 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 @@ -196,6 +196,10 @@ public class AutoscalerServiceClient { return stub.getServiceGroupByTenant(serviceGroupDefinitionName,tenantId); } + public DeploymentPolicy getDeploymentPolicyByTenant(String deploymentPolicyId,int tenantId) throws RemoteException { + return stub.getDeploymentPolicyByTenant(deploymentPolicyId, tenantId); + } + public ServiceGroup[] getServiceGroups() throws RemoteException, AutoscalerServiceAutoScalerExceptionException { return stub.getServiceGroups(); } http://git-wip-us.apache.org/repos/asf/stratos/blob/ecce38fe/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 f246e67..8cb13e9 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 @@ -3843,6 +3843,22 @@ public class StratosApiV41Utils { } } + /** + * Get deployment policy uuid by TenantId + * + * @return String Uuid + */ + public static String getDeploymentPolicyUuidByTenant(String deploymentPolicyId, + int tenantId) throws RestAPIException { + try { + AutoscalerServiceClient autoscalerServiceClient = AutoscalerServiceClient.getInstance(); + return (autoscalerServiceClient.getDeploymentPolicyByTenant(deploymentPolicyId, tenantId).getUuid()); + } catch (RemoteException e) { + String message = e.getMessage(); + log.error(message); + throw new RestAPIException(message, e); + } + } public static String getKubernetesClusterUuidByTenant(String clusterId,int tenantId) throws RestAPIException { http://git-wip-us.apache.org/repos/asf/stratos/blob/ecce38fe/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/util/converter/ObjectConverter.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/util/converter/ObjectConverter.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/util/converter/ObjectConverter.java index bcaac4f..707bd68 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/util/converter/ObjectConverter.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/util/converter/ObjectConverter.java @@ -1581,7 +1581,8 @@ public class ObjectConverter { groupContext.setGroupMaxInstances(groupDefinition.getGroupMaxInstances()); groupContext.setGroupMinInstances(groupDefinition.getGroupMinInstances()); groupContext.setDeploymentPolicy(groupDefinition.getDeploymentPolicy()); - groupContext.setDeploymentPolicyUuid(groupDefinition.getUuid()); + groupContext.setDeploymentPolicyUuid(StratosApiV41Utils.getDeploymentPolicyUuidByTenant(groupDefinition + .getDeploymentPolicy(), tenantId)); // Groups if (groupDefinition.getGroups() != null) { groupContext.setGroupContexts(convertGroupDefinitionsToStubGroupContexts(groupDefinition.getGroups(), http://git-wip-us.apache.org/repos/asf/stratos/blob/ecce38fe/service-stubs/org.apache.stratos.autoscaler.service.stub/src/main/resources/AutoscalerService.wsdl ---------------------------------------------------------------------- diff --git a/service-stubs/org.apache.stratos.autoscaler.service.stub/src/main/resources/AutoscalerService.wsdl b/service-stubs/org.apache.stratos.autoscaler.service.stub/src/main/resources/AutoscalerService.wsdl index 461ffec..dde3434 100644 --- a/service-stubs/org.apache.stratos.autoscaler.service.stub/src/main/resources/AutoscalerService.wsdl +++ b/service-stubs/org.apache.stratos.autoscaler.service.stub/src/main/resources/AutoscalerService.wsdl @@ -212,18 +212,6 @@ </xs:sequence> </xs:complexType> </xs:element> - <xs:element name="getApplications"> - <xs:complexType> - <xs:sequence/> - </xs:complexType> - </xs:element> - <xs:element name="getApplicationsResponse"> - <xs:complexType> - <xs:sequence> - <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="ax28:ApplicationContext"/> - </xs:sequence> - </xs:complexType> - </xs:element> <xs:element name="getServiceGroup"> <xs:complexType> <xs:sequence> @@ -238,17 +226,15 @@ </xs:sequence> </xs:complexType> </xs:element> - <xs:element name="getDeploymentPolicy"> + <xs:element name="getApplications"> <xs:complexType> - <xs:sequence> - <xs:element minOccurs="0" name="deploymentPolicyId" nillable="true" type="xs:string"/> - </xs:sequence> + <xs:sequence/> </xs:complexType> </xs:element> - <xs:element name="getDeploymentPolicyResponse"> + <xs:element name="getApplicationsResponse"> <xs:complexType> <xs:sequence> - <xs:element minOccurs="0" name="return" nillable="true" type="ax215:DeploymentPolicy"/> + <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="ax28:ApplicationContext"/> </xs:sequence> </xs:complexType> </xs:element> @@ -266,6 +252,20 @@ </xs:sequence> </xs:complexType> </xs:element> + <xs:element name="getDeploymentPolicy"> + <xs:complexType> + <xs:sequence> + <xs:element minOccurs="0" name="deploymentPolicyId" nillable="true" type="xs:string"/> + </xs:sequence> + </xs:complexType> + </xs:element> + <xs:element name="getDeploymentPolicyResponse"> + <xs:complexType> + <xs:sequence> + <xs:element minOccurs="0" name="return" nillable="true" type="ax215:DeploymentPolicy"/> + </xs:sequence> + </xs:complexType> + </xs:element> <xs:element name="getAutoscalingPolicy"> <xs:complexType> <xs:sequence> @@ -550,6 +550,21 @@ </xs:sequence> </xs:complexType> </xs:element> + <xs:element name="getDeploymentPolicyByTenant"> + <xs:complexType> + <xs:sequence> + <xs:element minOccurs="0" name="deploymentPolicyId" nillable="true" type="xs:string"/> + <xs:element minOccurs="0" name="tenantId" type="xs:int"/> + </xs:sequence> + </xs:complexType> + </xs:element> + <xs:element name="getDeploymentPolicyByTenantResponse"> + <xs:complexType> + <xs:sequence> + <xs:element minOccurs="0" name="return" nillable="true" type="ax215:DeploymentPolicy"/> + </xs:sequence> + </xs:complexType> + </xs:element> <xs:element name="findClusterId"> <xs:complexType> <xs:sequence> @@ -1172,6 +1187,12 @@ <wsdl:message name="getAutoscalingPolicyForTenantResponse"> <wsdl:part name="parameters" element="ns:getAutoscalingPolicyForTenantResponse"/> </wsdl:message> + <wsdl:message name="getDeploymentPolicyByTenantRequest"> + <wsdl:part name="parameters" element="ns:getDeploymentPolicyByTenant"/> + </wsdl:message> + <wsdl:message name="getDeploymentPolicyByTenantResponse"> + <wsdl:part name="parameters" element="ns:getDeploymentPolicyByTenantResponse"/> + </wsdl:message> <wsdl:message name="getAutoscalingPolicyRequest"> <wsdl:part name="parameters" element="ns:getAutoscalingPolicy"/> </wsdl:message> @@ -1387,6 +1408,10 @@ <wsdl:input message="ns:getAutoscalingPolicyForTenantRequest" wsaw:Action="urn:getAutoscalingPolicyForTenant"/> <wsdl:output message="ns:getAutoscalingPolicyForTenantResponse" wsaw:Action="urn:getAutoscalingPolicyForTenantResponse"/> </wsdl:operation> + <wsdl:operation name="getDeploymentPolicyByTenant"> + <wsdl:input message="ns:getDeploymentPolicyByTenantRequest" wsaw:Action="urn:getDeploymentPolicyByTenant"/> + <wsdl:output message="ns:getDeploymentPolicyByTenantResponse" wsaw:Action="urn:getDeploymentPolicyByTenantResponse"/> + </wsdl:operation> <wsdl:operation name="getAutoscalingPolicy"> <wsdl:input message="ns:getAutoscalingPolicyRequest" wsaw:Action="urn:getAutoscalingPolicy"/> <wsdl:output message="ns:getAutoscalingPolicyResponse" wsaw:Action="urn:getAutoscalingPolicyResponse"/> @@ -1739,6 +1764,15 @@ <soap:body use="literal"/> </wsdl:output> </wsdl:operation> + <wsdl:operation name="getDeploymentPolicyByTenant"> + <soap:operation soapAction="urn:getDeploymentPolicyByTenant" style="document"/> + <wsdl:input> + <soap:body use="literal"/> + </wsdl:input> + <wsdl:output> + <soap:body use="literal"/> + </wsdl:output> + </wsdl:operation> <wsdl:operation name="getAutoscalingPolicy"> <soap:operation soapAction="urn:getAutoscalingPolicy" style="document"/> <wsdl:input> @@ -2192,6 +2226,15 @@ <soap12:body use="literal"/> </wsdl:output> </wsdl:operation> + <wsdl:operation name="getDeploymentPolicyByTenant"> + <soap12:operation soapAction="urn:getDeploymentPolicyByTenant" style="document"/> + <wsdl:input> + <soap12:body use="literal"/> + </wsdl:input> + <wsdl:output> + <soap12:body use="literal"/> + </wsdl:output> + </wsdl:operation> <wsdl:operation name="getAutoscalingPolicy"> <soap12:operation soapAction="urn:getAutoscalingPolicy" style="document"/> <wsdl:input> @@ -2591,6 +2634,15 @@ <mime:content type="text/xml" part="parameters"/> </wsdl:output> </wsdl:operation> + <wsdl:operation name="getDeploymentPolicyByTenant"> + <http:operation location="getDeploymentPolicyByTenant"/> + <wsdl:input> + <mime:content type="text/xml" part="parameters"/> + </wsdl:input> + <wsdl:output> + <mime:content type="text/xml" part="parameters"/> + </wsdl:output> + </wsdl:operation> <wsdl:operation name="getAutoscalingPolicy"> <http:operation location="getAutoscalingPolicy"/> <wsdl:input>
