mise a jour

This commit is contained in:
Abdel-Kader Chabi-Sika-Boni 2021-01-02 18:20:06 +01:00
parent 36f98e2831
commit 45612c1d88
5 changed files with 136 additions and 93 deletions

View file

@ -3,6 +3,7 @@
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'
@ -28,6 +29,7 @@ def retrieve_config():
subprocess.check_output("node /mydir/*.js %s"%(my_config), shell=True) subprocess.check_output("node /mydir/*.js %s"%(my_config), shell=True)
else: else:
my_json_config = {"verdict":"oops"} my_json_config = {"verdict":"oops"}
sleep(3)
def config_json_to_string(json_config): def config_json_to_string(json_config):
config = "" config = ""

View file

@ -35,42 +35,65 @@ GATEWAY_F = "--local_ip 127.0.0.1 --local_port 8282 --local_name %s --remote_
DEV = "--local_ip 127.0.0.1 --local_port 9001 --local_name %s --remote_ip %s --remote_port 8282 --remote_name %s --send_period 3000" DEV = "--local_ip 127.0.0.1 --local_port 9001 --local_name %s --remote_ip %s --remote_port 8282 --remote_name %s --send_period 3000"
''' '''
SVR_READY = False
GWI1_READY = False
GWI2_READY = False
GWF1_READY = False
GWF2_READY = False
GWF3_READY = False
@app.route("/getmyconfig/<string:my_ip>") @app.route("/getmyconfig/<string:my_ip>")
def configurations_giver(my_ip="127.0.0.1"): def configurations_giver(my_ip="127.0.0.1"):
global SVR_READY
global GWI1_READY
global GWI2_READY
global GWF1_READY
global GWF2_READY
global GWF3_READY
configs = {"local_ip":my_ip, "verdict":"oops"} configs = {"local_ip":my_ip, "verdict":"oops"}
if my_ip==SVR_IP: if my_ip==SVR_IP:
configs["local_port"] = 8080 configs["local_port"] = 8080
configs["local_name"] = "srv" configs["local_name"] = "srv"
configs["verdict"] = "yes" configs["verdict"] = "yes"
SVR_READY = True
elif my_ip==GWI1_IP: elif my_ip==GWI1_IP:
if SVR_READY:
configs["local_port"] = 8181 configs["local_port"] = 8181
configs["local_name"] = "gwi1" configs["local_name"] = "gwi1"
configs["remote_ip"] = SVR_IP configs["remote_ip"] = SVR_IP
configs["remote_port"] = 8080 configs["remote_port"] = 8080
configs["remote_name"] = "srv" configs["remote_name"] = "srv"
configs["verdict"] = "yes" configs["verdict"] = "yes"
GWI1_READY = True
elif my_ip==GWF1_IP: elif my_ip==GWF1_IP:
if GWI1_READY:
configs["local_port"] = 8282 configs["local_port"] = 8282
configs["local_name"] = "gwf1" configs["local_name"] = "gwf1"
configs["remote_ip"] = GWI1_IP configs["remote_ip"] = GWI1_IP
configs["remote_port"] = 8181 configs["remote_port"] = 8181
configs["remote_name"] = "gwi1" configs["remote_name"] = "gwi1"
configs["verdict"] = "yes" configs["verdict"] = "yes"
GWF1_READY = True
elif my_ip==GWF2_IP: elif my_ip==GWF2_IP:
if GWI1_READY:
configs["local_port"] = 8282 configs["local_port"] = 8282
configs["local_name"] = "gwf2" configs["local_name"] = "gwf2"
configs["remote_ip"] = GWI1_IP configs["remote_ip"] = GWI1_IP
configs["remote_port"] = 8181 configs["remote_port"] = 8181
configs["remote_name"] = "gwi1" configs["remote_name"] = "gwi1"
configs["verdict"] = "yes" configs["verdict"] = "yes"
GWF2_READY = True
elif my_ip==GWF3_IP: elif my_ip==GWF3_IP:
if GWI1_READY:
configs["local_port"] = 8282 configs["local_port"] = 8282
configs["local_name"] = "gwf3" configs["local_name"] = "gwf3"
configs["remote_ip"] = GWI1_IP configs["remote_ip"] = GWI1_IP
configs["remote_port"] = 8181 configs["remote_port"] = 8181
configs["remote_name"] = "gwi1" configs["remote_name"] = "gwi1"
configs["verdict"] = "yes" configs["verdict"] = "yes"
GWF3_READY = True
elif my_ip==DEV1_GWF1_IP: elif my_ip==DEV1_GWF1_IP:
if GWF1_READY:
configs["local_port"] = 9001 configs["local_port"] = 9001
configs["local_name"] = "dev1gwf1" configs["local_name"] = "dev1gwf1"
configs["remote_ip"] = GWF1_IP configs["remote_ip"] = GWF1_IP
@ -79,6 +102,7 @@ def configurations_giver(my_ip="127.0.0.1"):
configs["send_period"] = 3000 configs["send_period"] = 3000
configs["verdict"] = "yes" configs["verdict"] = "yes"
elif my_ip==DEV2_GWF1_IP: elif my_ip==DEV2_GWF1_IP:
if GWF1_READY:
configs["local_port"] = 9001 configs["local_port"] = 9001
configs["local_name"] = "dev2gwf1" configs["local_name"] = "dev2gwf1"
configs["remote_ip"] = GWF1_IP configs["remote_ip"] = GWF1_IP
@ -87,6 +111,7 @@ def configurations_giver(my_ip="127.0.0.1"):
configs["send_period"] = 3000 configs["send_period"] = 3000
configs["verdict"] = "yes" configs["verdict"] = "yes"
elif my_ip==DEV3_GWF1_IP: elif my_ip==DEV3_GWF1_IP:
if GWF1_READY:
configs["local_port"] = 9001 configs["local_port"] = 9001
configs["local_name"] = "dev3gwf1" configs["local_name"] = "dev3gwf1"
configs["remote_ip"] = GWF1_IP configs["remote_ip"] = GWF1_IP
@ -95,6 +120,7 @@ def configurations_giver(my_ip="127.0.0.1"):
configs["send_period"] = 3000 configs["send_period"] = 3000
configs["verdict"] = "yes" configs["verdict"] = "yes"
elif my_ip==DEV1_GWF2_IP: elif my_ip==DEV1_GWF2_IP:
if GWF2_READY:
configs["local_port"] = 9001 configs["local_port"] = 9001
configs["local_name"] = "dev1gwf2" configs["local_name"] = "dev1gwf2"
configs["remote_ip"] = GWF2_IP configs["remote_ip"] = GWF2_IP
@ -103,6 +129,7 @@ def configurations_giver(my_ip="127.0.0.1"):
configs["send_period"] = 3000 configs["send_period"] = 3000
configs["verdict"] = "yes" configs["verdict"] = "yes"
elif my_ip==DEV2_GWF2_IP: elif my_ip==DEV2_GWF2_IP:
if GWF2_READY:
configs["local_port"] = 9001 configs["local_port"] = 9001
configs["local_name"] = "dev2gwf2" configs["local_name"] = "dev2gwf2"
configs["remote_ip"] = GWF2_IP configs["remote_ip"] = GWF2_IP
@ -111,6 +138,7 @@ def configurations_giver(my_ip="127.0.0.1"):
configs["send_period"] = 3000 configs["send_period"] = 3000
configs["verdict"] = "yes" configs["verdict"] = "yes"
elif my_ip==DEV3_GWF2_IP: elif my_ip==DEV3_GWF2_IP:
if GWF2_READY:
configs["local_port"] = 9001 configs["local_port"] = 9001
configs["local_name"] = "dev3gwf2" configs["local_name"] = "dev3gwf2"
configs["remote_ip"] = GWF2_IP configs["remote_ip"] = GWF2_IP
@ -119,6 +147,7 @@ def configurations_giver(my_ip="127.0.0.1"):
configs["send_period"] = 3000 configs["send_period"] = 3000
configs["verdict"] = "yes" configs["verdict"] = "yes"
elif my_ip==DEV1_GWF3_IP: elif my_ip==DEV1_GWF3_IP:
if GWF3_READY:
configs["local_port"] = 9001 configs["local_port"] = 9001
configs["local_name"] = "dev1gwf3" configs["local_name"] = "dev1gwf3"
configs["remote_ip"] = GWF3_IP configs["remote_ip"] = GWF3_IP
@ -127,6 +156,7 @@ def configurations_giver(my_ip="127.0.0.1"):
configs["send_period"] = 3000 configs["send_period"] = 3000
configs["verdict"] = "yes" configs["verdict"] = "yes"
elif my_ip==DEV2_GWF3_IP: elif my_ip==DEV2_GWF3_IP:
if GWF3_READY:
configs["local_port"] = 9001 configs["local_port"] = 9001
configs["local_name"] = "dev2gwf3" configs["local_name"] = "dev2gwf3"
configs["remote_ip"] = GWF3_IP configs["remote_ip"] = GWF3_IP
@ -135,6 +165,7 @@ def configurations_giver(my_ip="127.0.0.1"):
configs["send_period"] = 3000 configs["send_period"] = 3000
configs["verdict"] = "yes" configs["verdict"] = "yes"
elif my_ip==DEV3_GWF3_IP: elif my_ip==DEV3_GWF3_IP:
if GWF3_READY:
configs["local_port"] = 9001 configs["local_port"] = 9001
configs["local_name"] = "dev3gwf3" configs["local_name"] = "dev3gwf3"
configs["remote_ip"] = GWF3_IP configs["remote_ip"] = GWF3_IP
@ -146,12 +177,16 @@ def configurations_giver(my_ip="127.0.0.1"):
@app.route("/getmyconfig/") @app.route("/getmyconfig/")
def configurations_giver_to_dc(): def configurations_giver_to_dc():
configs = {"local_ip":GWI2_IP, "verdict":"yes"} global GWI2_READY
configs = {"local_ip":GWI2_IP, "verdict":"oops"}
if SVR_READY:
configs["local_port"] = 8181 configs["local_port"] = 8181
configs["local_name"] = "gwi2" configs["local_name"] = "gwi2"
configs["remote_ip"] = SVR_IP configs["remote_ip"] = SVR_IP
configs["remote_port"] = 8080 configs["remote_port"] = 8080
configs["remote_name"] = "srv" configs["remote_name"] = "srv"
configs["verdict"] = "yes"
GWI2_READY = True
return jsonify(configs) return jsonify(configs)
if __name__=='__main__': if __name__=='__main__':

View file

@ -3,6 +3,7 @@
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'
@ -28,6 +29,7 @@ def retrieve_config():
subprocess.check_output("node /mydir/*.js %s"%(my_config), shell=True) subprocess.check_output("node /mydir/*.js %s"%(my_config), shell=True)
else: else:
my_json_config = {"verdict":"oops"} my_json_config = {"verdict":"oops"}
sleep(3)
def config_json_to_string(json_config): def config_json_to_string(json_config):
config = "" config = ""

View file

@ -3,6 +3,7 @@
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'
@ -28,6 +29,7 @@ def retrieve_config():
subprocess.check_output("node /mydir/*.js %s"%(my_config), shell=True) subprocess.check_output("node /mydir/*.js %s"%(my_config), shell=True)
else: else:
my_json_config = {"verdict":"oops"} my_json_config = {"verdict":"oops"}
sleep(3)
def config_json_to_string(json_config): def config_json_to_string(json_config):
config = "" config = ""

View file

@ -3,6 +3,7 @@
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'
@ -28,6 +29,7 @@ def retrieve_config():
subprocess.check_output("node /mydir/*.js %s"%(my_config), shell=True) subprocess.check_output("node /mydir/*.js %s"%(my_config), shell=True)
else: else:
my_json_config = {"verdict":"oops"} my_json_config = {"verdict":"oops"}
sleep(3)
def config_json_to_string(json_config): def config_json_to_string(json_config):
config = "" config = ""