From 45612c1d88fd6a98a7b7c3f1a92e42fac502ca10 Mon Sep 17 00:00:00 2001 From: Abdel-Kader Chabi-Sika-Boni Date: Sat, 2 Jan 2021 18:20:06 +0100 Subject: [PATCH] mise a jour --- .../bootserver/bootstrap_client.py | 2 + .../bootserver/bootstrap_server.py | 221 ++++++++++-------- .../device/bootstrap_client.py | 2 + .../gateway/bootstrap_client.py | 2 + .../server/bootstrap_client.py | 2 + 5 files changed, 136 insertions(+), 93 deletions(-) diff --git a/Dockerfiles/forContainerNet/bootserver/bootstrap_client.py b/Dockerfiles/forContainerNet/bootserver/bootstrap_client.py index d2f06a7..07a48b5 100755 --- a/Dockerfiles/forContainerNet/bootserver/bootstrap_client.py +++ b/Dockerfiles/forContainerNet/bootserver/bootstrap_client.py @@ -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 = "" diff --git a/Dockerfiles/forContainerNet/bootserver/bootstrap_server.py b/Dockerfiles/forContainerNet/bootserver/bootstrap_server.py index 960407c..89a24f8 100755 --- a/Dockerfiles/forContainerNet/bootserver/bootstrap_server.py +++ b/Dockerfiles/forContainerNet/bootserver/bootstrap_server.py @@ -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/") 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__': diff --git a/Dockerfiles/forContainerNet/device/bootstrap_client.py b/Dockerfiles/forContainerNet/device/bootstrap_client.py index d2f06a7..07a48b5 100755 --- a/Dockerfiles/forContainerNet/device/bootstrap_client.py +++ b/Dockerfiles/forContainerNet/device/bootstrap_client.py @@ -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 = "" diff --git a/Dockerfiles/forContainerNet/gateway/bootstrap_client.py b/Dockerfiles/forContainerNet/gateway/bootstrap_client.py index d2f06a7..07a48b5 100755 --- a/Dockerfiles/forContainerNet/gateway/bootstrap_client.py +++ b/Dockerfiles/forContainerNet/gateway/bootstrap_client.py @@ -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 = "" diff --git a/Dockerfiles/forContainerNet/server/bootstrap_client.py b/Dockerfiles/forContainerNet/server/bootstrap_client.py index d2f06a7..07a48b5 100755 --- a/Dockerfiles/forContainerNet/server/bootstrap_client.py +++ b/Dockerfiles/forContainerNet/server/bootstrap_client.py @@ -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 = ""