Hi Damitha,
Please ignore my previous patch file. Refer to the patch file attached
herewith.
On Mon, Mar 19, 2012 at 7:47 AM, Sajith Kariyawasam <[email protected]> wrote:
>
> Hi Damitha,
>
> Please find the attached patch file, which includes worker node agent
> service related changes. Also I have done code cleanups and formatting
>
> SVN location is -> URL:
> https://svn.wso2.org/repos/wso2/carbon/platform/trunk/components/hosting-mgt/org.wso2.carbon.hosting.wnagent
>
>
> --
> Thanks,
> Sajith
>
>
--
Thanks,
Sajith
Index: src/test/java/org/wso2/carbon/hosting/wnagent/WNAgentTest.java
===================================================================
--- src/test/java/org/wso2/carbon/hosting/wnagent/WNAgentTest.java (revision 0)
+++ src/test/java/org/wso2/carbon/hosting/wnagent/WNAgentTest.java (revision 0)
@@ -0,0 +1,74 @@
+package org.wso2.carbon.hosting.wnagent;
+
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.wso2.carbon.hosting.wnagent.dto.Container;
+import org.wso2.carbon.hosting.wnagent.service.WorkerNodeAgentService;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: damitha
+ * Date: 1/19/12
+ * Time: 4:45 PM
+ * To change this template use File | Settings | File Templates.
+ */
+
+public class WNAgentTest {
+ @Before
+ public void setUp() throws Exception {
+
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @BeforeClass
+ public static void runBeforeClass() throws Exception {
+
+ }
+
+ @AfterClass
+ public static void runAfterClass() {
+
+ }
+
+ // @Test(expected = Exception.class)
+ @Test()
+ public void testAddContainerToRegistry() {
+ try {
+
+ WorkerNodeAgentService agentService = new WorkerNodeAgentService();
+
+ Container container = new Container();
+
+ container.setIp("10.100.80.2");
+ container.setJailRoot("/mnt/lxc");
+ container.setJailKeysFile("/home/wso2/container_steup/jailKeysFilePath");
+ container.setTemplate("template-ubuntu-lucid-lamp");
+ container.setZone("public");
+
+ container.setBridge("br-lxc");
+ container.setNetMask("255.255.255.0");
+ container.setNetGateway("192.168.254.1");
+
+ container.setMemory("512M");
+ container.setSwap("1G");
+ container.setCpuShares("1024");
+ container.setCpuSetShares("0-7");
+ container.setStorage("5G");
+
+ int ret = agentService.createContainer("ying", "g", container);
+ Assert.assertEquals(1, ret);
+
+ } catch (Exception e) {
+
+ e.printStackTrace();
+ Assert.assertTrue(false);
+ }
+ }
+}
Index: src/test/java/org/wso2/carbon/hosting/wnagent/WNAgentTestSuite.java
===================================================================
--- src/test/java/org/wso2/carbon/hosting/wnagent/WNAgentTestSuite.java (revision 0)
+++ src/test/java/org/wso2/carbon/hosting/wnagent/WNAgentTestSuite.java (revision 0)
@@ -0,0 +1,37 @@
+package org.wso2.carbon.hosting.wnagent;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
+
+import org.wso2.carbon.hosting.wnagent.WNAgentTest;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: damitha
+ * Date: 1/19/12
+ * Time: 2:54 PM
+ * To change this template use File | Settings | File Templates.
+ */
+
+// / /// /// /// /// /// /// /// /// /// /// /// ///
+// private static final String wso2hostingHome =
+// System.getProperty("wso2hosting.home");
+// You should import the Test Case Classes here.
+
+// / /// /// /// /// ///
+@RunWith(Suite.class)
+// / /// /// /// /// /// /// /// ///
+// List the Test Case Classes here.
+@SuiteClasses({
+ // /// ///// ///// ///// ///// ///// ///// ///// /////
+ // Comment the class(es) that you doesn't want to run.
+ WNAgentTest.class
+
+})
+// / /// /// /// /// /// /// /// /// /// /// /// /// /// /// ////// /// /// ///
+// /// /// /// /// ///
+// Name your Test Suit Class here, you should point the IntelliJ JUnit
+// Configuration to this class.
+public class WNAgentTestSuite {
+}
Index: src/test/java/org/wso2/carbon/hosting/mgt/WNAgentTest.java
===================================================================
--- src/test/java/org/wso2/carbon/hosting/mgt/WNAgentTest.java (revision 122945)
+++ src/test/java/org/wso2/carbon/hosting/mgt/WNAgentTest.java (working copy)
@@ -1,64 +0,0 @@
-package org.wso2.carbon.hosting.wnagent;
-
-import org.junit.*;
-import org.wso2.carbon.hosting.wnagent.dto.Container;
-
-/**
- * Created by IntelliJ IDEA.
- * User: damitha
- * Date: 1/19/12
- * Time: 4:45 PM
- * To change this template use File | Settings | File Templates.
- */
-
-public class WNAgentTest {
- @Before
- public void setUp() throws Exception {
-
- }
-
- @After
- public void tearDown() throws Exception {
- }
-
- @BeforeClass
- public static void runBeforeClass() throws Exception {
-
- }
-
- @AfterClass
- public static void runAfterClass() {
-
- }
-
- //@Test(expected = Exception.class)
- @Test()
- public void testAddContainerToRegistry() {
- try {
- String retVal;
- WNAgent agent = new WNAgent();
-
- Container container = new Container();
- container.setJailRoot("/mnt/lxc");
- container.setTemplate("template-ubuntu-lucid-lamp");
- container.setZone("public");
-
- container.setBridge("br-lxc");
- container.setNetMask("255.255.255.0");
- container.setNetGateway("192.168.254.1");
-
- container.setMemory("512M");
- container.setSwap("1G");
- container.setCpuShares("1024");
- container.setCpuSetShares("0-7");
- container.setStorage("5G");
- int ret = agent.createContainer("ying", "g", container);
- Assert.assertEquals(0, ret);
-
- } catch(Exception e) {
- Assert.assertTrue(false);
- e.printStackTrace();
- }
- }
-}
-
Index: src/test/java/org/wso2/carbon/hosting/mgt/WNAgentTestSuite.java
===================================================================
--- src/test/java/org/wso2/carbon/hosting/mgt/WNAgentTestSuite.java (revision 122945)
+++ src/test/java/org/wso2/carbon/hosting/mgt/WNAgentTestSuite.java (working copy)
@@ -1,34 +0,0 @@
-package org.wso2.carbon.hosting.mgt;
-
-/*import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;*/
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-import org.junit.runners.Suite.SuiteClasses;
-/**
- * Created by IntelliJ IDEA.
- * User: damitha
- * Date: 1/19/12
- * Time: 2:54 PM
- * To change this template use File | Settings | File Templates.
- */
-
-
-/// /// /// /// /// /// /// /// /// /// /// /// ///
-// You should import the Test Case Classes here.
-
-/// /// /// /// /// ///
-@RunWith(Suite.class)
-/// /// /// /// /// /// /// /// ///
-// List the Test Case Classes here.
-@SuiteClasses({
- ///// ///// ///// ///// ///// ///// ///// ///// /////
- // Comment the class(es) that you doesn't want to run.
- org.wso2.carbon.hosting.wnagent.WNAgentTest.class
-
-})
-
-/// /// /// /// /// /// /// /// /// /// /// /// /// /// /// ////// /// /// /// /// /// /// /// ///
-// Name your Test Suit Class here, you should point the IntelliJ JUnit Configuration to this class.
-public class WNAgentTestSuite {}
Index: src/main/java/org/wso2/carbon/hosting/wnagent/WNAgentConstants.java
===================================================================
--- src/main/java/org/wso2/carbon/hosting/wnagent/WNAgentConstants.java (revision 122945)
+++ src/main/java/org/wso2/carbon/hosting/wnagent/WNAgentConstants.java (working copy)
@@ -1,25 +1,35 @@
/*
- * Copyright (c) 2005-2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * WSO2 Inc. 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.
- *
+ * Copyright (c) 2005-2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. 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.wso2.carbon.hosting.wnagent;
+
public class WNAgentConstants {
- public static final String CONTAINER_PATH = "/_system/config/repository/hosting/containers";
+ public static final String CONTAINER_ACTION = "./container_action.sh";
+ public static final String CONTAINER_STOP_ACTION = "stop";
+
+ public static final String CONTAINER_START_ACTION = "start";
+
+ public static final String CONTAINER_DESTROY_ACTION = "destroy";
+
+ public static final String CONTAINER_CREATE_ACTION = "create";
+
+ public static final String WSO2_HOSTING_HOME = "/home/wso2/container_steup";
+
}
Index: src/main/java/org/wso2/carbon/hosting/wnagent/service/WorkerNodeAgentService.java
===================================================================
--- src/main/java/org/wso2/carbon/hosting/wnagent/service/WorkerNodeAgentService.java (revision 0)
+++ src/main/java/org/wso2/carbon/hosting/wnagent/service/WorkerNodeAgentService.java (revision 0)
@@ -0,0 +1,195 @@
+/*
+ * Copyright 2005-2007 WSO2, Inc. (http://wso2.com)
+ *
+ * Licensed 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.wso2.carbon.hosting.wnagent.service;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.wso2.carbon.hosting.wnagent.WNAgentConstants;
+import org.wso2.carbon.hosting.wnagent.WNAgentException;
+import org.wso2.carbon.hosting.wnagent.dto.Container;
+
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * In this class Stratos Worker Node Agent related stuff defined.
+ *
+ * Creating/destroying a container, starting/stopping a created container are
+ * covered in this class. Container is a
+ * physical or virtual machine allocated to a tenant.
+ *
+ */
+
+public class WorkerNodeAgentService {
+
+ private static final Log log = LogFactory.getLog(WorkerNodeAgentService.class);
+
+ /**
+ *
+ * @param container
+ * container information
+ * @return
+ * @throws IOException
+ * @throws InterruptedException
+ *
+ * Create a container corresponding to the container user. This
+ * method will be called when the tenant user
+ * upload his first application.
+ */
+ public int createContainer(String tenantName, String tenantPassword, Container container)
+ throws IOException,
+ InterruptedException,
+ WNAgentException {
+
+ ProcessBuilder pbInit =
+ new ProcessBuilder(WNAgentConstants.CONTAINER_ACTION,
+ WNAgentConstants.WSO2_HOSTING_HOME,
+ WNAgentConstants.CONTAINER_CREATE_ACTION,
+ tenantName, tenantPassword, container.getIp(),
+ container.getNetMask(),
+ container.getNetGateway(),
+ container.getBridge(),
+ container.getJailKeysFile(),
+ container.getTemplate(), container.getMemory(),
+ container.getSwap(), container.getCpuShares(),
+ container.getCpuSetShares());
+ pbInit.directory(new File(WNAgentConstants.WSO2_HOSTING_HOME));
+ Process procInit = pbInit.start();
+ int exitVal = procInit.waitFor();
+ if (exitVal == 0) {
+ String msg = "Hosting container create executed successfully";
+ log.debug(msg);
+ } else {
+ String msg = "Hosting container create execution failed";
+ log.debug(msg);
+ }
+ return exitVal;
+ }
+
+ /**
+ *
+ * @param tenantName
+ * tenant user
+ * @param containerRoot
+ * This is root of the file system where containers will be
+ * created
+ * @return
+ * @throws IOException
+ * @throws InterruptedException
+ *
+ * Destroy a container environment corresponding to a container
+ * user. When this method is called the container
+ * will be deleted.
+ */
+ public int destroyContainer(String tenantName, String containerRoot) throws IOException,
+ InterruptedException,
+ WNAgentException {
+
+ ProcessBuilder pbInit =
+ new ProcessBuilder(WNAgentConstants.CONTAINER_ACTION,
+ WNAgentConstants.WSO2_HOSTING_HOME,
+ WNAgentConstants.CONTAINER_DESTROY_ACTION,
+ tenantName, containerRoot);
+ pbInit.directory(new File(WNAgentConstants.WSO2_HOSTING_HOME));
+ Process procInit = pbInit.start();
+ int exitVal = procInit.waitFor();
+ if (exitVal == 0) {
+ String msg = "Hosting container destroy executed successfully";
+ log.debug(msg);
+ } else {
+ String msg = "Hosting container destroy execution failed";
+ log.debug(msg);
+ }
+ return exitVal;
+ }
+
+ /**
+ * Start the container. Starting the container
+ * means starting the lamp applications. A container is normally started
+ * after creating it or, when it is in the
+ * stopped state and user try to access it again.
+ *
+ * @param tenantName
+ * tenant user
+ * @param containerRoot
+ * This is root of the file system where containers will be
+ * created
+ * @return
+ * @throws IOException
+ * @throws InterruptedException
+ *
+ */
+ public int startContainer(String tenantName, String containerRoot) throws IOException,
+ InterruptedException,
+ WNAgentException {
+ ProcessBuilder pbInit =
+ new ProcessBuilder(WNAgentConstants.CONTAINER_ACTION,
+ WNAgentConstants.WSO2_HOSTING_HOME,
+ WNAgentConstants.CONTAINER_START_ACTION,
+ tenantName, containerRoot);
+ pbInit.directory(new File(WNAgentConstants.WSO2_HOSTING_HOME));
+ Process procInit = pbInit.start();
+ int exitVal = procInit.waitFor();
+ if (exitVal == 0) {
+ String msg = "Hosting container start action executed successfully";
+ log.debug(msg);
+ } else {
+ String msg = "Hosting container start action execution failed";
+ log.debug(msg);
+ }
+ return exitVal;
+ }
+
+ /**
+ *
+ * Stop the container. Stopping the container
+ * means shutdown the lamp applications. A container is normally stopped
+ * when the user idle for a predefined time
+ * period.
+ *
+ * @param tenantName
+ * tenant user
+ * @param containerRoot
+ * This is root of the file system where containers will be
+ * created
+ * @return
+ * @throws IOException
+ * @throws InterruptedException
+ *
+ */
+ public int stopContainer(String tenantName, String containerRoot) throws IOException,
+ InterruptedException,
+ WNAgentException {
+
+ ProcessBuilder pbInit =
+ new ProcessBuilder(WNAgentConstants.CONTAINER_ACTION,
+ WNAgentConstants.WSO2_HOSTING_HOME,
+ WNAgentConstants.CONTAINER_STOP_ACTION,
+ tenantName, containerRoot);
+ pbInit.directory(new File(WNAgentConstants.WSO2_HOSTING_HOME));
+ Process procInit = pbInit.start();
+ int exitVal = procInit.waitFor();
+ if (exitVal == 0) {
+ String msg = "Hosting container stop action executed successfully";
+ log.debug(msg);
+ } else {
+ String msg = "Hosting container stop action execution failed";
+ log.debug(msg);
+ }
+ return exitVal;
+ }
+}
Index: src/main/java/org/wso2/carbon/hosting/wnagent/WNAgentException.java
===================================================================
--- src/main/java/org/wso2/carbon/hosting/wnagent/WNAgentException.java (revision 122945)
+++ src/main/java/org/wso2/carbon/hosting/wnagent/WNAgentException.java (working copy)
@@ -1,31 +1,31 @@
/*
- * Copyright (c) 2005-2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * WSO2 Inc. 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.
- *
+ * Copyright (c) 2005-2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. 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.wso2.carbon.hosting.wnagent;
-@SuppressWarnings("serial")
-public class WNAgentException extends Exception{
- public WNAgentException(String msg) {
- super(msg);
- }
+@SuppressWarnings("serial")
+public class WNAgentException extends Exception {
- public WNAgentException(String msg, Throwable t) {
- super(msg, t);
- }
+ public WNAgentException(String msg) {
+ super(msg);
+ }
+
+ public WNAgentException(String msg, Throwable t) {
+ super(msg, t);
+ }
}
Index: src/main/java/org/wso2/carbon/hosting/wnagent/WNAgent.java
===================================================================
--- src/main/java/org/wso2/carbon/hosting/wnagent/WNAgent.java (revision 122945)
+++ src/main/java/org/wso2/carbon/hosting/wnagent/WNAgent.java (working copy)
@@ -1,158 +0,0 @@
-/*
- * Copyright 2005-2007 WSO2, Inc. (http://wso2.com)
- *
- * Licensed 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.wso2.carbon.hosting.wnagent;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.hosting.wnagent.dto.Container;
-
-import java.io.File;
-import java.io.IOException;
-
-/**
- * In this class Stratos Worker Node Agent related stuff defined.
- *
- * Creating/destroying a container, starting/stopping a created container are covered in this class. Container is a
- * physical or virtual machine allocated to a tenant.
- *
- */
-
-public class WNAgent {
- private static final Log log = LogFactory.getLog(WNAgent.class);
- //private static final String wso2hostingHome = System.getProperty("wso2hosting.home");
- private static final String wso2hostingHome = "/home/damitha/container_setup";
- /**
- *
- * @param container container information
- * @return
- * @throws IOException
- * @throws InterruptedException
- *
- * Create a container corresponding to the container user. This method will be called when the tenant user
- * upload his first application.
- */
- public int createContainer(String tenantName, String tenantPassword, Container container)
- throws IOException, InterruptedException, WNAgentException{
-
- ProcessBuilder pbInit = new ProcessBuilder("./container_action", wso2hostingHome, "create",
- tenantName, tenantPassword, container.getIp(), container.getNetMask(),
- container.getNetGateway(), container.getBridge(), container.getJailKeysFile(), container.getTemplate(),
- container.getMemory(), container.getSwap(), container.getCpuShares(), container.getCpuSetShares());
- pbInit.directory(new File(wso2hostingHome));
- Process procInit = pbInit.start();
- int exitVal = procInit.waitFor();
- if(exitVal == 0) {
- String msg = "Hosting container create executed successfully";
- log.debug(msg);
- } else {
- String msg = "Hosting container create execution failed";
- log.debug(msg);
- }
- return exitVal;
- }
-
- /**
- *
- * @param tenantName tenant user
- * @param containerRoot This is root of the file system where containers will be created
- * @return
- * @throws IOException
- * @throws InterruptedException
- *
- * Destroy a container environment corresponding to a container user. When this method is called the container
- * will be deleted.
- */
- public int destroyContainer(String tenantName, String containerRoot)
- throws IOException, InterruptedException, WNAgentException{
-
- ProcessBuilder pbInit = new ProcessBuilder("./container_action", wso2hostingHome, "destroy", tenantName,
- containerRoot);
- pbInit.directory(new File(wso2hostingHome));
- Process procInit = pbInit.start();
- int exitVal = procInit.waitFor();
- if(exitVal == 0) {
- String msg = "Hosting container destroy executed successfully";
- log.debug(msg);
- } else {
- String msg = "Hosting container destroy execution failed";
- log.debug(msg);
- }
- return exitVal;
- }
-
- /**
- * Start the container. Starting the container
- * means starting the lamp applications. A container is normally started after creating it or, when it is in the
- * stopped state and user try to access it again.
- *
- * @param tenantName tenant user
- * @param containerRoot This is root of the file system where containers will be created
- * @return
- * @throws IOException
- * @throws InterruptedException
- *
- */
- public int startContainer(String tenantName, String containerRoot)
- throws IOException, InterruptedException, WNAgentException {
- ProcessBuilder pbInit = new ProcessBuilder("./container_action", wso2hostingHome, "start", tenantName,
- containerRoot);
- pbInit.directory(new File(wso2hostingHome));
- Process procInit = pbInit.start();
- int exitVal = procInit.waitFor();
- if(exitVal == 0) {
- String msg = "Hosting container start action executed successfully";
- log.debug(msg);
- } else {
- String msg = "Hosting container start action execution failed";
- log.debug(msg);
- }
- return exitVal;
- }
-
- /**
- *
- * Stop the container. Stopping the container
- * means shutdown the lamp applications. A container is normally stopped when the user idle for a predefined time
- * period.
- *
- * @param tenantName tenant user
- * @param containerRoot This is root of the file system where containers will be created
- * @return
- * @throws IOException
- * @throws InterruptedException
- *
- */
- public int stopContainer(String tenantName, String containerRoot)
- throws IOException, InterruptedException, WNAgentException {
-
- ProcessBuilder pbInit = new ProcessBuilder("./container_action", wso2hostingHome, "stop", tenantName,
- containerRoot);
- pbInit.directory(new File(wso2hostingHome));
- Process procInit = pbInit.start();
- int exitVal = procInit.waitFor();
- if(exitVal == 0) {
- String msg = "Hosting container stop action executed successfully";
- log.debug(msg);
- } else {
- String msg = "Hosting container stop action execution failed";
- log.debug(msg);
- }
- return exitVal;
- }
-}
-
Index: src/main/java/org/wso2/carbon/hosting/wnagent/WNAgentUtils.java
===================================================================
--- src/main/java/org/wso2/carbon/hosting/wnagent/WNAgentUtils.java (revision 122945)
+++ src/main/java/org/wso2/carbon/hosting/wnagent/WNAgentUtils.java (working copy)
@@ -7,40 +7,54 @@
import java.io.File;
public class WNAgentUtils {
- //private static final String wso2wsasHome = System.getProperty("wso2wsas.home");
+ // private static final String wso2wsasHome =
+ // System.getProperty("wso2wsas.home");
private static final String wso2wsasHome = "/opt/as/wso2as-4.1.2";
- public static WSRegistryServiceClient initializeRegistry() throws Exception{
- WSRegistryServiceClient registry;
+ public static WSRegistryServiceClient initializeRegistry() throws Exception {
+ WSRegistryServiceClient registry;
- /*ConfigurationContext configContext = MessageContext.getCurrentMessageContext().getConfigurationContext();
- String adminUser = (String) MessageContext.getCurrentMessageContext().getServiceContext().
- getAxisService().getParameterValue(ResourcesConstants.ADMIN_USER);
- String adminUserPassword = (String) MessageContext.getCurrentMessageContext().getServiceContext().
- getAxisService().getParameterValue(ResourcesConstants.ADMIN_USER_PASSWORD);*/
- //String serverURL = (String) MessageContext.getCurrentMessageContext().getServiceContext().
- // getAxisService().getParameterValue(ResourcesConstants.SERVER_URL);
+ /*
+ * ConfigurationContext configContext =
+ * MessageContext.getCurrentMessageContext().getConfigurationContext();
+ * String adminUser = (String)
+ * MessageContext.getCurrentMessageContext().getServiceContext().
+ * getAxisService().getParameterValue(ResourcesConstants.ADMIN_USER);
+ * String adminUserPassword = (String)
+ * MessageContext.getCurrentMessageContext().getServiceContext().
+ * getAxisService().getParameterValue(ResourcesConstants.ADMIN_USER_PASSWORD
+ * );
+ */
+ // String serverURL = (String)
+ // MessageContext.getCurrentMessageContext().getServiceContext().
+ // getAxisService().getParameterValue(ResourcesConstants.SERVER_URL);
- //String backendURL = (String) MessageContext.getCurrentMessageContext().getServiceContext().
- // getAxisService().getParameterValue(ResourcesConstants.SERVER_URL);
- //String policyPath = (String) MessageContext.getCurrentMessageContext().getServiceContext().
- // getAxisService().getParameterValue(ResourcesConstants.POLICY_PATH);
-
+ // String backendURL = (String)
+ // MessageContext.getCurrentMessageContext().getServiceContext().
+ // getAxisService().getParameterValue(ResourcesConstants.SERVER_URL);
+ // String policyPath = (String)
+ // MessageContext.getCurrentMessageContext().getServiceContext().
+ // getAxisService().getParameterValue(ResourcesConstants.POLICY_PATH);
- System.setProperty("javax.net.ssl.trustStore", wso2wsasHome + File.separator + "repository" +File.separator +"resources" + File.separator +
- "security" + File.separator + "wso2carbon.jks");
- System.setProperty("javax.net.ssl.trustStorePassword", "wso2carbon");
- System.setProperty("javax.net.ssl.trustStoreType","JKS");
+ System.setProperty("javax.net.ssl.trustStore", wso2wsasHome + File.separator +
+ "repository" + File.separator + "resources" +
+ File.separator + "security" +
+ File.separator + "wso2carbon.jks");
+ System.setProperty("javax.net.ssl.trustStorePassword", "wso2carbon");
+ System.setProperty("javax.net.ssl.trustStoreType", "JKS");
- String serverURL = "http://localhost:9763/services/";
- String backendURL = "https://localhost:9443/services/";
- String axis2Repo = wso2wsasHome + "/repository/deployment/client";
- String axis2Conf = wso2wsasHome + "/repository/conf/axis2_client.xml";
- ConfigurationContext configContext = ConfigurationContextFactory.
- createConfigurationContextFromFileSystem(axis2Repo, axis2Conf);
- registry = new WSRegistryServiceClient(backendURL, "admin", "admin", serverURL, configContext);
-
- return registry;
- }
+ String serverURL = "http://localhost:9763/services/";
+ String backendURL = "https://localhost:9443/services/";
+ String axis2Repo = wso2wsasHome + "/repository/deployment/client";
+ String axis2Conf = wso2wsasHome + "/repository/conf/axis2_client.xml";
+ ConfigurationContext configContext =
+ ConfigurationContextFactory.createConfigurationContextFromFileSystem(axis2Repo,
+ axis2Conf);
+ registry =
+ new WSRegistryServiceClient(backendURL, "admin", "admin", serverURL,
+ configContext);
+ return registry;
+ }
+
}
Index: src/main/java/org/wso2/carbon/hosting/wnagent/dto/Container.java
===================================================================
--- src/main/java/org/wso2/carbon/hosting/wnagent/dto/Container.java (revision 122945)
+++ src/main/java/org/wso2/carbon/hosting/wnagent/dto/Container.java (working copy)
@@ -3,31 +3,31 @@
public class Container {
private String jailKeysFile;
-
+
private String template;
-
- private String zone;
-
- private String jailRoot;
-
- private String netGateway;
-
- private String ip;
-
- private String netMask;
-
- private String bridge;
-
- private String memory;
- private String swap;
-
- private String cpuShares;
-
- private String cpuSetShares;
+ private String zone;
- private String storage;
+ private String jailRoot;
+ private String netGateway;
+
+ private String ip;
+
+ private String netMask;
+
+ private String bridge;
+
+ private String memory;
+
+ private String swap;
+
+ private String cpuShares;
+
+ private String cpuSetShares;
+
+ private String storage;
+
public String getJailKeysFile() {
return jailKeysFile;
}
@@ -44,91 +44,91 @@
this.template = template;
}
- public String getCpuShares() {
- return cpuShares;
- }
+ public String getCpuShares() {
+ return cpuShares;
+ }
- public void setCpuShares(String cpuShares) {
- this.cpuShares = cpuShares;
- }
+ public void setCpuShares(String cpuShares) {
+ this.cpuShares = cpuShares;
+ }
- public String getNetGateway() {
- return netGateway;
- }
+ public String getNetGateway() {
+ return netGateway;
+ }
- public void setNetGateway(String netGateway) {
- this.netGateway = netGateway;
- }
+ public void setNetGateway(String netGateway) {
+ this.netGateway = netGateway;
+ }
- public String getJailRoot() {
- return jailRoot;
- }
+ public String getJailRoot() {
+ return jailRoot;
+ }
- public void setJailRoot(String jailRoot) {
- this.jailRoot = jailRoot;
- }
+ public void setJailRoot(String jailRoot) {
+ this.jailRoot = jailRoot;
+ }
- public String getCpuSetShares() {
- return cpuSetShares;
- }
+ public String getCpuSetShares() {
+ return cpuSetShares;
+ }
- public void setCpuSetShares(String cpuSetShares) {
- this.cpuSetShares = cpuSetShares;
- }
+ public void setCpuSetShares(String cpuSetShares) {
+ this.cpuSetShares = cpuSetShares;
+ }
- public String getIp() {
- return ip;
- }
+ public String getIp() {
+ return ip;
+ }
- public void setIp(String ip) {
- this.ip = ip;
- }
+ public void setIp(String ip) {
+ this.ip = ip;
+ }
- public String getNetMask() {
- return netMask;
- }
+ public String getNetMask() {
+ return netMask;
+ }
- public void setNetMask(String netMask) {
- this.netMask = netMask;
- }
+ public void setNetMask(String netMask) {
+ this.netMask = netMask;
+ }
- public String getBridge() {
- return bridge;
- }
+ public String getBridge() {
+ return bridge;
+ }
- public void setBridge(String bridge) {
- this.bridge = bridge;
- }
+ public void setBridge(String bridge) {
+ this.bridge = bridge;
+ }
- public String getMemory() {
- return memory;
- }
+ public String getMemory() {
+ return memory;
+ }
- public void setMemory(String memory) {
- this.memory = memory;
- }
+ public void setMemory(String memory) {
+ this.memory = memory;
+ }
- public String getSwap() {
- return swap;
- }
+ public String getSwap() {
+ return swap;
+ }
- public void setSwap(String swap) {
- this.swap = swap;
- }
+ public void setSwap(String swap) {
+ this.swap = swap;
+ }
- public String getStorage() {
- return storage;
- }
+ public String getStorage() {
+ return storage;
+ }
- public void setStorage(String storage) {
- this.storage = storage;
- }
+ public void setStorage(String storage) {
+ this.storage = storage;
+ }
- public String getZone() {
- return zone;
- }
+ public String getZone() {
+ return zone;
+ }
- public void setZone(String zone) {
- this.zone = zone;
- }
+ public void setZone(String zone) {
+ this.zone = zone;
+ }
}
Index: src/main/java/org/wso2/carbon/hosting/wnagent/client/WNAgentManagementClient.java
===================================================================
--- src/main/java/org/wso2/carbon/hosting/wnagent/client/WNAgentManagementClient.java (revision 122945)
+++ src/main/java/org/wso2/carbon/hosting/wnagent/client/WNAgentManagementClient.java (working copy)
@@ -5,7 +5,7 @@
/**
* @author wso2TODO Auto-generated method stub
- *
+ *
*/
public class WNAgentManagementClient {
Index: src/main/java/org/wso2/carbon/hosting/wnagent/exception/WNAgentException.java
===================================================================
--- src/main/java/org/wso2/carbon/hosting/wnagent/exception/WNAgentException.java (revision 0)
+++ src/main/java/org/wso2/carbon/hosting/wnagent/exception/WNAgentException.java (revision 0)
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2005-2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. 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.wso2.carbon.hosting.wnagent.exception;
+
+@SuppressWarnings("serial")
+public class WNAgentException extends Exception {
+
+ public WNAgentException(String msg) {
+ super(msg);
+ }
+
+ public WNAgentException(String msg, Throwable t) {
+ super(msg, t);
+ }
+}
Index: src/main/resources/META-INF/services.xml
===================================================================
--- src/main/resources/META-INF/services.xml (revision 122945)
+++ src/main/resources/META-INF/services.xml (working copy)
@@ -16,7 +16,7 @@
~ under the License.
-->
<serviceGroup>
- <service name="ContainerManagementAdmin" scope="transportsession">
+ <service name="WorkerNodeAgentService" scope="transportsession">
<schema schemaNamespace="http://org.apache.axis2/xsd" elementFormDefaultQualified="true"/>
<transports>
<transport>https</transport>
@@ -24,14 +24,14 @@
<description>
Admin service for managing all hosting containers
</description>
- <parameter name="ServiceClass">org.wso2.carbon.hosting.mgt.service.impl.ContainerManagementServiceImpl</parameter>
- <parameter name="enableMTOM">true</parameter>
+ <parameter name="ServiceClass">org.wso2.carbon.hosting.wnagent.service.WorkerNodeAgentService</parameter>
+ <!-- <parameter name="enableMTOM">true</parameter> -->
</service>
<parameter name="adminService" locked="true">false</parameter>
<parameter name="hiddenService" locked="true">false</parameter>
- <parameter name="AuthorizationAction" locked="false">
+ <!-- <parameter name="AuthorizationAction" locked="false">
/permission/admin/manage/modify/webapp
- </parameter>
+ </parameter> -->
</serviceGroup>
Index: pom.xml
===================================================================
--- pom.xml (revision 122945)
+++ pom.xml (working copy)
@@ -30,7 +30,7 @@
<artifactId>org.wso2.carbon.hosting.wnagent</artifactId>
<packaging>bundle</packaging>
<name>WSO2 Carbon - Hosting Worker Node Agent</name>
- <description>Hosting Worker Node Agent fuctionalities</description>
+ <description>Hosting Worker Node Agent functionalities</description>
<url>http://wso2.org</url>
<dependencies>
@@ -69,9 +69,9 @@
<instructions>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Bundle-Name>${project.artifactId}</Bundle-Name>
- <Bundle-Activator>
+<!-- <Bundle-Activator>
org.wso2.carbon.hosting.mgt.internal.HostingManagementActivator
- </Bundle-Activator>
+ </Bundle-Activator> -->
<Private-Package>org.wso2.carbon.hosting.mgt.*</Private-Package>
<Import-Package>
org.apache.axis2.*; version="${axis2.osgi.version.range.service-mgt}",
@@ -82,8 +82,7 @@
org.osgi.framework.*,
*;resolution:=optional
</Import-Package>
- <DynamicImport-Package>*</DynamicImport-Package>
- <Axis2Deployer>WebappsDeployer</Axis2Deployer>
+
</instructions>
</configuration>
</plugin>
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev