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 subprocess
import requests
from time import sleep
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)
else:
my_json_config = {"verdict":"oops"}
sleep(3)
def config_json_to_string(json_config):
config = ""

View file

@ -35,123 +35,158 @@ 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"
'''
SVR_READY = False
GWI1_READY = False
GWI2_READY = False
GWF1_READY = False
GWF2_READY = False
GWF3_READY = False
@app.route("/getmyconfig/<string:my_ip>")
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"}
if my_ip==SVR_IP:
configs["local_port"] = 8080
configs["local_name"] = "srv"
configs["verdict"] = "yes"
SVR_READY = True
elif my_ip==GWI1_IP:
configs["local_port"] = 8181
configs["local_name"] = "gwi1"
configs["remote_ip"] = SVR_IP
configs["remote_port"] = 8080
configs["remote_name"] = "srv"
configs["verdict"] = "yes"
if SVR_READY:
configs["local_port"] = 8181
configs["local_name"] = "gwi1"
configs["remote_ip"] = SVR_IP
configs["remote_port"] = 8080
configs["remote_name"] = "srv"
configs["verdict"] = "yes"
GWI1_READY = True
elif my_ip==GWF1_IP:
configs["local_port"] = 8282
configs["local_name"] = "gwf1"
configs["remote_ip"] = GWI1_IP
configs["remote_port"] = 8181
configs["remote_name"] = "gwi1"
configs["verdict"] = "yes"
if GWI1_READY:
configs["local_port"] = 8282
configs["local_name"] = "gwf1"
configs["remote_ip"] = GWI1_IP
configs["remote_port"] = 8181
configs["remote_name"] = "gwi1"
configs["verdict"] = "yes"
GWF1_READY = True
elif my_ip==GWF2_IP:
configs["local_port"] = 8282
configs["local_name"] = "gwf2"
configs["remote_ip"] = GWI1_IP
configs["remote_port"] = 8181
configs["remote_name"] = "gwi1"
configs["verdict"] = "yes"
if GWI1_READY:
configs["local_port"] = 8282
configs["local_name"] = "gwf2"
configs["remote_ip"] = GWI1_IP
configs["remote_port"] = 8181
configs["remote_name"] = "gwi1"
configs["verdict"] = "yes"
GWF2_READY = True
elif my_ip==GWF3_IP:
configs["local_port"] = 8282
configs["local_name"] = "gwf3"
configs["remote_ip"] = GWI1_IP
configs["remote_port"] = 8181
configs["remote_name"] = "gwi1"
configs["verdict"] = "yes"
if GWI1_READY:
configs["local_port"] = 8282
configs["local_name"] = "gwf3"
configs["remote_ip"] = GWI1_IP
configs["remote_port"] = 8181
configs["remote_name"] = "gwi1"
configs["verdict"] = "yes"
GWF3_READY = True
elif my_ip==DEV1_GWF1_IP:
configs["local_port"] = 9001
configs["local_name"] = "dev1gwf1"
configs["remote_ip"] = GWF1_IP
configs["remote_port"] = 8282
configs["remote_name"] = "gwf1"
configs["send_period"] = 3000
configs["verdict"] = "yes"
if GWF1_READY:
configs["local_port"] = 9001
configs["local_name"] = "dev1gwf1"
configs["remote_ip"] = GWF1_IP
configs["remote_port"] = 8282
configs["remote_name"] = "gwf1"
configs["send_period"] = 3000
configs["verdict"] = "yes"
elif my_ip==DEV2_GWF1_IP:
configs["local_port"] = 9001
configs["local_name"] = "dev2gwf1"
configs["remote_ip"] = GWF1_IP
configs["remote_port"] = 8282
configs["remote_name"] = "gwf1"
configs["send_period"] = 3000
configs["verdict"] = "yes"
if GWF1_READY:
configs["local_port"] = 9001
configs["local_name"] = "dev2gwf1"
configs["remote_ip"] = GWF1_IP
configs["remote_port"] = 8282
configs["remote_name"] = "gwf1"
configs["send_period"] = 3000
configs["verdict"] = "yes"
elif my_ip==DEV3_GWF1_IP:
configs["local_port"] = 9001
configs["local_name"] = "dev3gwf1"
configs["remote_ip"] = GWF1_IP
configs["remote_port"] = 8282
configs["remote_name"] = "gwf1"
configs["send_period"] = 3000
configs["verdict"] = "yes"
if GWF1_READY:
configs["local_port"] = 9001
configs["local_name"] = "dev3gwf1"
configs["remote_ip"] = GWF1_IP
configs["remote_port"] = 8282
configs["remote_name"] = "gwf1"
configs["send_period"] = 3000
configs["verdict"] = "yes"
elif my_ip==DEV1_GWF2_IP:
configs["local_port"] = 9001
configs["local_name"] = "dev1gwf2"
configs["remote_ip"] = GWF2_IP
configs["remote_port"] = 8282
configs["remote_name"] = "gwf2"
configs["send_period"] = 3000
configs["verdict"] = "yes"
if GWF2_READY:
configs["local_port"] = 9001
configs["local_name"] = "dev1gwf2"
configs["remote_ip"] = GWF2_IP
configs["remote_port"] = 8282
configs["remote_name"] = "gwf2"
configs["send_period"] = 3000
configs["verdict"] = "yes"
elif my_ip==DEV2_GWF2_IP:
configs["local_port"] = 9001
configs["local_name"] = "dev2gwf2"
configs["remote_ip"] = GWF2_IP
configs["remote_port"] = 8282
configs["remote_name"] = "gwf2"
configs["send_period"] = 3000
configs["verdict"] = "yes"
if GWF2_READY:
configs["local_port"] = 9001
configs["local_name"] = "dev2gwf2"
configs["remote_ip"] = GWF2_IP
configs["remote_port"] = 8282
configs["remote_name"] = "gwf2"
configs["send_period"] = 3000
configs["verdict"] = "yes"
elif my_ip==DEV3_GWF2_IP:
configs["local_port"] = 9001
configs["local_name"] = "dev3gwf2"
configs["remote_ip"] = GWF2_IP
configs["remote_port"] = 8282
configs["remote_name"] = "gwf2"
configs["send_period"] = 3000
configs["verdict"] = "yes"
if GWF2_READY:
configs["local_port"] = 9001
configs["local_name"] = "dev3gwf2"
configs["remote_ip"] = GWF2_IP
configs["remote_port"] = 8282
configs["remote_name"] = "gwf2"
configs["send_period"] = 3000
configs["verdict"] = "yes"
elif my_ip==DEV1_GWF3_IP:
configs["local_port"] = 9001
configs["local_name"] = "dev1gwf3"
configs["remote_ip"] = GWF3_IP
configs["remote_port"] = 8282
configs["remote_name"] = "gwf3"
configs["send_period"] = 3000
configs["verdict"] = "yes"
if GWF3_READY:
configs["local_port"] = 9001
configs["local_name"] = "dev1gwf3"
configs["remote_ip"] = GWF3_IP
configs["remote_port"] = 8282
configs["remote_name"] = "gwf3"
configs["send_period"] = 3000
configs["verdict"] = "yes"
elif my_ip==DEV2_GWF3_IP:
configs["local_port"] = 9001
configs["local_name"] = "dev2gwf3"
configs["remote_ip"] = GWF3_IP
configs["remote_port"] = 8282
configs["remote_name"] = "gwf3"
configs["send_period"] = 3000
configs["verdict"] = "yes"
if GWF3_READY:
configs["local_port"] = 9001
configs["local_name"] = "dev2gwf3"
configs["remote_ip"] = GWF3_IP
configs["remote_port"] = 8282
configs["remote_name"] = "gwf3"
configs["send_period"] = 3000
configs["verdict"] = "yes"
elif my_ip==DEV3_GWF3_IP:
configs["local_port"] = 9001
configs["local_name"] = "dev3gwf3"
configs["remote_ip"] = GWF3_IP
configs["remote_port"] = 8282
configs["remote_name"] = "gwf3"
configs["send_period"] = 3000
configs["verdict"] = "yes"
if GWF3_READY:
configs["local_port"] = 9001
configs["local_name"] = "dev3gwf3"
configs["remote_ip"] = GWF3_IP
configs["remote_port"] = 8282
configs["remote_name"] = "gwf3"
configs["send_period"] = 3000
configs["verdict"] = "yes"
return jsonify(configs)
@app.route("/getmyconfig/")
def configurations_giver_to_dc():
configs = {"local_ip":GWI2_IP, "verdict":"yes"}
configs["local_port"] = 8181
configs["local_name"] = "gwi2"
configs["remote_ip"] = SVR_IP
configs["remote_port"] = 8080
configs["remote_name"] = "srv"
global GWI2_READY
configs = {"local_ip":GWI2_IP, "verdict":"oops"}
if SVR_READY:
configs["local_port"] = 8181
configs["local_name"] = "gwi2"
configs["remote_ip"] = SVR_IP
configs["remote_port"] = 8080
configs["remote_name"] = "srv"
configs["verdict"] = "yes"
GWI2_READY = True
return jsonify(configs)
if __name__=='__main__':

View file

@ -3,6 +3,7 @@
import os
import subprocess
import requests
from time import sleep
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)
else:
my_json_config = {"verdict":"oops"}
sleep(3)
def config_json_to_string(json_config):
config = ""

View file

@ -3,6 +3,7 @@
import os
import subprocess
import requests
from time import sleep
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)
else:
my_json_config = {"verdict":"oops"}
sleep(3)
def config_json_to_string(json_config):
config = ""

View file

@ -3,6 +3,7 @@
import os
import subprocess
import requests
from time import sleep
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)
else:
my_json_config = {"verdict":"oops"}
sleep(3)
def config_json_to_string(json_config):
config = ""