mise a jour
This commit is contained in:
parent
fc8ce5a706
commit
770f84e959
4 changed files with 44 additions and 29 deletions
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/bin/python
|
#!/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
|
'''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)
|
(useful information according to our topology: useless otherwise)
|
||||||
'''
|
'''
|
||||||
|
@ -67,6 +67,8 @@ def configurations_giver(my_ip):
|
||||||
configs = DEV%('dev2gwf3',GWF3_IP,'gwf3')
|
configs = DEV%('dev2gwf3',GWF3_IP,'gwf3')
|
||||||
elif my_ip==DEV3_GWF3_IP:
|
elif my_ip==DEV3_GWF3_IP:
|
||||||
configs = DEV%('dev3gwf3',GWF3_IP,'gwf3')
|
configs = DEV%('dev3gwf3',GWF3_IP,'gwf3')
|
||||||
|
else:
|
||||||
|
configs = "oops"
|
||||||
return configs
|
return configs
|
||||||
|
|
||||||
if __name__=='__main__':
|
if __name__=='__main__':
|
||||||
|
|
|
@ -3,9 +3,9 @@ FROM node:buster
|
||||||
|
|
||||||
# Installing required libraries
|
# Installing required libraries
|
||||||
RUN apt-get update && \
|
RUN apt-get update && \
|
||||||
apt-get install -y net-tools iputils-ping python-pip && \
|
apt-get install -y net-tools iputils-ping python3 python3-pip && \
|
||||||
pip install flask && \
|
pip3 install flask && \
|
||||||
pip install requests && \
|
pip3 install requests && \
|
||||||
mkdir mydir && \
|
mkdir mydir && \
|
||||||
cd mydir && \
|
cd mydir && \
|
||||||
npm install express && \
|
npm install express && \
|
||||||
|
@ -18,7 +18,7 @@ COPY bootstrap_client.py /mydir
|
||||||
|
|
||||||
SHELL ["/bin/bash", "-c"]
|
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 && \
|
echo "/bin/bash" >> start.sh && \
|
||||||
chmod 777 start.sh
|
chmod 777 start.sh
|
||||||
|
|
||||||
|
|
|
@ -1,18 +1,31 @@
|
||||||
#!/usr/bin/python
|
#!/usr/bin/python3
|
||||||
|
#coding: utf-8
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
import requests
|
import requests
|
||||||
|
from time import sleep
|
||||||
|
|
||||||
|
|
||||||
BOOTSTRAP_SERVER_ADDRESS = '10.10.10.10:5555'
|
BOOTSTRAP_SERVER_ADDRESS = '10.10.10.10:5555'
|
||||||
|
|
||||||
def retrieve_config():
|
def retrieve_config():
|
||||||
my_config = "None"
|
my_config = "oops"
|
||||||
my_ip = subprocess.check_output("sleep 5 && echo $MY_IP", shell=True).rstrip()
|
resp = None
|
||||||
resp = requests.get("http://%s/getmyconfig/%s"%(BOOTSTRAP_SERVER_ADDRESS, my_ip))
|
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
|
my_config = resp.text
|
||||||
if my_config != "None":
|
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)
|
subprocess.check_output("node /mydir/*.js %s"%(my_config), shell=True)
|
||||||
#print("my_ip=%s and of type %s"%(my_ip,type(my_ip)))
|
|
||||||
|
|
||||||
retrieve_config()
|
retrieve_config()
|
||||||
|
|
|
@ -35,25 +35,25 @@ logging.getLogger('api.openstack.helper').setLevel(logging.DEBUG)
|
||||||
#####################################################################################################
|
#####################################################################################################
|
||||||
BOOTSTRAP_SERVER = '10.10.10.10' #name = btrap; port = 5555
|
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
|
GWI1_IP = '10.2.2.1' #name = gwi1
|
||||||
GWI2_IP = '10.0.1.2' #name = gwi2
|
GWI2_IP = '10.2.2.2' #name = gwi2
|
||||||
|
|
||||||
GWF1_IP = '10.0.0.1' #name = gwf1
|
GWF1_IP = '10.0.1.100' #name = gwf1
|
||||||
DEV1_GWF1_IP = '192.168.1.1' #name = dev1gwf1
|
DEV1_GWF1_IP = '10.0.1.1' #name = dev1gwf1
|
||||||
DEV2_GWF1_IP = '192.168.1.2' #name = dev2gwf1
|
DEV2_GWF1_IP = '10.0.1.2' #name = dev2gwf1
|
||||||
DEV3_GWF1_IP = '192.168.1.3' #name = dev3gwf1
|
DEV3_GWF1_IP = '10.0.1.3' #name = dev3gwf1
|
||||||
|
|
||||||
GWF2_IP = '10.0.0.2' #name = gwf2
|
GWF2_IP = '10.0.2.100' #name = gwf2
|
||||||
DEV1_GWF2_IP = '192.168.2.1' #name = dev1gwf2
|
DEV1_GWF2_IP = '10.0.2.1' #name = dev1gwf2
|
||||||
DEV2_GWF2_IP = '192.168.2.2' #name = dev2gwf2
|
DEV2_GWF2_IP = '10.0.2.2' #name = dev2gwf2
|
||||||
DEV3_GWF2_IP = '192.168.2.3' #name = dev3gwf2
|
DEV3_GWF2_IP = '10.0.2.3' #name = dev3gwf2
|
||||||
|
|
||||||
GWF3_IP = '10.0.0.3' #name = gwf3
|
GWF3_IP = '10.0.3.100' #name = gwf3
|
||||||
DEV1_GWF3_IP = '192.168.3.1' #name = dev1gwf3
|
DEV1_GWF3_IP = '10.0.3.1' #name = dev1gwf3
|
||||||
DEV2_GWF3_IP = '192.168.3.2' #name = dev2gwf3
|
DEV2_GWF3_IP = '10.0.3.2' #name = dev2gwf3
|
||||||
DEV3_GWF3_IP = '192.168.3.3' #name = dev3gwf3
|
DEV3_GWF3_IP = '10.0.3.3' #name = dev3gwf3
|
||||||
|
|
||||||
'''
|
'''
|
||||||
TOPOLOGY OVERVIEW
|
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():
|
def create_topology():
|
||||||
net = DCNetwork(monitor=False, enable_learning=True)
|
net = DCNetwork(monitor=False, enable_learning=True)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue