gctrl update
This commit is contained in:
parent
da56560316
commit
ee89012a93
2 changed files with 44 additions and 10 deletions
|
@ -8,6 +8,7 @@ import java.util.Map.Entry;
|
|||
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.client.ClientProtocolException;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.client.methods.HttpPut;
|
||||
import org.apache.http.entity.StringEntity;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
|
@ -34,6 +35,15 @@ class MANOAPI {
|
|||
String ip = vnfinfos.get("net").split("/")[0];
|
||||
Main.logger(this.getClass().getSimpleName(), "Deploying VNF ...");
|
||||
|
||||
CloseableHttpClient httpclient = HttpClients.createDefault();
|
||||
HttpPost httpPost;
|
||||
HttpPut httpPut;
|
||||
String inputJson, line;
|
||||
StringEntity stringEntity;
|
||||
HttpResponse response;
|
||||
BufferedReader br;
|
||||
StringBuffer result;
|
||||
|
||||
//printing
|
||||
for (Entry<String, String> e : vnfinfos.entrySet()) {
|
||||
Main.logger(this.getClass().getSimpleName(), "\t" + e.getKey() + " : " + e.getValue());
|
||||
|
@ -41,30 +51,54 @@ class MANOAPI {
|
|||
//TODO ************ (giw2: 10.2.2.2 intern ==> 172.17.0.17 extern)
|
||||
|
||||
for (Entry<String, String> e : vnfinfos.entrySet()) {
|
||||
CloseableHttpClient httpclient = HttpClients.createDefault();
|
||||
HttpPut httpPut = new HttpPut("http://127.0.0.1:5001/restapi/compute/dc1/"+vnfinfos.get("name"));
|
||||
httpclient = HttpClients.createDefault();
|
||||
httpPut = new HttpPut("http://127.0.0.1:5001/restapi/compute/dc1/"+vnfinfos.get("name"));
|
||||
httpPut.setHeader("Accept", "application/json");
|
||||
httpPut.setHeader("Content-type", "application/json");//vnfinfos.get("image")
|
||||
/*String inputJson = "{\n" +
|
||||
" \"image\": \"+gateway:topo+\",\n" +
|
||||
" \"network\": \"(id=input,ip=10.2.2.2/8)\"\n" +
|
||||
"}";*/
|
||||
String inputJson = "{\n" +
|
||||
inputJson = "{\n" +
|
||||
" \"image\": \""+vnfinfos.get("image")+"\",\n" +
|
||||
" \"network\": \"(id=input,ip="+ip+"/8)\"\n" +
|
||||
"}";
|
||||
StringEntity stringEntity = new StringEntity(inputJson);
|
||||
stringEntity = new StringEntity(inputJson);
|
||||
httpPut.setEntity(stringEntity);
|
||||
HttpResponse response = httpclient.execute(httpPut);
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader((response.getEntity().getContent())));
|
||||
response = httpclient.execute(httpPut);
|
||||
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));
|
||||
}
|
||||
|
||||
//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);
|
||||
}
|
||||
return ip;
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ class SDNCtrlAPI {
|
|||
|
||||
//Fixing script gateway.js registering bug
|
||||
//Manually registering gwf2
|
||||
httpPost = new HttpPost("http://172.17.0.17:8181/gateways/register");
|
||||
/*httpPost = new HttpPost("http://172.17.0.17:8181/gateways/register");
|
||||
httpPost.setHeader("Accept", "application/json");
|
||||
httpPost.setHeader("Content-type", "application/json");
|
||||
inputJson = "{\n" +
|
||||
|
@ -51,7 +51,7 @@ class SDNCtrlAPI {
|
|||
"}";
|
||||
stringEntity = new StringEntity(inputJson);
|
||||
httpPost.setEntity(stringEntity);
|
||||
httpclient.execute(httpPost);
|
||||
httpclient.execute(httpPost);*/
|
||||
|
||||
|
||||
//On s3: Redirect traffic from gwf2 to gwi2 through s4
|
||||
|
|
Loading…
Reference in a new issue