cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chirad...@apache.org
Subject [11/15] git commit: WIP: fixes for associating ASA1000v to tenant
Date Thu, 17 Jan 2013 00:38:52 GMT
WIP: fixes for associating ASA1000v to tenant

Signed-off-by: Chiradeep Vittal <chiradeep@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/84d218f9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/84d218f9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/84d218f9

Branch: refs/heads/cisco-vnmc-api-integration
Commit: 84d218f972e48d5f92e6659282d6d1762070b108
Parents: d74c6a9
Author: Chiradeep Vittal <chiradeep@apache.org>
Authored: Wed Jan 16 15:32:54 2013 -0800
Committer: Chiradeep Vittal <chiradeep@apache.org>
Committed: Wed Jan 16 15:32:54 2013 -0800

----------------------------------------------------------------------
 .../cloud/network/resource/CiscoVnmcResource.java  |   48 ++++++++++++++-
 .../resource/test/CiscoVnmcResourceTest.java       |   28 +++++++++
 2 files changed, 75 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/84d218f9/plugins/network-elements/cisco-vnmc/src/com/cloud/network/resource/CiscoVnmcResource.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/cisco-vnmc/src/com/cloud/network/resource/CiscoVnmcResource.java
b/plugins/network-elements/cisco-vnmc/src/com/cloud/network/resource/CiscoVnmcResource.java
index 937470f..2de5b7b 100644
--- a/plugins/network-elements/cisco-vnmc/src/com/cloud/network/resource/CiscoVnmcResource.java
+++ b/plugins/network-elements/cisco-vnmc/src/com/cloud/network/resource/CiscoVnmcResource.java
@@ -19,9 +19,12 @@ package com.cloud.network.resource;
 import java.io.BufferedReader;
 import java.io.FileReader;
 import java.io.StringReader;
+import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
+import javax.lang.model.element.Element;
 import javax.naming.ConfigurationException;
 import javax.xml.parsers.DocumentBuilderFactory;
 
@@ -32,6 +35,7 @@ import org.apache.commons.httpclient.methods.PostMethod;
 import org.apache.log4j.Logger;
 import org.w3c.dom.Document;
 import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
 import org.xml.sax.InputSource;
 
 import com.cloud.agent.IAgentControl;
@@ -95,7 +99,9 @@ public class CiscoVnmcResource implements ServerResource {
         CREATE_SOURCE_NAT_POLICY("create-source-nat-policy.xml", "policy-mgr"),
         CREATE_NAT_POLICY_SET("create-nat-policy-set.xml", "policy-mgr"),
         RESOLVE_NAT_POLICY_SET("associate-nat-policy-set.xml", "policy-mgr"),
-        CREATE_EDGE_FIREWALL("create-edge-firewall.xml", "resource-mgr");
+        CREATE_EDGE_FIREWALL("create-edge-firewall.xml", "resource-mgr"),
+        LIST_UNASSOC_ASA1000V("list-unassigned-asa1000v.xml", "resource-mgr"),
+        ASSIGN_ASA1000V("assoc-asa1000v.xml", "resource-mgr");
 
         private String scriptsDir = "scripts/network/cisco";
         private String xml;
@@ -753,6 +759,46 @@ public class CiscoVnmcResource implements ServerResource {
     	return verifySuccess(response);
 
     }
+    
+    
+    public List<String> listUnAssocAsa1000v() throws ExecutionException {
+    	
+    	String xml = VnmcXml.LIST_UNASSOC_ASA1000V.getXml();
+    	String service = VnmcXml.LIST_UNASSOC_ASA1000V.getService();
+    	xml = replaceXmlValue(xml, "cookie", _cookie);
+    	
+    	
+    	String response =  sendRequest(service, xml);
+
+    	List<String> result = new ArrayList<String>();
+    	
+    	Document xmlDoc = getDocument(response);
+    	xmlDoc.normalize();
+    	NodeList fwList = xmlDoc.getElementsByTagName("fwInstance");
+    	for (int j=0; j < fwList.getLength(); j++) {
+			Node fwNode = fwList.item(j);
+			result.add (fwNode.getAttributes().getNamedItem("dn").getNodeValue());
+			
+		}
+        
+        return result;
+
+    }
+    
+    public boolean assocAsa1000v(String tenantName, String firewallDn) throws ExecutionException
{
+    	
+    	String xml = VnmcXml.ASSIGN_ASA1000V.getXml();
+    	String service = VnmcXml.ASSIGN_ASA1000V.getService();
+    	xml = replaceXmlValue(xml, "cookie", _cookie);
+    	xml = replaceXmlValue(xml, "binddn", getDnForEdgeFirewall(tenantName) + "/binding");
+    	xml = replaceXmlValue(xml, "fwdn", firewallDn);
+    	
+    	String response =  sendRequest(service, xml);
+
+    	return verifySuccess(response);
+
+    }
+    
 
     private String sendRequest(String service, String xmlRequest) throws ExecutionException
{
     	org.apache.commons.httpclient.protocol.Protocol myhttps = 

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/84d218f9/plugins/network-elements/cisco-vnmc/src/com/cloud/network/resource/test/CiscoVnmcResourceTest.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/cisco-vnmc/src/com/cloud/network/resource/test/CiscoVnmcResourceTest.java
b/plugins/network-elements/cisco-vnmc/src/com/cloud/network/resource/test/CiscoVnmcResourceTest.java
index 58baf5b..fbcd535 100644
--- a/plugins/network-elements/cisco-vnmc/src/com/cloud/network/resource/test/CiscoVnmcResourceTest.java
+++ b/plugins/network-elements/cisco-vnmc/src/com/cloud/network/resource/test/CiscoVnmcResourceTest.java
@@ -18,6 +18,8 @@ package com.cloud.network.resource.test;
 
 import static org.junit.Assert.assertTrue;
 
+import java.util.List;
+
 import org.junit.BeforeClass;
 import org.junit.Ignore;
 import org.junit.Test;
@@ -30,6 +32,8 @@ import com.cloud.utils.exception.ExecutionException;
 public class CiscoVnmcResourceTest {
 	static CiscoVnmcResource resource;
 	static String tenantName = "TenantE";
+	static List<String> fwDns = null;
+	
 	@BeforeClass
 	public static void setUpClass() throws Exception {
 		resource = new CiscoVnmcResource("10.223.56.5", "admin", "C1sco123");
@@ -216,6 +220,7 @@ public class CiscoVnmcResourceTest {
 		}
 	}
 	
+	@Ignore
 	@Test
 	public void testCreateEdgeFirewall() {
 		try {
@@ -226,4 +231,27 @@ public class CiscoVnmcResourceTest {
 			e.printStackTrace();
 		}
 	}
+	
+	@Test
+	public void testListUnassocAsa1000v() {
+		try {
+			List<String> response = resource.listUnAssocAsa1000v(); 
+			assertTrue(response.size() >=0);
+			fwDns = response;
+		} catch (ExecutionException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+	}
+	
+	@Test
+	public void assocAsa1000v() {
+		try {
+			boolean result = resource.assocAsa1000v(tenantName, fwDns.get(0)); 
+			assertTrue(result);
+		} catch (ExecutionException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+	}
 }


Mime
View raw message