You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by is...@apache.org on 2013/12/04 18:57:18 UTC
[1/4] git commit: cartridge deployment through rest api - initial
implementation
Updated Branches:
refs/heads/master 0e94cb7ed -> 5f3e10b8c
cartridge deployment through rest api - initial implementation
Project: http://git-wip-us.apache.org/repos/asf/incubator-stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-stratos/commit/3f32200b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-stratos/tree/3f32200b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-stratos/diff/3f32200b
Branch: refs/heads/master
Commit: 3f32200b03ff5728cccfc7087c633347543df9b7
Parents: bb68f23
Author: Isuru <is...@wso2.com>
Authored: Tue Dec 3 23:05:49 2013 +0530
Committer: Isuru <is...@wso2.com>
Committed: Tue Dec 3 23:05:49 2013 +0530
----------------------------------------------------------------------
.../impl/CartridgeMgtServiceImpl.java | 40 ++++
.../interfaces/CartridgeMgtService.java | 29 +++
.../cloud/controller/pojo/CartridgeConfig.java | 208 +++++++++++++++++++
.../cloud/controller/pojo/IaasConfig.java | 90 ++++++++
.../cloud/controller/pojo/PortMapping.java | 5 +
.../stratos/cloud/controller/pojo/Property.java | 4 +
.../src/main/resources/META-INF/services.xml | 7 +
.../org.apache.stratos.rest.endpoint/pom.xml | 6 +
.../stratos/rest/endpoint/ServiceHolder.java | 7 +
.../definition/CartridgeDefinitionBean.java | 98 +++++++++
.../cartridge/definition/DeploymentBean.java | 46 ++++
.../cartridge/definition/IaasProviderBean.java | 51 +++++
.../cartridge/definition/PortMappingBean.java | 36 ++++
.../bean/cartridge/definition/PropertyBean.java | 30 +++
.../endpoint/bean/util/type/list/ListType.java | 39 ++++
.../endpoint/exception/RestAPIException.java | 50 +++++
.../client/CartridgeMgtServiceClient.java | 89 ++++++++
.../rest/endpoint/services/ServiceUtils.java | 149 ++++++++++++-
.../rest/endpoint/services/StratosAdmin.java | 23 ++
.../pom.xml | 130 ++++++++++++
.../src/main/resources/CartridgeMgtService.wsdl | 145 +++++++++++++
service-stubs/pom.xml | 1 +
22 files changed, 1282 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/3f32200b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CartridgeMgtServiceImpl.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CartridgeMgtServiceImpl.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CartridgeMgtServiceImpl.java
new file mode 100644
index 0000000..fd9ebac
--- /dev/null
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CartridgeMgtServiceImpl.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.cloud.controller.impl;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.cloud.controller.interfaces.CartridgeMgtService;
+import org.apache.stratos.cloud.controller.pojo.CartridgeConfig;
+
+public class CartridgeMgtServiceImpl implements CartridgeMgtService {
+
+ private static final Log log = LogFactory.getLog(CartridgeMgtServiceImpl.class);
+
+ public void deployCartridgeDefinition(CartridgeConfig cartridgeConfig) {
+
+ log.info("***** " + cartridgeConfig.toString() + " *****");
+ }
+
+ public void undeployCartridgeDefinition(String cartridgeType) {
+
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/3f32200b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CartridgeMgtService.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CartridgeMgtService.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CartridgeMgtService.java
new file mode 100644
index 0000000..ba1f1c5
--- /dev/null
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CartridgeMgtService.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.cloud.controller.interfaces;
+
+import org.apache.stratos.cloud.controller.pojo.CartridgeConfig;
+
+public interface CartridgeMgtService {
+
+ public void deployCartridgeDefinition (CartridgeConfig cartridgeConfig);
+
+ public void undeployCartridgeDefinition (String cartridgeType);
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/3f32200b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/CartridgeConfig.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/CartridgeConfig.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/CartridgeConfig.java
new file mode 100644
index 0000000..ed83262
--- /dev/null
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/CartridgeConfig.java
@@ -0,0 +1,208 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.cloud.controller.pojo;
+
+import java.io.Serializable;
+
+/**
+ * This class is used as the pojo for supporting the service at CC,
+ * which is called by the Rest API in SM to deploy a cartridge definition
+ */
+public class CartridgeConfig implements Serializable {
+
+ private String type;
+
+ private String hostName;
+
+ private String provider;
+
+ private String displayName;
+
+ private String description;
+
+ private String version;
+
+ private boolean multiTenant;
+
+ private String baseDir;
+
+ private String[] deploymentDirs;
+
+ private PortMapping[] portMappings;
+
+ private Properties properties;
+
+ private IaasConfig[] iaasConfigs;
+
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getHostName() {
+ return hostName;
+ }
+
+ public void setHostName(String hostName) {
+ this.hostName = hostName;
+ }
+
+ public String getProvider() {
+ return provider;
+ }
+
+ public void setProvider(String provider) {
+ this.provider = provider;
+ }
+
+ public String getDisplayName() {
+ return displayName;
+ }
+
+ public void setDisplayName(String displayName) {
+ this.displayName = displayName;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ public boolean isMultiTenant() {
+ return multiTenant;
+ }
+
+ public void setMultiTenant(boolean multiTenant) {
+ this.multiTenant = multiTenant;
+ }
+
+ public String getBaseDir() {
+ return baseDir;
+ }
+
+ public void setBaseDir(String baseDir) {
+ this.baseDir = baseDir;
+ }
+
+ public String[] getDeploymentDirs() {
+ return deploymentDirs;
+ }
+
+ public void setDeploymentDirs(String[] deploymentDirs) {
+ this.deploymentDirs = deploymentDirs;
+ }
+
+ public PortMapping[] getPortMappings() {
+ return portMappings;
+ }
+
+ public void setPortMappings(PortMapping[] portMappings) {
+ this.portMappings = portMappings;
+ }
+
+ public Properties getProperties() {
+ return properties;
+ }
+
+ public void setProperties(Properties properties) {
+ this.properties = properties;
+ }
+
+ public IaasConfig[] getIaasConfigs() {
+ return iaasConfigs;
+ }
+
+ public void setIaasConfigs(IaasConfig[] iaasConfigs) {
+ this.iaasConfigs = iaasConfigs;
+ }
+
+ public String toString () {
+
+ return "Type: " + type + ", Provider: " + provider + ", Host: " + hostName + ", Display Name: " + displayName +
+ ", Description: " + description + ", Version: " + version + ", Multitenant " + multiTenant +
+ "\n Deployment: " + getDeploymentDetails() + "\n PortMapping: " + getPortMappingDetails() +
+ "\n IaaS: " + getIaasConfigDetails() + "\n Properties: " + getPropertyDetails();
+ }
+
+ private String getDeploymentDetails () {
+
+ StringBuilder deploymentDetailBuilder = new StringBuilder();
+ deploymentDetailBuilder.append("Base direcotry: " + baseDir);
+ if(deploymentDirs.length > 0) {
+ deploymentDetailBuilder.append(" Direcotries: ");
+ for (String directory : deploymentDirs) {
+ deploymentDetailBuilder.append(directory + " | ");
+ }
+ }
+
+ return deploymentDetailBuilder.toString();
+ }
+
+ private String getPortMappingDetails () {
+
+ StringBuilder portMappingDetailBuilder = new StringBuilder();
+ if(portMappings.length > 0) {
+ for (PortMapping portMapping : portMappings) {
+ portMappingDetailBuilder.append(portMapping.toString() + " | ");
+ }
+ }
+ return portMappingDetailBuilder.toString();
+ }
+
+ private String getIaasConfigDetails () {
+
+ StringBuilder iaasConfigDetailBuilder = new StringBuilder();
+ if(iaasConfigs.length > 0) {
+ for (IaasConfig iaasConfig : iaasConfigs) {
+ iaasConfigDetailBuilder.append(iaasConfig.toString() + " | ");
+ }
+ }
+ return iaasConfigDetailBuilder.toString();
+ }
+
+ private String getPropertyDetails () {
+
+ StringBuilder propertyDetailBuilder = new StringBuilder();
+ if(properties != null) {
+ Property[] propertyArray = properties.getProperties();
+ if (propertyArray.length > 0) {
+ for (Property property : propertyArray) {
+ propertyDetailBuilder.append(property.toString() + " | ");
+ }
+ }
+ }
+ return propertyDetailBuilder.toString();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/3f32200b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/IaasConfig.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/IaasConfig.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/IaasConfig.java
new file mode 100644
index 0000000..70ac73d
--- /dev/null
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/IaasConfig.java
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.cloud.controller.pojo;
+
+import java.io.Serializable;
+
+/**
+ * This class is used to support <link>CartridgeConfig</link>
+ * class for the Rest API
+ */
+public class IaasConfig implements Serializable {
+
+ private String type;
+
+ private String imageId;
+
+ private int maxInstanceLimit;
+
+ private Properties properties;
+
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getImageId() {
+ return imageId;
+ }
+
+ public void setImageId(String imageId) {
+ this.imageId = imageId;
+ }
+
+ public int getMaxInstanceLimit() {
+ return maxInstanceLimit;
+ }
+
+ public void setMaxInstanceLimit(int maxInstanceLimit) {
+ this.maxInstanceLimit = maxInstanceLimit;
+ }
+
+ public Properties getProperties() {
+ return properties;
+ }
+
+ public void setProperties(Properties properties) {
+ this.properties = properties;
+ }
+
+ public String toString () {
+
+ return " [ Type: " + type + ", Image Id: " + imageId + ", Max Instance Limit: " + maxInstanceLimit +
+ " Properties: " + getIaasProperties() + " ] ";
+ }
+
+ private String getIaasProperties () {
+
+ StringBuilder iaasPropertyBuilder = new StringBuilder();
+ if (properties != null) {
+ Property [] propertyArray = properties.getProperties();
+ if(propertyArray.length > 0) {
+ for (Property property : propertyArray) {
+ iaasPropertyBuilder.append(property.toString() + " | ");
+ }
+ }
+ }
+ return iaasPropertyBuilder.toString();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/3f32200b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/PortMapping.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/PortMapping.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/PortMapping.java
index 65b52f7..63e222b 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/PortMapping.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/PortMapping.java
@@ -61,4 +61,9 @@ public class PortMapping implements Serializable{
this.proxyPort = proxyPort;
}
+ public String toString () {
+
+ return "Protocol: " + protocol + ", Port: " + port + ", Proxy Port: " + proxyPort;
+ }
+
}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/3f32200b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/Property.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/Property.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/Property.java
index d7c1ebf..0de93c1 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/Property.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/Property.java
@@ -54,4 +54,8 @@ public class Property implements Serializable{
this.value = value;
}
+ public String toString () {
+
+ return name + " : " + value;
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/3f32200b/components/org.apache.stratos.cloud.controller/src/main/resources/META-INF/services.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/resources/META-INF/services.xml b/components/org.apache.stratos.cloud.controller/src/main/resources/META-INF/services.xml
index 3c39159..bd47cd0 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/resources/META-INF/services.xml
+++ b/components/org.apache.stratos.cloud.controller/src/main/resources/META-INF/services.xml
@@ -28,4 +28,11 @@
<messageReceiver mep="http://www.w3.org/ns/wsdl/in-out" class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"/>
</messageReceivers>
</service>
+ <service name="CartridgeMgtService" scope="application">
+ <parameter name="ServiceClass">org.apache.stratos.cloud.controller.impl.CartridgeMgtServiceImpl</parameter>
+ <messageReceivers>
+ <messageReceiver mep="http://www.w3.org/ns/wsdl/in-only" class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver"/>
+ <messageReceiver mep="http://www.w3.org/ns/wsdl/in-out" class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"/>
+ </messageReceivers>
+ </service>
</serviceGroup>
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/3f32200b/components/org.apache.stratos.rest.endpoint/pom.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/pom.xml b/components/org.apache.stratos.rest.endpoint/pom.xml
index 71f6a25..e226a8f 100644
--- a/components/org.apache.stratos.rest.endpoint/pom.xml
+++ b/components/org.apache.stratos.rest.endpoint/pom.xml
@@ -100,5 +100,11 @@
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.stratos</groupId>
+ <artifactId>org.apache.stratos.cartridge.mgt.service.stub</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
</project>
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/3f32200b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/ServiceHolder.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/ServiceHolder.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/ServiceHolder.java
index 7ea6098..69e3aaa 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/ServiceHolder.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/ServiceHolder.java
@@ -26,6 +26,7 @@ import org.wso2.carbon.core.multitenancy.persistence.TenantPersistor;
import org.wso2.carbon.registry.core.service.RegistryService;
import org.wso2.carbon.user.core.service.RealmService;
import org.wso2.carbon.user.core.tenant.TenantManager;
+import org.wso2.carbon.utils.ConfigurationContextService;
/**
* Some of the admin services needs objects with states inside the runtime. There are
@@ -65,4 +66,10 @@ public class ServiceHolder {
return tenantPersistor;
}
+ public static ConfigurationContextService getConfigurationContext() {
+ PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
+ ConfigurationContextService configurationContextService = (ConfigurationContextService) carbonContext.
+ getOSGiService(ConfigurationContextService.class);
+ return configurationContextService;
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/3f32200b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/cartridge/definition/CartridgeDefinitionBean.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/cartridge/definition/CartridgeDefinitionBean.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/cartridge/definition/CartridgeDefinitionBean.java
new file mode 100644
index 0000000..68840dd
--- /dev/null
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/cartridge/definition/CartridgeDefinitionBean.java
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.rest.endpoint.bean.cartridge.definition;
+
+import javax.xml.bind.annotation.XmlRootElement;
+import java.util.List;
+
+@XmlRootElement(name = "cartridgeDefinitionBean")
+public class CartridgeDefinitionBean {
+
+ public String type;
+
+ public String host;
+
+ public String provider;
+
+ public String displayName;
+
+ public String description;
+
+ public String version;
+
+ public boolean multiTenant;
+
+ public DeploymentBean deployment;
+
+ public List<PortMappingBean> portMapping;
+
+ public List<IaasProviderBean> iaasProvider;
+
+ public List<PropertyBean> property;
+
+ public String toString () {
+
+ return "Type: " + type + ", Provider: " + provider + ", Host: " + host + ", Display Name: " + displayName +
+ ", Description: " + description + ", Version: " + version + ", Multitenant " + multiTenant + "\n" +
+ getDeploymentDetails() + "\n PortMapping: " + getPortMappings() + "\n IaaS: " + getIaasProviders() +
+ "\n Properties: " + getProperties();
+ }
+
+ private String getDeploymentDetails () {
+
+ if(deployment != null) {
+ return deployment.toString();
+ }
+ return null;
+ }
+
+ private String getPortMappings () {
+
+ StringBuilder portMappingBuilder = new StringBuilder();
+ if(portMapping != null && !portMapping.isEmpty()) {
+ for(PortMappingBean portMappingBean : portMapping) {
+ portMappingBuilder.append(portMappingBean.toString());
+ }
+ }
+ return portMappingBuilder.toString();
+ }
+
+ private String getIaasProviders () {
+
+ StringBuilder iaasBuilder = new StringBuilder();
+ if(iaasProvider != null && !iaasProvider.isEmpty()) {
+ for(IaasProviderBean iaasProviderBean : iaasProvider) {
+ iaasBuilder.append(iaasProviderBean.toString());
+ }
+ }
+ return iaasBuilder.toString();
+ }
+
+ private String getProperties () {
+
+ StringBuilder propertyBuilder = new StringBuilder();
+ if(property != null) {
+ for(PropertyBean propertyBean : property) {
+ propertyBuilder.append(propertyBean.name + " : " + propertyBean.value + " | ");
+ }
+ }
+ return propertyBuilder.toString();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/3f32200b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/cartridge/definition/DeploymentBean.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/cartridge/definition/DeploymentBean.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/cartridge/definition/DeploymentBean.java
new file mode 100644
index 0000000..97d0d2e
--- /dev/null
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/cartridge/definition/DeploymentBean.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.rest.endpoint.bean.cartridge.definition;
+
+import javax.xml.bind.annotation.XmlRootElement;
+import java.util.List;
+
+@XmlRootElement(name = "deployment")
+public class DeploymentBean {
+
+ public String baseDir;
+
+ public List<String> dir;
+
+ public String toString () {
+ return " Base Directory: " + baseDir + " Directories: " + getDirectories();
+ }
+
+ private String getDirectories () {
+
+ StringBuilder directoryBuilder = new StringBuilder();
+ if(dir != null) {
+ for(String directory : dir) {
+ directoryBuilder.append(directory + " | ");
+ }
+ }
+ return directoryBuilder.toString();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/3f32200b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/cartridge/definition/IaasProviderBean.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/cartridge/definition/IaasProviderBean.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/cartridge/definition/IaasProviderBean.java
new file mode 100644
index 0000000..5cd0667
--- /dev/null
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/cartridge/definition/IaasProviderBean.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.rest.endpoint.bean.cartridge.definition;
+
+import javax.xml.bind.annotation.XmlRootElement;
+import java.util.List;
+
+@XmlRootElement (name = "iaasProvider")
+public class IaasProviderBean {
+
+ public String type;
+
+ public String imageId;
+
+ public int maxInstanceLimit;
+
+ public List<PropertyBean> property;
+
+ public String toString () {
+ return " [ Type: " + type + ", Image Id: " + imageId + ", Max Instance Limit: " + maxInstanceLimit +
+ " Properties: " + getIaasProperties() + " ] ";
+ }
+
+ private String getIaasProperties () {
+
+ StringBuilder iaasPropertyBuilder = new StringBuilder();
+ if(property != null) {
+ for (PropertyBean propertyBean : property) {
+ iaasPropertyBuilder.append(propertyBean.name + " : " + propertyBean.value + " | ");
+ }
+ }
+ return iaasPropertyBuilder.toString();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/3f32200b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/cartridge/definition/PortMappingBean.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/cartridge/definition/PortMappingBean.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/cartridge/definition/PortMappingBean.java
new file mode 100644
index 0000000..bd11f5e
--- /dev/null
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/cartridge/definition/PortMappingBean.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.rest.endpoint.bean.cartridge.definition;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement(name = "portMapping")
+public class PortMappingBean {
+
+ public String protocol;
+
+ public int port;
+
+ public int proxyPort;
+
+ public String toString () {
+ return " [ Protocol: " + protocol + ", Port: " + port + ", Proxy port: " + proxyPort + "] ";
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/3f32200b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/cartridge/definition/PropertyBean.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/cartridge/definition/PropertyBean.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/cartridge/definition/PropertyBean.java
new file mode 100644
index 0000000..8bdd7e2
--- /dev/null
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/cartridge/definition/PropertyBean.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.rest.endpoint.bean.cartridge.definition;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement(name = "property")
+public class PropertyBean {
+
+ public String name;
+
+ public String value;
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/3f32200b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/type/list/ListType.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/type/list/ListType.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/type/list/ListType.java
new file mode 100644
index 0000000..36b0930
--- /dev/null
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/type/list/ListType.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.rest.endpoint.bean.util.type.list;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import java.util.List;
+
+@XmlRootElement(name = "List")
+public class ListType<T> {
+
+ private List<T> list;
+
+ @XmlElement(name="Item")
+ public List<T> getList() {
+ return list;
+ }
+
+ public void setList(List<T> list) {
+ this.list = list;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/3f32200b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/exception/RestAPIException.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/exception/RestAPIException.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/exception/RestAPIException.java
new file mode 100644
index 0000000..c483fef
--- /dev/null
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/exception/RestAPIException.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.rest.endpoint.exception;
+
+public class RestAPIException extends Exception {
+
+ private static final long serialVersionUID = 1L;
+
+ private String message;
+
+ public RestAPIException() {
+ super();
+ }
+
+ public RestAPIException(String message, Throwable cause) {
+ super(message, cause);
+ this.message = message;
+ }
+
+ public RestAPIException(String message) {
+ super(message);
+ this.message = message;
+ }
+
+ public RestAPIException(Throwable cause) {
+ super(cause);
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/3f32200b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/service/client/CartridgeMgtServiceClient.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/service/client/CartridgeMgtServiceClient.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/service/client/CartridgeMgtServiceClient.java
new file mode 100644
index 0000000..086c172
--- /dev/null
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/service/client/CartridgeMgtServiceClient.java
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.rest.endpoint.service.client;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.cartridge.mgt.stub.CartridgeMgtServiceStub;
+import org.apache.stratos.cloud.controller.pojo.CartridgeConfig;
+import org.apache.stratos.rest.endpoint.ServiceHolder;
+
+import java.rmi.RemoteException;
+
+public class CartridgeMgtServiceClient {
+
+ private CartridgeMgtServiceStub cartridgeMgtServiceStub;
+ private static final Log log = LogFactory.getLog(CartridgeMgtServiceClient.class);
+ private static volatile CartridgeMgtServiceClient serviceClient;
+ private static final String CARTRIDGE_MGT_EPR = "cartridge.mgt.epr";
+
+ private CartridgeMgtServiceClient(String epr) throws AxisFault {
+
+ ConfigurationContext clientConfigContext = ServiceHolder.getConfigurationContext().getClientConfigContext();
+ try {
+ cartridgeMgtServiceStub = new CartridgeMgtServiceStub(clientConfigContext, epr);
+ cartridgeMgtServiceStub._getServiceClient().getOptions().setTimeOutInMilliSeconds(300000);
+
+ } catch (AxisFault axisFault) {
+ String msg = "Failed to initiate CartridgeMgtServiceClient client. " + axisFault.getMessage();
+ log.error(msg, axisFault);
+ throw new AxisFault(msg, axisFault);
+ }
+
+ }
+
+ public static CartridgeMgtServiceClient getServiceClient() throws AxisFault {
+ if (serviceClient == null) {
+ synchronized (CartridgeMgtServiceClient.class) {
+ if (serviceClient == null) {
+ serviceClient = new CartridgeMgtServiceClient(System.getProperty(CARTRIDGE_MGT_EPR));
+ }
+ }
+ }
+ return serviceClient;
+ }
+
+ public void deployCartridgedefinition (CartridgeConfig cartridgeConfig)
+ throws Exception {
+
+ try {
+ cartridgeMgtServiceStub.deployCartridgeDefinition(cartridgeConfig);
+
+ } catch (RemoteException e) {
+ String errorMsg = "Transport error in deploying cartridge definition";
+ log.error(errorMsg, e);
+ throw new Exception(errorMsg, e);
+ }
+ }
+
+ public void undeployCartridgeDefinition (String cartridgeType) throws Exception {
+
+ try {
+ cartridgeMgtServiceStub.undeployCartridgeDefinition(cartridgeType);
+
+ } catch (RemoteException e) {
+ String errorMsg = "Transport error in undeploying cartridge definition type " + cartridgeType;
+ log.error(errorMsg, e);
+ throw new Exception(errorMsg, e);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/3f32200b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java
index 1e38a83..9ab0828 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java
@@ -34,8 +34,14 @@ import org.apache.stratos.adc.mgt.utils.ApplicationManagementUtil;
import org.apache.stratos.adc.mgt.utils.CartridgeConstants;
import org.apache.stratos.adc.mgt.utils.PersistenceManager;
import org.apache.stratos.adc.topology.mgt.service.TopologyManagementService;
+import org.apache.stratos.cloud.controller.pojo.*;
+import org.apache.stratos.rest.endpoint.bean.cartridge.definition.CartridgeDefinitionBean;
+import org.apache.stratos.rest.endpoint.bean.cartridge.definition.IaasProviderBean;
+import org.apache.stratos.rest.endpoint.bean.cartridge.definition.PortMappingBean;
+import org.apache.stratos.rest.endpoint.bean.cartridge.definition.PropertyBean;
+import org.apache.stratos.rest.endpoint.exception.RestAPIException;
+import org.apache.stratos.rest.endpoint.service.client.CartridgeMgtServiceClient;
import org.wso2.carbon.context.PrivilegedCarbonContext;
-import org.apache.stratos.cloud.controller.pojo.CartridgeInfo;
import java.util.ArrayList;
import java.util.Collections;
@@ -46,6 +52,147 @@ public class ServiceUtils {
private static Log log = LogFactory.getLog(StratosAdmin.class);
private static CartridgeSubscriptionManager cartridgeSubsciptionManager = new CartridgeSubscriptionManager();
+ static void deployCartridge (CartridgeDefinitionBean cartridgeDefinitionBean) throws RestAPIException {
+
+ log.info("***** " + cartridgeDefinitionBean.toString() + " *****");
+
+ CartridgeMgtServiceClient cartridgeMgtServiceClient = getCartridgeMgtServiceClient();
+ if (cartridgeMgtServiceClient != null) {
+
+ CartridgeConfig cartridgeConfig = populateCartridgeConfigPojo(cartridgeDefinitionBean);
+
+ if(cartridgeConfig == null) {
+ throw new RestAPIException("Populated CartridgeConfig instance is null, cartridge deployment aborted");
+ }
+
+ try {
+ cartridgeMgtServiceClient.deployCartridgedefinition(cartridgeConfig);
+
+ } catch (Exception e) {
+ throw new RestAPIException(e);
+ }
+ }
+ }
+
+ static CartridgeConfig populateCartridgeConfigPojo (CartridgeDefinitionBean cartridgeDefinitionBean) {
+
+ CartridgeConfig cartridgeConfig = new CartridgeConfig();
+
+ cartridgeConfig.setType(cartridgeDefinitionBean.type);
+ cartridgeConfig.setHostName(cartridgeDefinitionBean.host);
+ cartridgeConfig.setProvider(cartridgeDefinitionBean.provider);
+ cartridgeConfig.setVersion(cartridgeDefinitionBean.version);
+ cartridgeConfig.setMultiTenant(cartridgeDefinitionBean.multiTenant);
+ cartridgeConfig.setDisplayName(cartridgeDefinitionBean.displayName);
+ cartridgeConfig.setDescription(cartridgeDefinitionBean.description);
+ //deployment information
+ if(cartridgeDefinitionBean.deployment != null) {
+ cartridgeConfig.setBaseDir(cartridgeDefinitionBean.deployment.baseDir);
+ if(cartridgeDefinitionBean.deployment.dir != null && !cartridgeDefinitionBean.deployment.dir.isEmpty()) {
+ cartridgeConfig.setDeploymentDirs(cartridgeDefinitionBean.deployment.dir.
+ toArray(new String[cartridgeDefinitionBean.deployment.dir.size()]));
+ }
+ }
+ //port mapping
+ if(cartridgeDefinitionBean.portMapping != null && !cartridgeDefinitionBean.portMapping.isEmpty()) {
+ cartridgeConfig.setPortMappings(getPortMappingsAsArray(cartridgeDefinitionBean.portMapping));
+ }
+ //IaaS
+ if(cartridgeDefinitionBean.iaasProvider != null & !cartridgeDefinitionBean.iaasProvider.isEmpty()) {
+ cartridgeConfig.setIaasConfigs(getIaasConfigsAsArray(cartridgeDefinitionBean.iaasProvider));
+ }
+ //Properties
+ if(cartridgeDefinitionBean.property != null && !cartridgeDefinitionBean.property.isEmpty()) {
+ cartridgeConfig.setProperties(getProperties(cartridgeDefinitionBean.property));
+ }
+
+ return cartridgeConfig;
+ }
+
+ private static PortMapping[] getPortMappingsAsArray(List<PortMappingBean> portMappingBeans) {
+
+ //convert to an array
+ PortMappingBean [] portMappingBeanArray = new PortMappingBean[portMappingBeans.size()];
+ portMappingBeans.toArray(portMappingBeanArray);
+ PortMapping [] portMappingArray = new PortMapping[portMappingBeanArray.length];
+
+ for (int i = 0 ; i < portMappingBeanArray.length ; i++) {
+ PortMapping portMapping = new PortMapping();
+ portMapping.setProtocol(portMappingBeanArray[i].protocol);
+ portMapping.setPort(Integer.toString(portMappingBeanArray[i].port));
+ portMapping.setProxyPort(Integer.toString(portMappingBeanArray[i].proxyPort));
+ portMappingArray[i] = portMapping;
+ }
+
+ return portMappingArray;
+ }
+
+ private static IaasConfig[] getIaasConfigsAsArray (List<IaasProviderBean> iaasProviderBeans) {
+
+ //convert to an array
+ IaasProviderBean [] iaasProviderBeansArray = new IaasProviderBean[iaasProviderBeans.size()];
+ iaasProviderBeans.toArray(iaasProviderBeansArray);
+ IaasConfig [] iaasConfigsArray = new IaasConfig[iaasProviderBeansArray.length];
+
+ for (int i = 0 ; i < iaasProviderBeansArray.length ; i++) {
+ IaasConfig iaasConfig = new IaasConfig();
+ iaasConfig.setType(iaasProviderBeansArray[i].type);
+ iaasConfig.setImageId(iaasProviderBeansArray[i].imageId);
+ iaasConfig.setMaxInstanceLimit(iaasProviderBeansArray[i].maxInstanceLimit);
+
+ if(iaasProviderBeansArray[i].property != null && !iaasProviderBeansArray[i].property.isEmpty()) {
+ //set the Properties instance to IaasConfig instance
+ iaasConfig.setProperties(getProperties(iaasProviderBeansArray[i].property));
+ }
+ iaasConfigsArray[i] = iaasConfig;
+ }
+ return iaasConfigsArray;
+ }
+
+ private static Properties getProperties (List<PropertyBean> propertyBeans) {
+
+ //convert to an array
+ PropertyBean [] propertyBeansArray = new PropertyBean[propertyBeans.size()];
+ propertyBeans.toArray(propertyBeansArray);
+ Property [] propertyArray = new Property[propertyBeansArray.length];
+
+ for (int j = 0 ; j < propertyBeansArray.length ; j++) {
+ Property property = new Property();
+ property.setName(propertyBeansArray[j].name);
+ property.setValue(propertyBeansArray[j].value);
+ propertyArray[j] = property;
+ }
+
+ Properties properties = new Properties();
+ properties.setProperties(propertyArray);
+ return properties;
+ }
+
+ static void undeployCartridge (String cartridgeType) throws RestAPIException {
+
+ CartridgeMgtServiceClient cartridgeMgtServiceClient = getCartridgeMgtServiceClient();
+ if (cartridgeMgtServiceClient != null) {
+ try {
+ cartridgeMgtServiceClient.undeployCartridgeDefinition(cartridgeType);
+
+ } catch (Exception e) {
+ throw new RestAPIException(e);
+ }
+ }
+ }
+
+ private static CartridgeMgtServiceClient getCartridgeMgtServiceClient () {
+
+ try {
+ return CartridgeMgtServiceClient.getServiceClient();
+
+ } catch (AxisFault axisFault) {
+ String errorMsg = "Error in getting CartridgeMgtServiceClient instance";
+ log.error(errorMsg, axisFault);
+ }
+ return null;
+ }
+
static List<Cartridge> getAvailableCartridges(String cartridgeSearchString, Boolean multiTenant, ConfigurationContext configurationContext) throws ADCException {
List<Cartridge> cartridges = new ArrayList<Cartridge>();
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/3f32200b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java
index a40cbc6..06f447f 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java
@@ -31,6 +31,8 @@ import org.apache.stratos.rest.endpoint.ServiceHolder;
import org.apache.stratos.rest.endpoint.annotation.AuthorizationAction;
import org.apache.stratos.rest.endpoint.annotation.SuperTenantService;
import org.apache.stratos.rest.endpoint.bean.CartridgeInfoBean;
+import org.apache.stratos.rest.endpoint.bean.cartridge.definition.CartridgeDefinitionBean;
+import org.apache.stratos.rest.endpoint.exception.RestAPIException;
import org.apache.stratos.tenant.mgt.util.TenantMgtUtil;
import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.context.RegistryType;
@@ -51,7 +53,28 @@ import java.util.List;
public class StratosAdmin extends AbstractAdmin {
private static Log log = LogFactory.getLog(StratosAdmin.class);
+ @POST
+ @Path("/cartridge/definition/")
+ @Produces("application/json")
+ @Consumes("application/json")
+ @AuthorizationAction("/permission/protected/manage/monitor/tenants")
+ @SuperTenantService(true)
+ public void deployCartridgeDefinition (CartridgeDefinitionBean cartridgeDefinitionBean)
+ throws RestAPIException {
+
+ ServiceUtils.deployCartridge(cartridgeDefinitionBean);
+ }
+ @DELETE
+ @Path("/cartridge/definition/{cartridgeType}")
+ @Produces("application/json")
+ @Consumes("application/json")
+ @AuthorizationAction("/permission/protected/manage/monitor/tenants")
+ @SuperTenantService(true)
+ public void unDeployCartridgeDefinition (@PathParam("cartridgeType") String cartridgeType) throws RestAPIException {
+
+ ServiceUtils.undeployCartridge(cartridgeType);
+ }
@GET
@Path("/cartridge/tenanted/list")
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/3f32200b/service-stubs/org.apache.stratos.cartridge.mgt.service.stub/pom.xml
----------------------------------------------------------------------
diff --git a/service-stubs/org.apache.stratos.cartridge.mgt.service.stub/pom.xml b/service-stubs/org.apache.stratos.cartridge.mgt.service.stub/pom.xml
new file mode 100644
index 0000000..d50ea98
--- /dev/null
+++ b/service-stubs/org.apache.stratos.cartridge.mgt.service.stub/pom.xml
@@ -0,0 +1,130 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <parent>
+ <groupId>org.apache.stratos</groupId>
+ <artifactId>stratos-service-stubs-parent</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>org.apache.stratos.cartridge.mgt.service.stub</artifactId>
+ <packaging>bundle</packaging>
+ <name>Apache Stratos - Cartridge Mgt Service Stub</name>
+ <url>http://apache.org</url>
+
+ <build>
+ <plugins>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>source-code-generation</id>
+ <phase>process-resources</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <tasks>
+ <java classname="org.apache.axis2.wsdl.WSDL2Java" fork="true">
+ <arg line="-uri src/main/resources/CartridgeMgtService.wsdl -u -uw -o target/generated-code -p org.apache.stratos.cartridge.mgt.stub -ns2p http://exception.controller.cloud.stratos.apache.org/xsd=org.apache.stratos.cloud.controller.exception,http://pojo.controller.cloud.stratos.apache.org/xsd=org.apache.stratos.cloud.controller.pojo"/>
+ <classpath refid="maven.dependency.classpath"/>
+ <classpath refid="maven.compile.classpath"/>
+ <classpath refid="maven.runtime.classpath"/>
+ </java>
+ </tasks>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>add-source</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>add-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>
+ target/generated-code/src
+ </source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
+ <Bundle-Name>${project.artifactId}</Bundle-Name>
+ <Export-Package>
+ org.apache.stratos.cloud.controller.exception.*; version=${project.version},
+ org.apache.stratos.cloud.controller.pojo.*; version=${project.version},
+ org.apache.stratos.cartridge.mgt.stub.*; version=${project.version}
+ </Export-Package>
+ <Import-Package>
+ *;resolution:=optional
+ </Import-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.axis2.wso2</groupId>
+ <artifactId>axis2</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>wsdl4j.wso2</groupId>
+ <artifactId>wsdl4j</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ws.commons.schema.wso2</groupId>
+ <artifactId>XmlSchema</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ws.commons.axiom.wso2</groupId>
+ <artifactId>axiom</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.neethi.wso2</groupId>
+ <artifactId>neethi</artifactId>
+ </dependency>
+ </dependencies>
+
+</project>
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/3f32200b/service-stubs/org.apache.stratos.cartridge.mgt.service.stub/src/main/resources/CartridgeMgtService.wsdl
----------------------------------------------------------------------
diff --git a/service-stubs/org.apache.stratos.cartridge.mgt.service.stub/src/main/resources/CartridgeMgtService.wsdl b/service-stubs/org.apache.stratos.cartridge.mgt.service.stub/src/main/resources/CartridgeMgtService.wsdl
new file mode 100644
index 0000000..4051812
--- /dev/null
+++ b/service-stubs/org.apache.stratos.cartridge.mgt.service.stub/src/main/resources/CartridgeMgtService.wsdl
@@ -0,0 +1,145 @@
+<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:ns="http://impl.controller.cloud.stratos.apache.org" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:ax211="http://pojo.controller.cloud.stratos.apache.org/xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" targetNamespace="http://impl.controller.cloud.stratos.apache.org">
+ <wsdl:documentation>CartridgeMgtService</wsdl:documentation>
+ <wsdl:types>
+ <xs:schema xmlns:ax212="http://pojo.controller.cloud.stratos.apache.org/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://impl.controller.cloud.stratos.apache.org">
+ <xs:import namespace="http://pojo.controller.cloud.stratos.apache.org/xsd"/>
+ <xs:element name="undeployCartridgeDefinition">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="cartridgeType" nillable="true" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="deployCartridgeDefinition">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="cartridgeConfig" nillable="true" type="ax212:CartridgeConfig"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:schema>
+ <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://pojo.controller.cloud.stratos.apache.org/xsd">
+ <xs:complexType name="CartridgeConfig">
+ <xs:sequence>
+ <xs:element minOccurs="0" name="baseDir" nillable="true" type="xs:string"/>
+ <xs:element maxOccurs="unbounded" minOccurs="0" name="deploymentDirs" nillable="true" type="xs:string"/>
+ <xs:element minOccurs="0" name="description" nillable="true" type="xs:string"/>
+ <xs:element minOccurs="0" name="displayName" nillable="true" type="xs:string"/>
+ <xs:element minOccurs="0" name="hostName" nillable="true" type="xs:string"/>
+ <xs:element maxOccurs="unbounded" minOccurs="0" name="iaasConfigs" nillable="true" type="ax211:IaasConfig"/>
+ <xs:element minOccurs="0" name="multiTenant" type="xs:boolean"/>
+ <xs:element maxOccurs="unbounded" minOccurs="0" name="portMappings" nillable="true" type="ax211:PortMapping"/>
+ <xs:element minOccurs="0" name="properties" nillable="true" type="ax211:Properties"/>
+ <xs:element minOccurs="0" name="provider" nillable="true" type="xs:string"/>
+ <xs:element minOccurs="0" name="type" nillable="true" type="xs:string"/>
+ <xs:element minOccurs="0" name="version" nillable="true" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType name="IaasConfig">
+ <xs:sequence>
+ <xs:element minOccurs="0" name="imageId" nillable="true" type="xs:string"/>
+ <xs:element minOccurs="0" name="maxInstanceLimit" type="xs:int"/>
+ <xs:element minOccurs="0" name="properties" nillable="true" type="ax211:Properties"/>
+ <xs:element minOccurs="0" name="type" nillable="true" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType name="Properties">
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" minOccurs="0" name="properties" nillable="true" type="ax211:Property"/>
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType name="Property">
+ <xs:sequence>
+ <xs:element minOccurs="0" name="name" nillable="true" type="xs:string"/>
+ <xs:element minOccurs="0" name="value" nillable="true" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType name="PortMapping">
+ <xs:sequence>
+ <xs:element minOccurs="0" name="port" nillable="true" type="xs:string"/>
+ <xs:element minOccurs="0" name="protocol" nillable="true" type="xs:string"/>
+ <xs:element minOccurs="0" name="proxyPort" nillable="true" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:schema>
+ </wsdl:types>
+ <wsdl:message name="deployCartridgeDefinitionRequest">
+ <wsdl:part name="parameters" element="ns:deployCartridgeDefinition"/>
+ </wsdl:message>
+ <wsdl:message name="undeployCartridgeDefinitionRequest">
+ <wsdl:part name="parameters" element="ns:undeployCartridgeDefinition"/>
+ </wsdl:message>
+ <wsdl:portType name="CartridgeMgtServicePortType">
+ <wsdl:operation name="deployCartridgeDefinition">
+ <wsdl:input message="ns:deployCartridgeDefinitionRequest" wsaw:Action="urn:deployCartridgeDefinition"/>
+ </wsdl:operation>
+ <wsdl:operation name="undeployCartridgeDefinition">
+ <wsdl:input message="ns:undeployCartridgeDefinitionRequest" wsaw:Action="urn:undeployCartridgeDefinition"/>
+ </wsdl:operation>
+ </wsdl:portType>
+ <wsdl:binding name="CartridgeMgtServiceSoap11Binding" type="ns:CartridgeMgtServicePortType">
+ <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
+ <wsdl:operation name="deployCartridgeDefinition">
+ <soap:operation soapAction="urn:deployCartridgeDefinition" style="document"/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+ </wsdl:operation>
+ <wsdl:operation name="undeployCartridgeDefinition">
+ <soap:operation soapAction="urn:undeployCartridgeDefinition" style="document"/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:binding name="CartridgeMgtServiceSoap12Binding" type="ns:CartridgeMgtServicePortType">
+ <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
+ <wsdl:operation name="deployCartridgeDefinition">
+ <soap12:operation soapAction="urn:deployCartridgeDefinition" style="document"/>
+ <wsdl:input>
+ <soap12:body use="literal"/>
+ </wsdl:input>
+ </wsdl:operation>
+ <wsdl:operation name="undeployCartridgeDefinition">
+ <soap12:operation soapAction="urn:undeployCartridgeDefinition" style="document"/>
+ <wsdl:input>
+ <soap12:body use="literal"/>
+ </wsdl:input>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:binding name="CartridgeMgtServiceHttpBinding" type="ns:CartridgeMgtServicePortType">
+ <http:binding verb="POST"/>
+ <wsdl:operation name="deployCartridgeDefinition">
+ <http:operation location="deployCartridgeDefinition"/>
+ <wsdl:input>
+ <mime:content type="text/xml" part="parameters"/>
+ </wsdl:input>
+ </wsdl:operation>
+ <wsdl:operation name="undeployCartridgeDefinition">
+ <http:operation location="undeployCartridgeDefinition"/>
+ <wsdl:input>
+ <mime:content type="text/xml" part="parameters"/>
+ </wsdl:input>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:service name="CartridgeMgtService">
+ <wsdl:port name="CartridgeMgtServiceHttpsSoap11Endpoint" binding="ns:CartridgeMgtServiceSoap11Binding">
+ <soap:address location="https://10.144.132.229:9444/services/CartridgeMgtService.CartridgeMgtServiceHttpsSoap11Endpoint/"/>
+ </wsdl:port>
+ <wsdl:port name="CartridgeMgtServiceHttpSoap11Endpoint" binding="ns:CartridgeMgtServiceSoap11Binding">
+ <soap:address location="http://10.144.132.229:9764/services/CartridgeMgtService.CartridgeMgtServiceHttpSoap11Endpoint/"/>
+ </wsdl:port>
+ <wsdl:port name="CartridgeMgtServiceHttpSoap12Endpoint" binding="ns:CartridgeMgtServiceSoap12Binding">
+ <soap12:address location="http://10.144.132.229:9764/services/CartridgeMgtService.CartridgeMgtServiceHttpSoap12Endpoint/"/>
+ </wsdl:port>
+ <wsdl:port name="CartridgeMgtServiceHttpsSoap12Endpoint" binding="ns:CartridgeMgtServiceSoap12Binding">
+ <soap12:address location="https://10.144.132.229:9444/services/CartridgeMgtService.CartridgeMgtServiceHttpsSoap12Endpoint/"/>
+ </wsdl:port>
+ <wsdl:port name="CartridgeMgtServiceHttpsEndpoint" binding="ns:CartridgeMgtServiceHttpBinding">
+ <http:address location="https://10.144.132.229:9444/services/CartridgeMgtService.CartridgeMgtServiceHttpsEndpoint/"/>
+ </wsdl:port>
+ <wsdl:port name="CartridgeMgtServiceHttpEndpoint" binding="ns:CartridgeMgtServiceHttpBinding">
+ <http:address location="http://10.144.132.229:9764/services/CartridgeMgtService.CartridgeMgtServiceHttpEndpoint/"/>
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/3f32200b/service-stubs/pom.xml
----------------------------------------------------------------------
diff --git a/service-stubs/pom.xml b/service-stubs/pom.xml
index 908b70a..73dabcc 100644
--- a/service-stubs/pom.xml
+++ b/service-stubs/pom.xml
@@ -57,6 +57,7 @@
<module>org.apache.stratos.usage.meteringqueryds.stub</module>
<module>org.apache.stratos.manager.dashboard.stub</module>
<module>org.apache.stratos.usage.meteringsummarygenerationds.stub</module>
+ <module>org.apache.stratos.cartridge.mgt.service.stub</module>
</modules>
<build>
[3/4] git commit: completed cartridge deployment through rest api
Posted by is...@apache.org.
completed cartridge deployment through rest api
Project: http://git-wip-us.apache.org/repos/asf/incubator-stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-stratos/commit/5660364c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-stratos/tree/5660364c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-stratos/diff/5660364c
Branch: refs/heads/master
Commit: 5660364c929181a82fa79405cdccd9d0a844ee06
Parents: 685bd11
Author: Isuru <is...@wso2.com>
Authored: Wed Dec 4 23:09:06 2013 +0530
Committer: Isuru <is...@wso2.com>
Committed: Wed Dec 4 23:09:06 2013 +0530
----------------------------------------------------------------------
.../client/CloudControllerServiceClient.java | 27 ++++++++++++
.../org.apache.stratos.rest.endpoint/pom.xml | 6 +--
.../definition/CartridgeDefinitionBean.java | 12 +++++-
.../cartridge/definition/IaasProviderBean.java | 15 ++++++-
.../cartridge/definition/LoadBalancerBean.java | 44 ++++++++++++++++++++
.../client/CartridgeMgtServiceClient.java | 14 +------
.../rest/endpoint/services/ServiceUtils.java | 38 +++++++++++++----
.../rest/endpoint/services/StratosAdmin.java | 1 -
8 files changed, 129 insertions(+), 28 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/5660364c/components/org.apache.stratos.adc.mgt/src/main/java/org/apache/stratos/adc/mgt/client/CloudControllerServiceClient.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.adc.mgt/src/main/java/org/apache/stratos/adc/mgt/client/CloudControllerServiceClient.java b/components/org.apache.stratos.adc.mgt/src/main/java/org/apache/stratos/adc/mgt/client/CloudControllerServiceClient.java
index 703f467..4434625 100644
--- a/components/org.apache.stratos.adc.mgt/src/main/java/org/apache/stratos/adc/mgt/client/CloudControllerServiceClient.java
+++ b/components/org.apache.stratos.adc.mgt/src/main/java/org/apache/stratos/adc/mgt/client/CloudControllerServiceClient.java
@@ -26,6 +26,7 @@ import org.apache.commons.logging.LogFactory;
import org.apache.stratos.adc.mgt.exception.UnregisteredCartridgeException;
import org.apache.stratos.adc.mgt.internal.DataHolder;
import org.apache.stratos.adc.mgt.utils.CartridgeConstants;
+import org.apache.stratos.cloud.controller.pojo.CartridgeConfig;
import org.apache.stratos.cloud.controller.pojo.CartridgeInfo;
import org.apache.stratos.cloud.controller.pojo.Registrant;
import org.apache.stratos.cloud.controller.stub.CloudControllerServiceIllegalArgumentExceptionException;
@@ -71,6 +72,32 @@ public class CloudControllerServiceClient {
return serviceClient;
}
+ public void deployCartridgeDefinition (CartridgeConfig cartridgeConfig)
+ throws Exception {
+
+ try {
+ stub.deployCartridgeDefinition(cartridgeConfig);
+
+ } catch (RemoteException e) {
+ String errorMsg = "Error in deploying cartridge definition";
+ log.error(errorMsg, e);
+ throw new Exception(errorMsg, e);
+ }
+ }
+
+ public void unDeployCartridgeDefinition (String cartridgeType)
+ throws Exception {
+
+ try {
+ stub.undeployCartridgeDefinition(cartridgeType);
+
+ } catch (RemoteException e) {
+ String errorMsg = "Error in deploying cartridge definition";
+ log.error(errorMsg, e);
+ throw new Exception(errorMsg, e);
+ }
+ }
+
public boolean register(String clusterId, String cartridgeType,
String payload, String tenantRange,
String hostName, Properties properties,
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/5660364c/components/org.apache.stratos.rest.endpoint/pom.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/pom.xml b/components/org.apache.stratos.rest.endpoint/pom.xml
index e226a8f..71bb563 100644
--- a/components/org.apache.stratos.rest.endpoint/pom.xml
+++ b/components/org.apache.stratos.rest.endpoint/pom.xml
@@ -97,14 +97,14 @@
<dependency>
<groupId>org.apache.stratos</groupId>
<artifactId>org.apache.stratos.cloud.controller.service.stub</artifactId>
- <version>${project.version}</version>
+ <version>4.0.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
- <dependency>
+ <!--dependency>
<groupId>org.apache.stratos</groupId>
<artifactId>org.apache.stratos.cartridge.mgt.service.stub</artifactId>
<version>4.0.0-SNAPSHOT</version>
<scope>provided</scope>
- </dependency>
+ </dependency-->
</dependencies>
</project>
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/5660364c/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/cartridge/definition/CartridgeDefinitionBean.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/cartridge/definition/CartridgeDefinitionBean.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/cartridge/definition/CartridgeDefinitionBean.java
index 68840dd..318e347 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/cartridge/definition/CartridgeDefinitionBean.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/cartridge/definition/CartridgeDefinitionBean.java
@@ -45,6 +45,8 @@ public class CartridgeDefinitionBean {
public List<IaasProviderBean> iaasProvider;
+ public LoadBalancerBean loadBalancer;
+
public List<PropertyBean> property;
public String toString () {
@@ -52,7 +54,7 @@ public class CartridgeDefinitionBean {
return "Type: " + type + ", Provider: " + provider + ", Host: " + host + ", Display Name: " + displayName +
", Description: " + description + ", Version: " + version + ", Multitenant " + multiTenant + "\n" +
getDeploymentDetails() + "\n PortMapping: " + getPortMappings() + "\n IaaS: " + getIaasProviders() +
- "\n Properties: " + getProperties();
+ "\n LoadBalancer: " + getLoadBalancerInfo() + "\n Properties: " + getProperties();
}
private String getDeploymentDetails () {
@@ -63,6 +65,14 @@ public class CartridgeDefinitionBean {
return null;
}
+ private String getLoadBalancerInfo() {
+
+ if(loadBalancer != null) {
+ return loadBalancer.toString();
+ }
+ return null;
+ }
+
private String getPortMappings () {
StringBuilder portMappingBuilder = new StringBuilder();
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/5660364c/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/cartridge/definition/IaasProviderBean.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/cartridge/definition/IaasProviderBean.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/cartridge/definition/IaasProviderBean.java
index 5cd0667..0ccb33c 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/cartridge/definition/IaasProviderBean.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/cartridge/definition/IaasProviderBean.java
@@ -27,15 +27,26 @@ public class IaasProviderBean {
public String type;
+ public String name;
+
+ public String className;
+
public String imageId;
public int maxInstanceLimit;
+ public String provider;
+
+ public String identity;
+
+ public String credential;
+
public List<PropertyBean> property;
public String toString () {
- return " [ Type: " + type + ", Image Id: " + imageId + ", Max Instance Limit: " + maxInstanceLimit +
- " Properties: " + getIaasProperties() + " ] ";
+ return " [ Type: " + type + ", Name: " + name + ", Class Name: " + className + ", Image Id: " + imageId +
+ ", Max Instance Limit: " + maxInstanceLimit + ", Provider: " + provider + ", Identity: " + identity +
+ ", Credentials: " + credential + ", Properties: " + getIaasProperties() + " ] ";
}
private String getIaasProperties () {
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/5660364c/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/cartridge/definition/LoadBalancerBean.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/cartridge/definition/LoadBalancerBean.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/cartridge/definition/LoadBalancerBean.java
new file mode 100644
index 0000000..c21c867
--- /dev/null
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/cartridge/definition/LoadBalancerBean.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.rest.endpoint.bean.cartridge.definition;
+
+import javax.xml.bind.annotation.XmlRootElement;
+import java.util.List;
+
+@XmlRootElement(name = "loadBalancer")
+public class LoadBalancerBean {
+
+ public String type;
+
+ public List<PropertyBean> property;
+
+ public String toString () {
+
+ StringBuilder lbBuilder = new StringBuilder();
+ lbBuilder.append(" Type: " + type);
+ if(property != null && !property.isEmpty()) {
+ lbBuilder.append(" Properties: ");
+ for(PropertyBean propertyBean : property) {
+ lbBuilder.append(propertyBean.name + " : " + propertyBean.value + " | ");
+ }
+ }
+ return lbBuilder.toString();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/5660364c/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/service/client/CartridgeMgtServiceClient.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/service/client/CartridgeMgtServiceClient.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/service/client/CartridgeMgtServiceClient.java
index 086c172..4b497cf 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/service/client/CartridgeMgtServiceClient.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/service/client/CartridgeMgtServiceClient.java
@@ -19,19 +19,9 @@
package org.apache.stratos.rest.endpoint.service.client;
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.cartridge.mgt.stub.CartridgeMgtServiceStub;
-import org.apache.stratos.cloud.controller.pojo.CartridgeConfig;
-import org.apache.stratos.rest.endpoint.ServiceHolder;
-
-import java.rmi.RemoteException;
-
public class CartridgeMgtServiceClient {
- private CartridgeMgtServiceStub cartridgeMgtServiceStub;
+ /*private CartridgeMgtServiceStub cartridgeMgtServiceStub;
private static final Log log = LogFactory.getLog(CartridgeMgtServiceClient.class);
private static volatile CartridgeMgtServiceClient serviceClient;
private static final String CARTRIDGE_MGT_EPR = "cartridge.mgt.epr";
@@ -85,5 +75,5 @@ public class CartridgeMgtServiceClient {
log.error(errorMsg, e);
throw new Exception(errorMsg, e);
}
- }
+ } */
}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/5660364c/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java
index 9ab0828..3dfb32e 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java
@@ -40,7 +40,6 @@ import org.apache.stratos.rest.endpoint.bean.cartridge.definition.IaasProviderBe
import org.apache.stratos.rest.endpoint.bean.cartridge.definition.PortMappingBean;
import org.apache.stratos.rest.endpoint.bean.cartridge.definition.PropertyBean;
import org.apache.stratos.rest.endpoint.exception.RestAPIException;
-import org.apache.stratos.rest.endpoint.service.client.CartridgeMgtServiceClient;
import org.wso2.carbon.context.PrivilegedCarbonContext;
import java.util.ArrayList;
@@ -56,8 +55,8 @@ public class ServiceUtils {
log.info("***** " + cartridgeDefinitionBean.toString() + " *****");
- CartridgeMgtServiceClient cartridgeMgtServiceClient = getCartridgeMgtServiceClient();
- if (cartridgeMgtServiceClient != null) {
+ CloudControllerServiceClient cloudControllerServiceClient = getCloudControllerServiceClient();
+ if (cloudControllerServiceClient != null) {
CartridgeConfig cartridgeConfig = populateCartridgeConfigPojo(cartridgeDefinitionBean);
@@ -66,7 +65,7 @@ public class ServiceUtils {
}
try {
- cartridgeMgtServiceClient.deployCartridgedefinition(cartridgeConfig);
+ cloudControllerServiceClient.deployCartridgeDefinition(cartridgeConfig);
} catch (Exception e) {
throw new RestAPIException(e);
@@ -101,6 +100,10 @@ public class ServiceUtils {
if(cartridgeDefinitionBean.iaasProvider != null & !cartridgeDefinitionBean.iaasProvider.isEmpty()) {
cartridgeConfig.setIaasConfigs(getIaasConfigsAsArray(cartridgeDefinitionBean.iaasProvider));
}
+ //LB
+ if(cartridgeDefinitionBean.loadBalancer != null) {
+ //cartridgeConfig.set
+ }
//Properties
if(cartridgeDefinitionBean.property != null && !cartridgeDefinitionBean.property.isEmpty()) {
cartridgeConfig.setProperties(getProperties(cartridgeDefinitionBean.property));
@@ -139,6 +142,11 @@ public class ServiceUtils {
iaasConfig.setType(iaasProviderBeansArray[i].type);
iaasConfig.setImageId(iaasProviderBeansArray[i].imageId);
iaasConfig.setMaxInstanceLimit(iaasProviderBeansArray[i].maxInstanceLimit);
+ iaasConfig.setName(iaasProviderBeansArray[i].name);
+ iaasConfig.setClassName(iaasProviderBeansArray[i].className);
+ iaasConfig.setCredential(iaasProviderBeansArray[i].credential);
+ iaasConfig.setIdentity(iaasProviderBeansArray[i].identity);
+ iaasConfig.setProvider(iaasProviderBeansArray[i].provider);
if(iaasProviderBeansArray[i].property != null && !iaasProviderBeansArray[i].property.isEmpty()) {
//set the Properties instance to IaasConfig instance
@@ -170,10 +178,10 @@ public class ServiceUtils {
static void undeployCartridge (String cartridgeType) throws RestAPIException {
- CartridgeMgtServiceClient cartridgeMgtServiceClient = getCartridgeMgtServiceClient();
- if (cartridgeMgtServiceClient != null) {
+ CloudControllerServiceClient cloudControllerServiceClient = getCloudControllerServiceClient();
+ if (cloudControllerServiceClient != null) {
try {
- cartridgeMgtServiceClient.undeployCartridgeDefinition(cartridgeType);
+ cloudControllerServiceClient.unDeployCartridgeDefinition(cartridgeType);
} catch (Exception e) {
throw new RestAPIException(e);
@@ -181,7 +189,19 @@ public class ServiceUtils {
}
}
- private static CartridgeMgtServiceClient getCartridgeMgtServiceClient () {
+ private static CloudControllerServiceClient getCloudControllerServiceClient () {
+
+ try {
+ return CloudControllerServiceClient.getServiceClient();
+
+ } catch (AxisFault axisFault) {
+ String errorMsg = "Error in getting CloudControllerServiceClient instance";
+ log.error(errorMsg, axisFault);
+ }
+ return null;
+ }
+
+ /*private static CartridgeMgtServiceClient getCartridgeMgtServiceClient () {
try {
return CartridgeMgtServiceClient.getServiceClient();
@@ -191,7 +211,7 @@ public class ServiceUtils {
log.error(errorMsg, axisFault);
}
return null;
- }
+ }*/
static List<Cartridge> getAvailableCartridges(String cartridgeSearchString, Boolean multiTenant, ConfigurationContext configurationContext) throws ADCException {
List<Cartridge> cartridges = new ArrayList<Cartridge>();
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/5660364c/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java
index 06f447f..cd82c07 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java
@@ -198,7 +198,6 @@ public class StratosAdmin extends AbstractAdmin {
}
-
@PUT
@Path("/tenant")
@Consumes("application/json")
[2/4] git commit: Merge branch 'master' of
https://git-wip-us.apache.org/repos/asf/incubator-stratos into rest_api
Posted by is...@apache.org.
Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/incubator-stratos into rest_api
Project: http://git-wip-us.apache.org/repos/asf/incubator-stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-stratos/commit/685bd119
Tree: http://git-wip-us.apache.org/repos/asf/incubator-stratos/tree/685bd119
Diff: http://git-wip-us.apache.org/repos/asf/incubator-stratos/diff/685bd119
Branch: refs/heads/master
Commit: 685bd1194ae0e67a03a4223430861434cdd6e14c
Parents: 3f32200 2da09be
Author: Isuru <is...@wso2.com>
Authored: Wed Dec 4 10:47:45 2013 +0530
Committer: Isuru <is...@wso2.com>
Committed: Wed Dec 4 10:47:45 2013 +0530
----------------------------------------------------------------------
.../stream-manager-config.xml | 163 +++++++++++++++++++
1 file changed, 163 insertions(+)
----------------------------------------------------------------------
[4/4] git commit: fixing merge confilcts in CC component
Posted by is...@apache.org.
fixing merge confilcts in CC component
Project: http://git-wip-us.apache.org/repos/asf/incubator-stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-stratos/commit/5f3e10b8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-stratos/tree/5f3e10b8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-stratos/diff/5f3e10b8
Branch: refs/heads/master
Commit: 5f3e10b8c88de7f0483d502f42bd7ad7cdbe7b38
Parents: 5660364 0e94cb7
Author: Isuru <is...@wso2.com>
Authored: Wed Dec 4 23:26:07 2013 +0530
Committer: Isuru <is...@wso2.com>
Committed: Wed Dec 4 23:26:07 2013 +0530
----------------------------------------------------------------------
.../mgt/listener/InstanceStatusListener.java | 60 ++--
.../stratos/autoscaler/AutoscalerContext.java | 2 +-
.../impl/CloudControllerServiceImpl.java | 136 ++++---
.../interfaces/CloudControllerService.java | 8 +
.../cloud/controller/pojo/Cartridge.java | 6 +
.../cloud/controller/pojo/CartridgeConfig.java | 2 +
.../cloud/controller/pojo/IaasConfig.java | 64 +++-
.../cloud/controller/pojo/IaasProvider.java | 48 +--
.../controller/util/CloudControllerUtil.java | 101 ++++++
.../statistics/WSO2CEPStatsPublisher.java | 10 +-
.../load/balancer/LoadBalancerContext.java | 2 +-
.../internal/LoadBalancerServiceComponent.java | 7 +-
.../broker/publish/TopicPublisher.java | 2 +-
.../cartridge-agent/ec2/php/cartridge-agent.sh | 75 +---
.../git/impl/GitBasedArtifactRepository.java | 21 ++
.../event/subscriber/ArtifactListener.java | 57 ++-
.../subscriber/CartridgeAgentConstants.java | 3 +
.../event/subscriber/LaunchParamsUtil.java | 58 +++
.../cartridge/agent/event/subscriber/Main.java | 22 +-
.../pom.xml | 131 +++++++
.../src/main/resources/AutoScalerService.wsdl | 359 +++++++++++++++++++
.../main/resources/CloudControllerService.wsdl | 144 +++++++-
22 files changed, 1088 insertions(+), 230 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/5f3e10b8/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/CartridgeConfig.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/5f3e10b8/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/IaasConfig.java
----------------------------------------------------------------------
diff --cc components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/IaasConfig.java
index 70ac73d,b20f2d3..dfddde8
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/IaasConfig.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/IaasConfig.java
@@@ -27,8 -27,16 +27,17 @@@ import java.io.Serializable
*/
public class IaasConfig implements Serializable {
- private String type;
+
+ private static final long serialVersionUID = 3329046207651171707L;
+
+ private String type;
+
+ private String className;
+
+ private String name;
+
+ private String provider, identity, credential;
+
private String imageId;
private int maxInstanceLimit;