gctrl update
This commit is contained in:
parent
9cf16b0efc
commit
da56560316
5 changed files with 51 additions and 133 deletions
|
@ -65,7 +65,6 @@ class MANOAPI {
|
|||
while ((line = br.readLine()) != null) {
|
||||
System.out.println("Response : \n" + result.append(line));
|
||||
}
|
||||
//System.out.println("Does Reponse contains 'datacenter'? :" + result.toString().contains("datacenter"));
|
||||
}
|
||||
return ip;
|
||||
}
|
||||
|
|
|
@ -21,36 +21,68 @@ class SDNCtrlAPI {
|
|||
String status = "OK";
|
||||
Main.logger(this.getClass().getSimpleName(), "olddestip = " + olddestip + "; newdestip = " + newdestip);
|
||||
|
||||
//On s3: Redirect traffic from gwf2 to gwi2 through s4
|
||||
CloseableHttpClient httpclient = HttpClients.createDefault();
|
||||
HttpPost httpPost = new HttpPost("http://127.0.0.1:8080/stats/flowentry/add");
|
||||
HttpPost httpPost;
|
||||
String match, actions, inputJson, line;
|
||||
StringEntity stringEntity;
|
||||
HttpResponse response;
|
||||
BufferedReader br;
|
||||
StringBuffer result;
|
||||
|
||||
//Fixing script gateway.js registering bug
|
||||
//Manually registering gwf2
|
||||
httpPost = new HttpPost("http://172.17.0.17:8181/gateways/register");
|
||||
httpPost.setHeader("Accept", "application/json");
|
||||
httpPost.setHeader("Content-type", "application/json");
|
||||
inputJson = "{\n" +
|
||||
" \"Name\": \"gwf2\",\n" +
|
||||
" \"PoC\": \"http://10.0.2.100:8282\"\n" +
|
||||
"}";
|
||||
stringEntity = new StringEntity(inputJson);
|
||||
httpPost.setEntity(stringEntity);
|
||||
httpclient.execute(httpPost);
|
||||
//Manually registering gwf3
|
||||
httpPost = new HttpPost("http://172.17.0.17:8181/gateways/register");
|
||||
httpPost.setHeader("Accept", "application/json");
|
||||
httpPost.setHeader("Content-type", "application/json");
|
||||
inputJson = "{\n" +
|
||||
" \"Name\": \"gwf3\",\n" +
|
||||
" \"PoC\": \"http://10.0.3.100:8282\"\n" +
|
||||
"}";
|
||||
stringEntity = new StringEntity(inputJson);
|
||||
httpPost.setEntity(stringEntity);
|
||||
httpclient.execute(httpPost);
|
||||
|
||||
|
||||
//On s3: Redirect traffic from gwf2 to gwi2 through s4
|
||||
httpPost = new HttpPost("http://127.0.0.1:8080/stats/flowentry/add");
|
||||
httpPost.setHeader("Accept", "application/json");
|
||||
httpPost.setHeader("Content-type", "application/json");//vnfinfos.get("image")
|
||||
String match = "{\n" +
|
||||
match = "{\n" +
|
||||
" \"ipv4_dst\": \"10.2.2.1\",\n" +
|
||||
" \"eth_type\": 2048,\n" +
|
||||
" \"ipv4_src\": \"10.0.2.100\"\n" +
|
||||
"}";
|
||||
String actions = "[\n" +
|
||||
actions = "[\n" +
|
||||
" {\"type\": \"SET_FIELD\", \"field\":\"eth_dst\", \"value\":\"00:00:00:00:00:20\"}, \n" +
|
||||
" {\"type\": \"SET_FIELD\", \"field\":\"ipv4_dst\", \"value\":\"10.2.2.2\"}, \n" +
|
||||
" {\"type\": \"OUTPUT\", \"port\":2} \n" +
|
||||
"]";
|
||||
String inputJson = "{\n" +
|
||||
inputJson = "{\n" +
|
||||
" \"dpid\": 3,\n" +
|
||||
" \"priority\": 1,\n" +
|
||||
" \"match\": "+match+",\n" +
|
||||
" \"actions\": "+actions+"\n" +
|
||||
"}";
|
||||
StringEntity stringEntity = new StringEntity(inputJson);
|
||||
stringEntity = new StringEntity(inputJson);
|
||||
httpPost.setEntity(stringEntity);
|
||||
HttpResponse response = httpclient.execute(httpPost);
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader((response.getEntity().getContent())));
|
||||
response = httpclient.execute(httpPost);
|
||||
br = new BufferedReader(new InputStreamReader((response.getEntity().getContent())));
|
||||
if (response.getStatusLine().getStatusCode() != 200) {
|
||||
throw new RuntimeException("Failed : HTTP error code : " + response.getStatusLine().getStatusCode());
|
||||
}
|
||||
StringBuffer result = new StringBuffer();
|
||||
String line = "";
|
||||
result = new StringBuffer();
|
||||
line = "";
|
||||
while ((line = br.readLine()) != null) {
|
||||
System.out.println("Response : \n" + result.append(line));
|
||||
}
|
||||
|
@ -184,49 +216,6 @@ class SDNCtrlAPI {
|
|||
System.out.println("Response : \n" + result.append(line));
|
||||
}
|
||||
|
||||
|
||||
//Fixing script gateway.js registering bug
|
||||
//Manually registering gwf2
|
||||
httpPost = new HttpPost("http://172.17.0.17:8181/gateways/register");
|
||||
httpPost.setHeader("Accept", "application/json");
|
||||
httpPost.setHeader("Content-type", "application/json");
|
||||
inputJson = "{\n" +
|
||||
" \"Name\": \"gwf2\",\n" +
|
||||
" \"PoC\": \"http://10.0.2.100:8282\"\n" +
|
||||
"}";
|
||||
stringEntity = new StringEntity(inputJson);
|
||||
httpPost.setEntity(stringEntity);
|
||||
response = httpclient.execute(httpPost);
|
||||
br = new BufferedReader(new InputStreamReader((response.getEntity().getContent())));
|
||||
if (response.getStatusLine().getStatusCode() != 200) {
|
||||
throw new RuntimeException("Failed : HTTP error code : " + response.getStatusLine().getStatusCode());
|
||||
}
|
||||
result = new StringBuffer();
|
||||
line = "";
|
||||
while ((line = br.readLine()) != null) {
|
||||
System.out.println("Response : \n" + result.append(line));
|
||||
}
|
||||
//Manually registering gwf3
|
||||
httpPost = new HttpPost("http://172.17.0.17:8181/gateways/register");
|
||||
httpPost.setHeader("Accept", "application/json");
|
||||
httpPost.setHeader("Content-type", "application/json");
|
||||
inputJson = "{\n" +
|
||||
" \"Name\": \"gwf3\",\n" +
|
||||
" \"PoC\": \"http://10.0.3.100:8282\"\n" +
|
||||
"}";
|
||||
stringEntity = new StringEntity(inputJson);
|
||||
httpPost.setEntity(stringEntity);
|
||||
response = httpclient.execute(httpPost);
|
||||
br = new BufferedReader(new InputStreamReader((response.getEntity().getContent())));
|
||||
if (response.getStatusLine().getStatusCode() != 200) {
|
||||
throw new RuntimeException("Failed : HTTP error code : " + response.getStatusLine().getStatusCode());
|
||||
}
|
||||
result = new StringBuffer();
|
||||
line = "";
|
||||
while ((line = br.readLine()) != null) {
|
||||
System.out.println("Response : \n" + result.append(line));
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,81 +28,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
|||
public class GctrlApplication {
|
||||
|
||||
public static void main(String[] args) throws ClientProtocolException, IOException{
|
||||
/*RestTemplate restTemplate = new RestTemplate();
|
||||
ResponseEntity<String> response = restTemplate.getForEntity("http://172.17.0.3:8080/health", String.class);
|
||||
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
JsonNode root;
|
||||
try {
|
||||
root = mapper.readTree(response.getBody());
|
||||
JsonNode cpu_load = root.path("currentload");
|
||||
|
||||
//JsonNode root1 = mapper.readTree(name.toString().replace("[", "").replace("]", ""));
|
||||
//JsonNode name1 = root1.path("load");
|
||||
|
||||
System.out.println(cpu_load.asDouble());
|
||||
//System.out.println(name1.asDouble()+2);
|
||||
} catch (JsonMappingException e) {
|
||||
e.printStackTrace();
|
||||
} catch (JsonProcessingException e) {
|
||||
e.printStackTrace();
|
||||
}*/
|
||||
|
||||
//RestTemplate restTemplate = new RestTemplate();
|
||||
/*CloseableHttpClient httpclient = HttpClients.createDefault();
|
||||
HttpPut httpPut = new HttpPut("http://127.0.0.1:5001/restapi/compute/dc1/gwi2");
|
||||
httpPut.setHeader("Accept", "application/json");
|
||||
httpPut.setHeader("Content-type", "application/json");
|
||||
String inputJson = "{\n" +
|
||||
" \"image\": \"gateway:topo\",\n" +
|
||||
" \"network\": \"(id=input,ip=10.2.2.2/8)\"\n" +
|
||||
"}";
|
||||
StringEntity stringEntity = new StringEntity(inputJson);
|
||||
httpPut.setEntity(stringEntity);
|
||||
HttpResponse response = httpclient.execute(httpPut);
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader((response.getEntity().getContent())));
|
||||
if (response.getStatusLine().getStatusCode() != 200) {
|
||||
throw new RuntimeException("Failed : HTTP error code : " + response.getStatusLine().getStatusCode());
|
||||
}
|
||||
StringBuffer result = new StringBuffer();
|
||||
String line = "";
|
||||
while ((line = br.readLine()) != null) {
|
||||
System.out.println("Response : \n" + result.append(line));
|
||||
}
|
||||
System.out.println("Does Reponse contains 'datacenter'? :" + result.toString().contains("datacenter"));*/
|
||||
|
||||
CloseableHttpClient httpclient = HttpClients.createDefault();
|
||||
HttpPost httpPost = new HttpPost("http://127.0.0.1:8080/stats/flowentry/add");
|
||||
httpPost.setHeader("Accept", "application/json");
|
||||
httpPost.setHeader("Content-type", "application/json");
|
||||
String match = "{\n" +
|
||||
" \"ipv4_dst\": \"10.0.0.1\",\n" +
|
||||
" \"eth_type\": 2048,\n" +
|
||||
" \"ipv4_src\": \"10.0.2.100\"\n" +
|
||||
"}";
|
||||
String actions = "[\n" +
|
||||
" {\"type\": \"SET_FIELD\", \"field\":\"eth_dst\", \"value\":\"00:00:00:00:00:20\"}, \n" +
|
||||
" {\"type\": \"OUTPUT\", \"port\":2} \n" +
|
||||
"]";
|
||||
String inputJson = "{\n" +
|
||||
" \"dpid\": 3,\n" +
|
||||
" \"priority\": 1,\n" +
|
||||
" \"match\": "+match+",\n" +
|
||||
" \"actions\": "+actions+"\n" +
|
||||
"}";
|
||||
System.out.println(inputJson);
|
||||
StringEntity stringEntity = new StringEntity(inputJson);
|
||||
httpPost.setEntity(stringEntity);
|
||||
HttpResponse response = httpclient.execute(httpPost);
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader((response.getEntity().getContent())));
|
||||
if (response.getStatusLine().getStatusCode() != 200) {
|
||||
throw new RuntimeException("Failed : HTTP error code : " + response.getStatusLine().getStatusCode());
|
||||
}
|
||||
StringBuffer result = new StringBuffer();
|
||||
String line = "";
|
||||
while ((line = br.readLine()) != null) {
|
||||
System.out.println("Response : \n" + result.append(line));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -15,6 +15,9 @@ from mininet.log import setLogLevel, info
|
|||
from emuvim.dcemulator.net import DCNetwork
|
||||
from emuvim.api.rest.rest_api_endpoint import RestApiEndpoint
|
||||
from emuvim.api.openstack.openstack_api_endpoint import OpenstackApiEndpoint
|
||||
from mininet.node import Controller, RemoteController
|
||||
from mininet.node import OVSSwitch
|
||||
#from functools import partial
|
||||
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
setLogLevel('info') # set Mininet loglevel
|
||||
|
@ -96,9 +99,10 @@ Necessary docker images: config:topo ; server:topo ; gateway:topo ; device:topo
|
|||
|
||||
|
||||
def create_topology():
|
||||
net = DCNetwork(monitor=False, enable_learning=True)
|
||||
net = DCNetwork(monitor=False, enable_learning=True, autoSetMacs=True)
|
||||
|
||||
dc1 = net.addDatacenter("dc1")
|
||||
#net.addController( 'c0Externe', controller=RemoteController, ip='127.0.0.1', port=6633 ) #Ajout d'un remote controller
|
||||
# add OpenStack-like APIs to the emulated DC
|
||||
api1 = OpenstackApiEndpoint("0.0.0.0", 6001)
|
||||
api1.connect_datacenter(dc1)
|
||||
|
|
Loading…
Reference in a new issue