mirror of https://github.com/apache/cloudstack.git
WIP: fixes for associating ASA1000v to tenant
Signed-off-by: Chiradeep Vittal <chiradeep@apache.org>
This commit is contained in:
parent
d74c6a9ac2
commit
84d218f972
|
|
@ -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 =
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue