Browse Source

mise a jour

parent
commit
f3da18acd1

+ 29
- 0
Dockerfiles/forContainerNet/gwi2/Dockerfile View File

@@ -0,0 +1,29 @@
1
+# Choosing the image to use
2
+FROM node:buster
3
+
4
+ENV MY_IP=10.2.2.2
5
+
6
+# Installing required libraries
7
+RUN apt-get update && \
8
+    apt-get install -y net-tools iputils-ping python-pip && \
9
+    pip install flask && \
10
+    pip install requests && \
11
+    mkdir mydir && \
12
+    cd mydir && \
13
+    npm install express && \
14
+    npm install yargs && \
15
+    npm install systeminformation && \
16
+    npm install request && \
17
+    wget http://homepages.laas.fr/smedjiah/tmp/gateway.js
18
+
19
+COPY bootstrap_client.py /mydir
20
+
21
+SHELL ["/bin/bash", "-c"]
22
+
23
+RUN echo "nohup python /mydir/bootstrap_client.py &" > start.sh && \
24
+    echo "/bin/bash" >> start.sh && \
25
+    chmod 777 start.sh
26
+
27
+# Mandatory entrypoint in containernet
28
+ENTRYPOINT ./start.sh
29
+

+ 50
- 0
Dockerfiles/forContainerNet/gwi2/bootstrap_client.py View File

@@ -0,0 +1,50 @@
1
+#!/usr/bin/python
2
+#coding: utf-8
3
+import os
4
+import subprocess
5
+import requests
6
+
7
+
8
+BOOTSTRAP_SERVER_ADDRESS = '10.10.10.10:5555'
9
+
10
+def retrieve_config():
11
+    my_json_config = {"verdict":"oops"}
12
+    my_ip = str(subprocess.check_output("echo $MY_IP", shell=True)).rstrip()
13
+    print("MY_IP : %s"%(my_ip))
14
+    while my_json_config["verdict"] != "yes":
15
+        try:
16
+            resp = requests.get("http://%s/getmyconfig/%s"%(BOOTSTRAP_SERVER_ADDRESS, my_ip), timeout=2)
17
+        except:
18
+            print("Unable to join the bootstrap server")
19
+        try:
20
+            my_json_config = resp.json()
21
+            print("Extracted configs [succ] : %s"%(my_json_config))
22
+        except:
23
+            print("Unable to extract configs from bootstrap server's answer")
24
+            print("Extracted configs [fail] : %s"%(my_json_config))
25
+        print("request url : ==>%s<=="%("http://%s/getmyconfig/%s"%(BOOTSTRAP_SERVER_ADDRESS, my_ip)))
26
+        if "verdict" in my_json_config and my_json_config["verdict"] == "yes":
27
+            my_config = config_json_to_string(my_json_config)
28
+            subprocess.check_output("node /mydir/*.js %s"%(my_config), shell=True)
29
+        else:
30
+            my_json_config = {"verdict":"oops"}
31
+
32
+def config_json_to_string(json_config):
33
+    config = ""
34
+    if "local_ip" in json_config:
35
+        config += "--local_ip "+json_config["local_ip"]
36
+    if "local_port" in json_config:
37
+        config += "--local_port "+str(json_config["local_port"])
38
+    if "local_name" in json_config:
39
+        config += "--local_name "+json_config["local_name"]
40
+    if "remote_ip" in json_config:
41
+        config += "--remote_ip "+json_config["remote_ip"]
42
+    if "remote_port" in json_config:
43
+        config += "--remote_port "+str(json_config["remote_port"])
44
+    if "remote_name" in json_config:
45
+        config += "--remote_name "+json_config["remote_name"]
46
+    if "send_period" in json_config:
47
+        config += "--send_period "+str(json_config["send_period"])
48
+    return config
49
+
50
+retrieve_config()

+ 1
- 1
jsfiles/server.js View File

@@ -171,4 +171,4 @@ app.get('/health', function(req, res) {
171 171
 
172 172
 app.listen(LOCAL_ENDPOINT.PORT , function () {
173 173
     console.log(LOCAL_ENDPOINT.NAME + ' listening on : ' + LOCAL_ENDPOINT.PORT );
174
-});
174
+});

+ 1
- 1
topologie/topology_test.py View File

@@ -114,7 +114,7 @@ def create_topology():
114 114
     btrap = net.addDocker('btrap', ip=BOOTSTRAP_SERVER, dimage="config:topo")
115 115
 
116 116
     info('*** Adding topology server\n')
117
-    srv = net.addDocker('srv', ip=SVR_IP, dimage="server:topo", environment={'MY_IP':SVR_IP})
117
+    srv = net.addDocker('srv', ip=SVR_IP, dimage="server:topo", environment={'MY_IP':SVR_IP})# ports=[8080], publish_all_ports=True,
118 118
 
119 119
     info('*** Adding topology intermediary gateway\n')
120 120
     #gwi1 = net.addDocker('gwi1', ip=GWI1_IP, dimage="gateway:topo", environment={'MY_IP':GWI1_IP})

Loading…
Cancel
Save