diff --git a/Dockerfiles/forContainerNet/bootserver/bootstrap_server.py b/Dockerfiles/forContainerNet/bootserver/bootstrap_server.py index ccbad63..3cc5883 100755 --- a/Dockerfiles/forContainerNet/bootserver/bootstrap_server.py +++ b/Dockerfiles/forContainerNet/bootserver/bootstrap_server.py @@ -1,5 +1,5 @@ #!/usr/bin/python -#encoding: utf-8 +#coding: utf-8 '''In our topology, we assume the container running this script has ip address 10.10.10.10 (useful information according to our topology: useless otherwise) ''' @@ -67,6 +67,8 @@ def configurations_giver(my_ip): configs = DEV%('dev2gwf3',GWF3_IP,'gwf3') elif my_ip==DEV3_GWF3_IP: configs = DEV%('dev3gwf3',GWF3_IP,'gwf3') + else: + configs = "oops" return configs if __name__=='__main__': diff --git a/Dockerfiles/forContainerNet/server/Dockerfile b/Dockerfiles/forContainerNet/server/Dockerfile index 501a0f1..cfcc60f 100644 --- a/Dockerfiles/forContainerNet/server/Dockerfile +++ b/Dockerfiles/forContainerNet/server/Dockerfile @@ -3,9 +3,9 @@ FROM node:buster # Installing required libraries RUN apt-get update && \ - apt-get install -y net-tools iputils-ping python-pip && \ - pip install flask && \ - pip install requests && \ + apt-get install -y net-tools iputils-ping python3 python3-pip && \ + pip3 install flask && \ + pip3 install requests && \ mkdir mydir && \ cd mydir && \ npm install express && \ @@ -18,7 +18,7 @@ COPY bootstrap_client.py /mydir SHELL ["/bin/bash", "-c"] -RUN echo "nohup python /mydir/bootstrap_client.py &" > start.sh && \ +RUN echo "nohup python3 /mydir/bootstrap_client.py &" > start.sh && \ echo "/bin/bash" >> start.sh && \ chmod 777 start.sh diff --git a/Dockerfiles/forContainerNet/server/bootstrap_client.py b/Dockerfiles/forContainerNet/server/bootstrap_client.py index 6e34c43..15b627b 100755 --- a/Dockerfiles/forContainerNet/server/bootstrap_client.py +++ b/Dockerfiles/forContainerNet/server/bootstrap_client.py @@ -1,18 +1,31 @@ -#!/usr/bin/python +#!/usr/bin/python3 +#coding: utf-8 import os import subprocess import requests +from time import sleep BOOTSTRAP_SERVER_ADDRESS = '10.10.10.10:5555' def retrieve_config(): - my_config = "None" - my_ip = subprocess.check_output("sleep 5 && echo $MY_IP", shell=True).rstrip() - resp = requests.get("http://%s/getmyconfig/%s"%(BOOTSTRAP_SERVER_ADDRESS, my_ip)) - my_config = resp.text - if my_config != "None": - subprocess.check_output("node /mydir/*.js %s"%(my_config), shell=True) - #print("my_ip=%s and of type %s"%(my_ip,type(my_ip))) + my_config = "oops" + resp = None + my_ip_ = str(subprocess.check_output("echo $MY_IP", shell=True)) #subprocess returning format: b'X.X.X.X\n' + my_ip = my_ip_.replace("b'",'').replace("'",'').replace("\\n",'') + print("MY_IP : %s"%(my_ip)) + while resp is None: + try: + resp = requests.get("http://%s/getmyconfig/%s"%(BOOTSTRAP_SERVER_ADDRESS, my_ip), timeout=2) + except: + print("Unable to join the bootstrap server") + try: + my_config = resp.text + except: + print("Unable to extract configs from bootstrap server's answer") + print("request url : %s"%("http://%s/getmyconfig/%s"%(BOOTSTRAP_SERVER_ADDRESS, my_ip))) + print("received configs : %s"%(my_config)) + if my_config != "oops": + subprocess.check_output("node /mydir/*.js %s"%(my_config), shell=True) retrieve_config() diff --git a/topologie/topology_test.py b/topologie/topology_test.py index 48fde30..69fc649 100755 --- a/topologie/topology_test.py +++ b/topologie/topology_test.py @@ -35,25 +35,25 @@ logging.getLogger('api.openstack.helper').setLevel(logging.DEBUG) ##################################################################################################### BOOTSTRAP_SERVER = '10.10.10.10' #name = btrap; port = 5555 -SVR_IP = '192.168.0.1' #name = srv +SVR_IP = '10.0.0.1' #name = srv -GWI1_IP = '10.0.1.1' #name = gwi1 -GWI2_IP = '10.0.1.2' #name = gwi2 +GWI1_IP = '10.2.2.1' #name = gwi1 +GWI2_IP = '10.2.2.2' #name = gwi2 -GWF1_IP = '10.0.0.1' #name = gwf1 -DEV1_GWF1_IP = '192.168.1.1' #name = dev1gwf1 -DEV2_GWF1_IP = '192.168.1.2' #name = dev2gwf1 -DEV3_GWF1_IP = '192.168.1.3' #name = dev3gwf1 +GWF1_IP = '10.0.1.100' #name = gwf1 +DEV1_GWF1_IP = '10.0.1.1' #name = dev1gwf1 +DEV2_GWF1_IP = '10.0.1.2' #name = dev2gwf1 +DEV3_GWF1_IP = '10.0.1.3' #name = dev3gwf1 -GWF2_IP = '10.0.0.2' #name = gwf2 -DEV1_GWF2_IP = '192.168.2.1' #name = dev1gwf2 -DEV2_GWF2_IP = '192.168.2.2' #name = dev2gwf2 -DEV3_GWF2_IP = '192.168.2.3' #name = dev3gwf2 +GWF2_IP = '10.0.2.100' #name = gwf2 +DEV1_GWF2_IP = '10.0.2.1' #name = dev1gwf2 +DEV2_GWF2_IP = '10.0.2.2' #name = dev2gwf2 +DEV3_GWF2_IP = '10.0.2.3' #name = dev3gwf2 -GWF3_IP = '10.0.0.3' #name = gwf3 -DEV1_GWF3_IP = '192.168.3.1' #name = dev1gwf3 -DEV2_GWF3_IP = '192.168.3.2' #name = dev2gwf3 -DEV3_GWF3_IP = '192.168.3.3' #name = dev3gwf3 +GWF3_IP = '10.0.3.100' #name = gwf3 +DEV1_GWF3_IP = '10.0.3.1' #name = dev1gwf3 +DEV2_GWF3_IP = '10.0.3.2' #name = dev2gwf3 +DEV3_GWF3_IP = '10.0.3.3' #name = dev3gwf3 ''' TOPOLOGY OVERVIEW @@ -94,7 +94,7 @@ Necessary docker images: config:topo ; server:topo ; gateway:topo ; device:topo ''' ##################################################################################################### -SVR_IP = '12.10.110.1' #name = srv +#SVR_IP = '12.10.110.1' #name = srv def create_topology(): net = DCNetwork(monitor=False, enable_learning=True)