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
Index: src/test/java/org/wso2/carbon/hosting/mgt/WNAgentTest.java
===================================================================
--- src/test/java/org/wso2/carbon/hosting/mgt/WNAgentTest.java	(revision 122931)
+++ src/test/java/org/wso2/carbon/hosting/mgt/WNAgentTest.java	(working copy)
@@ -1,7 +1,13 @@
-package org.wso2.carbon.hosting.wnagent;
+package org.wso2.carbon.hosting.mgt;
 
-import org.junit.*;
+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.
@@ -12,53 +18,57 @@
  */
 
 public class WNAgentTest {
-    @Before
-    public void setUp() throws Exception {
+	@Before
+	public void setUp() throws Exception {
 
-    }
+	}
 
-    @After
-    public void tearDown() throws Exception {
-    }
+	@After
+	public void tearDown() throws Exception {
+	}
 
-    @BeforeClass
-    public static void runBeforeClass() throws Exception {
+	@BeforeClass
+	public static void runBeforeClass() throws Exception {
 
-    }
+	}
 
-    @AfterClass
-    public static void runAfterClass() {
+	@AfterClass
+	public static void runAfterClass() {
 
-    }
+	}
 
-    //@Test(expected = Exception.class)
-    @Test()
-    public void testAddContainerToRegistry() {
-        try {
-            String retVal;
-            WNAgent agent = new WNAgent();
+	// @Test(expected = Exception.class)
+	@Test()
+	public void testAddContainerToRegistry() {
+		try {
 
-            Container container = new Container();
-            container.setJailRoot("/mnt/lxc");
-            container.setTemplate("template-ubuntu-lucid-lamp");
-            container.setZone("public");
+			WorkerNodeAgentService agentService = new WorkerNodeAgentService();
 
-            container.setBridge("br-lxc");
-            container.setNetMask("255.255.255.0");
-            container.setNetGateway("192.168.254.1");
+			Container container = new Container();
 
-            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);
+			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");
 
-        } catch(Exception e) {
-            Assert.assertTrue(false);
-            e.printStackTrace();
-        }
-    }
+			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/mgt/WNAgentTestSuite.java
===================================================================
--- src/test/java/org/wso2/carbon/hosting/mgt/WNAgentTestSuite.java	(revision 122931)
+++ src/test/java/org/wso2/carbon/hosting/mgt/WNAgentTestSuite.java	(working copy)
@@ -1,11 +1,11 @@
 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;
+
+import org.wso2.carbon.hosting.mgt.WNAgentTest;
+
 /**
  * Created by IntelliJ IDEA.
  * User: damitha
@@ -14,21 +14,24 @@
  * 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.
-        org.wso2.carbon.hosting.wnagent.WNAgentTest.class
+	// /// ///// ///// ///// ///// ///// ///// ///// /////
+	// 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 {}
+// / /// /// /// /// /// /// /// /// /// /// /// /// /// /// ////// /// /// ///
+// /// /// /// /// ///
+// 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 122931)
+++ 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/WNAgentException.java
===================================================================
--- src/main/java/org/wso2/carbon/hosting/wnagent/WNAgentException.java	(revision 122931)
+++ 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/WNAgentUtils.java
===================================================================
--- src/main/java/org/wso2/carbon/hosting/wnagent/WNAgentUtils.java	(revision 122931)
+++ 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 122931)
+++ 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 122931)
+++ 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/resources/META-INF/services.xml
===================================================================
--- src/main/resources/META-INF/services.xml	(revision 122931)
+++ 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 122931)
+++ 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

Reply via email to