From 1047fe1b9c43325a4e619888f9e9caf842c4eff7 Mon Sep 17 00:00:00 2001 From: Daniil Troshkov Date: Wed, 31 Jan 2024 16:17:12 +0400 Subject: [PATCH 01/23] inc FAIL_POLLING_TIME_SECONDS to avoid the spam --- modules/sc-mesh-secure-deployment/src/nats/src/constants.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/sc-mesh-secure-deployment/src/nats/src/constants.py b/modules/sc-mesh-secure-deployment/src/nats/src/constants.py index 6c279786a..60a15a65c 100644 --- a/modules/sc-mesh-secure-deployment/src/nats/src/constants.py +++ b/modules/sc-mesh-secure-deployment/src/nats/src/constants.py @@ -57,7 +57,7 @@ class Constants(Enum): PUT_DEVICE_CERTIFICATES: str = "public/put_device_certificates" OK_POLLING_TIME_SECONDS: int = 600 - FAIL_POLLING_TIME_SECONDS: int = 1 + FAIL_POLLING_TIME_SECONDS: int = 60 if __name__ == "__main__": # Usage From 0c3da2feddc2b40aa85f43540d91d301c3b778a4 Mon Sep 17 00:00:00 2001 From: Daniil Troshkov Date: Wed, 31 Jan 2024 16:59:17 +0400 Subject: [PATCH 02/23] do not use mesh conf for UTM branch --- .../src/nats/comms_nats_controller.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/sc-mesh-secure-deployment/src/nats/comms_nats_controller.py b/modules/sc-mesh-secure-deployment/src/nats/comms_nats_controller.py index 68ac3fded..6ed6f9f21 100644 --- a/modules/sc-mesh-secure-deployment/src/nats/comms_nats_controller.py +++ b/modules/sc-mesh-secure-deployment/src/nats/comms_nats_controller.py @@ -470,6 +470,11 @@ def __action_radio_configuration(self, response: requests.Response) -> str: :param response: https response :return: status """ + + # we do not need for UTM branch + # so just skip this step and return OK status + return "OK" + config: dict = json.loads(response.text) if self.__previous_config_mesh is not None: From db12ea57592f0bb54541e14b5745839c5a6586b6 Mon Sep 17 00:00:00 2001 From: Daniil Troshkov Date: Wed, 31 Jan 2024 17:51:27 +0400 Subject: [PATCH 03/23] debug conf validation fix --- .../src/nats/comms_nats_controller.py | 14 +++++++++++++- .../src/nats/src/constants.py | 1 + 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/modules/sc-mesh-secure-deployment/src/nats/comms_nats_controller.py b/modules/sc-mesh-secure-deployment/src/nats/comms_nats_controller.py index 6ed6f9f21..2ecc47e00 100644 --- a/modules/sc-mesh-secure-deployment/src/nats/comms_nats_controller.py +++ b/modules/sc-mesh-secure-deployment/src/nats/comms_nats_controller.py @@ -179,6 +179,7 @@ def __init__( StatusType.UPLOAD_CERTIFICATES.value: "OK" if self.__certs_uploaded else "FAIL", + StatusType.DOWNLOAD_DEBUG_CONFIG.value: "FAIL", } self.__config_status_mapping = { @@ -187,6 +188,7 @@ def __init__( ConfigType.BIRTH_CERTIFICATE: StatusType.DOWNLOAD_CERTIFICATES, ConfigType.LOWER_CERTIFICATE: StatusType.DOWNLOAD_CERTIFICATES, ConfigType.UPPER_CERTIFICATE: StatusType.DOWNLOAD_CERTIFICATES, + ConfigType.DEBUG_CONFIG: StatusType.DOWNLOAD_DEBUG_CONFIG, } try: @@ -1290,6 +1292,12 @@ def __validate_response( ) else: self.logger.error("Validation not implemented, unknown config") + elif response.status_code == 405: + if config == ConfigType.DEBUG_CONFIG: + # It is OK: server do not support debug mode + status = "OK" + else: + status = "FAIL" else: status = "FAIL" @@ -1325,14 +1333,17 @@ async def __loop_run_executor(self, executor, config: ConfigType) -> None: response.status_code == 200 and self.__previous_debug_config != response.text.strip() ): - self.__handle_received_config(response, ConfigType.DEBUG_CONFIG) + ret = self.__handle_received_config(response, ConfigType.DEBUG_CONFIG) self.__mesh_conf_request_processed = False + if ret == "OK": + self.__status[status_type] = "OK" elif ( response.status_code == 200 and self.__previous_debug_config == response.text.strip() ): self.__debug_config_interval = Constants.OK_POLLING_TIME_SECONDS.value self.__mesh_conf_request_processed = False + self.__status[status_type] = "OK" elif response.text.strip() == "" or response.status_code != 200: self.__debug_config_interval = Constants.FAIL_POLLING_TIME_SECONDS.value if response.status_code == 405: @@ -1343,6 +1354,7 @@ async def __loop_run_executor(self, executor, config: ConfigType) -> None: Constants.OK_POLLING_TIME_SECONDS.value ) self.__mesh_conf_request_processed = False + self.__status[status_type] = "OK" else: if response.status_code == 200: ret = self.__handle_received_config(response, config) diff --git a/modules/sc-mesh-secure-deployment/src/nats/src/constants.py b/modules/sc-mesh-secure-deployment/src/nats/src/constants.py index 60a15a65c..e4602e9ec 100644 --- a/modules/sc-mesh-secure-deployment/src/nats/src/constants.py +++ b/modules/sc-mesh-secure-deployment/src/nats/src/constants.py @@ -26,6 +26,7 @@ class StatusType(str, Enum): DOWNLOAD_FEATURES: str = "download_features" DOWNLOAD_CERTIFICATES: str = "download_certificates" UPLOAD_CERTIFICATES: str = "upload_certificates" + DOWNLOAD_DEBUG_CONFIG: str = "download_debug_config" # pylint: disable=too-few-public-methods, too-many-instance-attributes, disable=invalid-name class Constants(Enum): From d4c90c517258d0624f57b2c79cd5d7e54b3aeb18 Mon Sep 17 00:00:00 2001 From: Daniil Troshkov Date: Thu, 1 Feb 2024 09:19:50 +0400 Subject: [PATCH 04/23] fail polling time bak to 1 sec --- modules/sc-mesh-secure-deployment/src/nats/src/constants.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/sc-mesh-secure-deployment/src/nats/src/constants.py b/modules/sc-mesh-secure-deployment/src/nats/src/constants.py index e4602e9ec..44b56e0d3 100644 --- a/modules/sc-mesh-secure-deployment/src/nats/src/constants.py +++ b/modules/sc-mesh-secure-deployment/src/nats/src/constants.py @@ -58,7 +58,7 @@ class Constants(Enum): PUT_DEVICE_CERTIFICATES: str = "public/put_device_certificates" OK_POLLING_TIME_SECONDS: int = 600 - FAIL_POLLING_TIME_SECONDS: int = 60 + FAIL_POLLING_TIME_SECONDS: int = 1 if __name__ == "__main__": # Usage From ac9c717183e34f19b8f82c030f9ca64a14c9dd4d Mon Sep 17 00:00:00 2001 From: Daniil Troshkov Date: Thu, 1 Feb 2024 14:52:21 +0400 Subject: [PATCH 05/23] feat: UTM conf --- .../src/nats/comms_nats_controller.py | 51 +++++++++++++++++++ .../src/nats/src/constants.py | 2 + 2 files changed, 53 insertions(+) diff --git a/modules/sc-mesh-secure-deployment/src/nats/comms_nats_controller.py b/modules/sc-mesh-secure-deployment/src/nats/comms_nats_controller.py index 2ecc47e00..d533316ec 100644 --- a/modules/sc-mesh-secure-deployment/src/nats/comms_nats_controller.py +++ b/modules/sc-mesh-secure-deployment/src/nats/comms_nats_controller.py @@ -98,6 +98,9 @@ def __init__( self.__previous_debug_config: Optional[ str ] = self.__read_debug_config_from_file() + self.__previous_config_utm: Optional[str] = self.__read_config_from_file( + ConfigType.UTM_CONFIG.value + ) self.__mesh_conf_request_processed = False self.__comms_ctrl: comms_controller.CommsController = comms_ctrl self.logger: logging = self.__comms_ctrl.logger.getChild("mdm_agent") @@ -180,6 +183,7 @@ def __init__( if self.__certs_uploaded else "FAIL", StatusType.DOWNLOAD_DEBUG_CONFIG.value: "FAIL", + StatusType.DOWNLOAD_UTM_CONFIG.value: "FAIL", } self.__config_status_mapping = { @@ -189,6 +193,7 @@ def __init__( ConfigType.LOWER_CERTIFICATE: StatusType.DOWNLOAD_CERTIFICATES, ConfigType.UPPER_CERTIFICATE: StatusType.DOWNLOAD_CERTIFICATES, ConfigType.DEBUG_CONFIG: StatusType.DOWNLOAD_DEBUG_CONFIG, + ConfigType.UTM_CONFIG: StatusType.DOWNLOAD_UTM_CONFIG, } try: @@ -331,6 +336,7 @@ async def execute(self) -> None: elif self.mdm_service_available: await self.__loop_run_executor(self.executor, ConfigType.FEATURES) await self.__loop_run_executor(self.executor, ConfigType.MESH_CONFIG) + await self.__loop_run_executor(self.executor, ConfigType.UTM_CONFIG) if self.__mesh_conf_request_processed: await self.__loop_run_executor( self.executor, ConfigType.DEBUG_CONFIG @@ -466,6 +472,38 @@ def __action_certificates( return "FAIL" return "OK" + def __action_utm_configuration(self, response: requests.Response) -> str: + """ + Take utm configuration into use + :param response: https response + :return: status + """ + + config: dict = json.loads(response.text) + + if self.__previous_config_utm not None: + self.logger.debug( + f"config: {config} previous: {json.loads(self.__previous_config_utm)}" + ) + + if json.loads(self.__previous_config_utm) == config: + self.logger.debug( + "No changes in UTM config, not updating." + ) + return "OK" + + self.logger.debug("No previous UTM config") + + self.__config_version = int(config["version"]) + self.__write_config_to_file(response, ConfigType.UTM_CONFIG.value) + + self.__previous_config_utm = self.__read_config_from_file( + ConfigType.UTM_CONFIG.value + ) + + return "OK" + + def __action_radio_configuration(self, response: requests.Response) -> str: """ Take radio configuration into use @@ -620,6 +658,11 @@ def __handle_received_config( ret = self.__action_feature_yaml(response) return ret + # UTM configuration actions + if config.value == ConfigType.UTM_CONFIG.value: + ret = self.__action_utm_configuration(response) + return ret + @staticmethod def __read_config_from_file(config: str) -> Optional[str]: """ @@ -1290,6 +1333,14 @@ def __validate_response( self.logger.error( "Debug config field not found in config" ) + elif config == ConfigType.UTM_CONFIG: + try: + if json.loads(response.text)["payload"]["utm_config"]: + status = "OK" + except KeyError: + self.logger.error( + "UTM config field not found in config" + ) else: self.logger.error("Validation not implemented, unknown config") elif response.status_code == 405: diff --git a/modules/sc-mesh-secure-deployment/src/nats/src/constants.py b/modules/sc-mesh-secure-deployment/src/nats/src/constants.py index 44b56e0d3..f3f050c26 100644 --- a/modules/sc-mesh-secure-deployment/src/nats/src/constants.py +++ b/modules/sc-mesh-secure-deployment/src/nats/src/constants.py @@ -14,6 +14,7 @@ class ConfigType(str, Enum): LOWER_CERTIFICATE: str = "lower_certificates" FEATURES: str = "features" DEBUG_CONFIG: str = "debug_conf" + UTM_CONFIG: str = "utm_conf" class StatusType(str, Enum): @@ -27,6 +28,7 @@ class StatusType(str, Enum): DOWNLOAD_CERTIFICATES: str = "download_certificates" UPLOAD_CERTIFICATES: str = "upload_certificates" DOWNLOAD_DEBUG_CONFIG: str = "download_debug_config" + DOWNLOAD_UTM_CONFIG: str = "download_utm_config" # pylint: disable=too-few-public-methods, too-many-instance-attributes, disable=invalid-name class Constants(Enum): From 6260be9f9b668089e9d9819c05262fa9e804249f Mon Sep 17 00:00:00 2001 From: Daniil Troshkov Date: Thu, 1 Feb 2024 15:27:38 +0400 Subject: [PATCH 06/23] fix: typo --- .../sc-mesh-secure-deployment/src/nats/comms_nats_controller.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/sc-mesh-secure-deployment/src/nats/comms_nats_controller.py b/modules/sc-mesh-secure-deployment/src/nats/comms_nats_controller.py index d533316ec..816209242 100644 --- a/modules/sc-mesh-secure-deployment/src/nats/comms_nats_controller.py +++ b/modules/sc-mesh-secure-deployment/src/nats/comms_nats_controller.py @@ -481,7 +481,7 @@ def __action_utm_configuration(self, response: requests.Response) -> str: config: dict = json.loads(response.text) - if self.__previous_config_utm not None: + if self.__previous_config_utm is not None: self.logger.debug( f"config: {config} previous: {json.loads(self.__previous_config_utm)}" ) From 8eab48bd0d84cd79c6f6714089a817e66284e117 Mon Sep 17 00:00:00 2001 From: Daniil Troshkov Date: Fri, 2 Feb 2024 12:22:09 +0400 Subject: [PATCH 07/23] debug: increase polling time to avoid spam --- modules/sc-mesh-secure-deployment/src/nats/src/constants.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/sc-mesh-secure-deployment/src/nats/src/constants.py b/modules/sc-mesh-secure-deployment/src/nats/src/constants.py index f3f050c26..9a1537681 100644 --- a/modules/sc-mesh-secure-deployment/src/nats/src/constants.py +++ b/modules/sc-mesh-secure-deployment/src/nats/src/constants.py @@ -60,7 +60,7 @@ class Constants(Enum): PUT_DEVICE_CERTIFICATES: str = "public/put_device_certificates" OK_POLLING_TIME_SECONDS: int = 600 - FAIL_POLLING_TIME_SECONDS: int = 1 + FAIL_POLLING_TIME_SECONDS: int = 10 if __name__ == "__main__": # Usage From 8a4e24819d73f32761f8090e2a8edf2114311234 Mon Sep 17 00:00:00 2001 From: Daniil Troshkov Date: Fri, 2 Feb 2024 14:09:51 +0400 Subject: [PATCH 08/23] fix: typo --- .../sc-mesh-secure-deployment/src/nats/comms_nats_controller.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/sc-mesh-secure-deployment/src/nats/comms_nats_controller.py b/modules/sc-mesh-secure-deployment/src/nats/comms_nats_controller.py index 816209242..adb507d8e 100644 --- a/modules/sc-mesh-secure-deployment/src/nats/comms_nats_controller.py +++ b/modules/sc-mesh-secure-deployment/src/nats/comms_nats_controller.py @@ -1335,7 +1335,7 @@ def __validate_response( ) elif config == ConfigType.UTM_CONFIG: try: - if json.loads(response.text)["payload"]["utm_config"]: + if json.loads(response.text)["payload"]["utm_conf"]: status = "OK" except KeyError: self.logger.error( From c629b01aeed24490e4cdbd4ad290260d20e7d88e Mon Sep 17 00:00:00 2001 From: Daniil Troshkov Date: Fri, 2 Feb 2024 14:48:01 +0400 Subject: [PATCH 09/23] debug: debug_conf req --- .../src/nats/comms_nats_controller.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/sc-mesh-secure-deployment/src/nats/comms_nats_controller.py b/modules/sc-mesh-secure-deployment/src/nats/comms_nats_controller.py index adb507d8e..5aeea2b8d 100644 --- a/modules/sc-mesh-secure-deployment/src/nats/comms_nats_controller.py +++ b/modules/sc-mesh-secure-deployment/src/nats/comms_nats_controller.py @@ -1412,14 +1412,16 @@ async def __loop_run_executor(self, executor, config: ConfigType) -> None: self.logger.debug("config: %s, ret: %s", config, ret) if ret == "OK": self.__status[status_type] = "OK" - if config.value == ConfigType.MESH_CONFIG.value and ret == "OK": - self.__mesh_conf_request_processed = True elif response.status_code != 200: self.__status[status_type] = "FAIL" # if all statuses are OK, then we can start the OK polling if all(value == "OK" for value in self.__status.values()): self.__interval = Constants.OK_POLLING_TIME_SECONDS.value + self.__mesh_conf_request_processed = True + self.logger.debug( + "************ all statuses are OK !!!" + ) else: self.__interval = Constants.FAIL_POLLING_TIME_SECONDS.value From 5e4862d9202c4d50524ba066de959c868eeeb203 Mon Sep 17 00:00:00 2001 From: Daniil Troshkov Date: Fri, 2 Feb 2024 15:27:20 +0400 Subject: [PATCH 10/23] debug: debug_conf in special flow --- .../src/nats/comms_nats_controller.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/sc-mesh-secure-deployment/src/nats/comms_nats_controller.py b/modules/sc-mesh-secure-deployment/src/nats/comms_nats_controller.py index 5aeea2b8d..50a551ae1 100644 --- a/modules/sc-mesh-secure-deployment/src/nats/comms_nats_controller.py +++ b/modules/sc-mesh-secure-deployment/src/nats/comms_nats_controller.py @@ -182,7 +182,7 @@ def __init__( StatusType.UPLOAD_CERTIFICATES.value: "OK" if self.__certs_uploaded else "FAIL", - StatusType.DOWNLOAD_DEBUG_CONFIG.value: "FAIL", + #StatusType.DOWNLOAD_DEBUG_CONFIG.value: "FAIL", StatusType.DOWNLOAD_UTM_CONFIG.value: "FAIL", } @@ -192,7 +192,7 @@ def __init__( ConfigType.BIRTH_CERTIFICATE: StatusType.DOWNLOAD_CERTIFICATES, ConfigType.LOWER_CERTIFICATE: StatusType.DOWNLOAD_CERTIFICATES, ConfigType.UPPER_CERTIFICATE: StatusType.DOWNLOAD_CERTIFICATES, - ConfigType.DEBUG_CONFIG: StatusType.DOWNLOAD_DEBUG_CONFIG, + #ConfigType.DEBUG_CONFIG: StatusType.DOWNLOAD_DEBUG_CONFIG, ConfigType.UTM_CONFIG: StatusType.DOWNLOAD_UTM_CONFIG, } From b023f49ea7f849591e64b328805a015a665be428 Mon Sep 17 00:00:00 2001 From: Daniil Troshkov Date: Mon, 5 Feb 2024 13:49:19 +0400 Subject: [PATCH 11/23] feat: entrypoint_mdm_agent_utm --- .../utils/docker/entrypoint_mdm_agent_utm.sh | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100755 modules/utils/docker/entrypoint_mdm_agent_utm.sh diff --git a/modules/utils/docker/entrypoint_mdm_agent_utm.sh b/modules/utils/docker/entrypoint_mdm_agent_utm.sh new file mode 100755 index 000000000..e3ed4b881 --- /dev/null +++ b/modules/utils/docker/entrypoint_mdm_agent_utm.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +source /opt/mesh-helper.sh + + ####################################### + # BC needs to be on place before this # + ####################################### + + # TODO: Identity from BC or HSM? + if [ ! -f "/opt/identity" ]; then + echo "generates identity id" + generate_identity_id + fi + + sleep 3 + + ####################################### + # Enable MDM stuff # + ####################################### + echo "starting mdm agent for testing purposes" + /opt/S90mdm_agent start From 779651378e52d972cd04a7bf202b406fc42e3d63 Mon Sep 17 00:00:00 2001 From: Daniil Troshkov Date: Mon, 5 Feb 2024 17:40:03 +0400 Subject: [PATCH 12/23] debug: entrypoint_mdm_agent_utm --- .../utils/docker/entrypoint_mdm_agent_utm.sh | 81 +++++++++++++++++++ 1 file changed, 81 insertions(+) diff --git a/modules/utils/docker/entrypoint_mdm_agent_utm.sh b/modules/utils/docker/entrypoint_mdm_agent_utm.sh index e3ed4b881..f915aa367 100755 --- a/modules/utils/docker/entrypoint_mdm_agent_utm.sh +++ b/modules/utils/docker/entrypoint_mdm_agent_utm.sh @@ -2,6 +2,17 @@ source /opt/mesh-helper.sh +# sources mesh configuration and sets start_opts +source_configuration "0" + +if [ "$MSVERSION" != "nats" ]; then + if [ -f "/usr/local/bin/entrypoint.sh" ]; then + /bin/bash /usr/local/bin/entrypoint.sh + else + /bin/bash /opt/mesh_com/modules/utils/docker/entrypoint.sh + fi +else + ####################################### # BC needs to be on place before this # ####################################### @@ -12,6 +23,32 @@ source /opt/mesh-helper.sh generate_identity_id fi + ####################################### + # Initialise default radios and IF # + ####################################### + + # Do not continue in case halow init has not finished + # Halow is slow to start, so we wait for it to finish + while ps aux | grep [i]nit_halow > /dev/null; do + sleep 1 + done + + echo "Starting 11s mesh service" + # Loop for mesh service + for i in {0..2}; do + if [ "$i" -eq 0 ] || [ -f "/opt/${i}_mesh.conf" ]; then + /opt/S9011sNatsMesh start id"$i" + fi + done + + echo "Starting AP service" + # Loop for AP service + for i in {0..2}; do + if [ "$i" -eq 0 ] || [ -f "/opt/${i}_mesh.conf" ]; then + /opt/S90APoint start id"$i" + fi + done + sleep 3 ####################################### @@ -19,3 +56,47 @@ source /opt/mesh-helper.sh ####################################### echo "starting mdm agent for testing purposes" /opt/S90mdm_agent start + + # Start jamming service + JAMMING=$(extract_features_value "jamming" $YAML_FILE) + if [ "$JAMMING" == "true" ]; then + echo "starting jamming avoidance service" + /opt/S99jammingavoidance start + fi + + ####################################### + # Enable FMO stuff # + ####################################### + # FMO can be configured in the features.yaml file + FMO=$(extract_features_value "FMO" $YAML_FILE) + if [ "$FMO" = "true" ]; then + echo "starting Alfred" + /opt/S90Alfred start + + echo "starting provisioning agent" + # blocks execution until provisioning is done or timeout (30s) + # IP address and port are passed as arguments and hardcoded. + python /opt/nats/src/comms_provisioning.py -t 30 -s 192.168.1.254 -p 8080 -o /opt > /opt/comms_provisioning.log 2>&1 + + echo "Start nats server and client nodes" + /opt/S90nats_discovery start + + echo "wait for nats.conf to be created" + until [ -f /var/run/nats.conf ]; do + sleep 1 + done + + echo "starting nats server" + /opt/S90nats_server start + + echo "starting comms services" + /opt/S90comms_controller start + fi # FMO + + echo "starting mptcp" + if [ -f "/var/run/mptcp.conf" ]; then + /opt/S90mptcp start + fi + # alive + nohup /bin/bash -c "while true; do sleep infinity; done" +fi From 52fc2b1e9ffa3ae18a68037452404e59074b9b69 Mon Sep 17 00:00:00 2001 From: Daniil Troshkov Date: Tue, 6 Feb 2024 08:54:03 +0400 Subject: [PATCH 13/23] cleanup: rm jumming and FMO --- .../utils/docker/entrypoint_mdm_agent_utm.sh | 43 ------------------- 1 file changed, 43 deletions(-) diff --git a/modules/utils/docker/entrypoint_mdm_agent_utm.sh b/modules/utils/docker/entrypoint_mdm_agent_utm.sh index f915aa367..991029b1a 100755 --- a/modules/utils/docker/entrypoint_mdm_agent_utm.sh +++ b/modules/utils/docker/entrypoint_mdm_agent_utm.sh @@ -56,47 +56,4 @@ else ####################################### echo "starting mdm agent for testing purposes" /opt/S90mdm_agent start - - # Start jamming service - JAMMING=$(extract_features_value "jamming" $YAML_FILE) - if [ "$JAMMING" == "true" ]; then - echo "starting jamming avoidance service" - /opt/S99jammingavoidance start - fi - - ####################################### - # Enable FMO stuff # - ####################################### - # FMO can be configured in the features.yaml file - FMO=$(extract_features_value "FMO" $YAML_FILE) - if [ "$FMO" = "true" ]; then - echo "starting Alfred" - /opt/S90Alfred start - - echo "starting provisioning agent" - # blocks execution until provisioning is done or timeout (30s) - # IP address and port are passed as arguments and hardcoded. - python /opt/nats/src/comms_provisioning.py -t 30 -s 192.168.1.254 -p 8080 -o /opt > /opt/comms_provisioning.log 2>&1 - - echo "Start nats server and client nodes" - /opt/S90nats_discovery start - - echo "wait for nats.conf to be created" - until [ -f /var/run/nats.conf ]; do - sleep 1 - done - - echo "starting nats server" - /opt/S90nats_server start - - echo "starting comms services" - /opt/S90comms_controller start - fi # FMO - - echo "starting mptcp" - if [ -f "/var/run/mptcp.conf" ]; then - /opt/S90mptcp start - fi - # alive - nohup /bin/bash -c "while true; do sleep infinity; done" fi From db366e94be288a6f6409988062884d79dc368c12 Mon Sep 17 00:00:00 2001 From: Daniil Troshkov Date: Tue, 6 Feb 2024 11:57:32 +0400 Subject: [PATCH 14/23] cleanup: AP service --- modules/utils/docker/entrypoint_mdm_agent_utm.sh | 8 -------- 1 file changed, 8 deletions(-) diff --git a/modules/utils/docker/entrypoint_mdm_agent_utm.sh b/modules/utils/docker/entrypoint_mdm_agent_utm.sh index 991029b1a..c0260b47f 100755 --- a/modules/utils/docker/entrypoint_mdm_agent_utm.sh +++ b/modules/utils/docker/entrypoint_mdm_agent_utm.sh @@ -41,14 +41,6 @@ else fi done - echo "Starting AP service" - # Loop for AP service - for i in {0..2}; do - if [ "$i" -eq 0 ] || [ -f "/opt/${i}_mesh.conf" ]; then - /opt/S90APoint start id"$i" - fi - done - sleep 3 ####################################### From ecbf7a099d0a81065f3b64c2eab09b54177b25bb Mon Sep 17 00:00:00 2001 From: Daniil Troshkov Date: Tue, 6 Feb 2024 14:35:06 +0400 Subject: [PATCH 15/23] cleanup: 11s mesh service:w --- modules/utils/docker/entrypoint_mdm_agent_utm.sh | 8 -------- 1 file changed, 8 deletions(-) diff --git a/modules/utils/docker/entrypoint_mdm_agent_utm.sh b/modules/utils/docker/entrypoint_mdm_agent_utm.sh index c0260b47f..9f0dff877 100755 --- a/modules/utils/docker/entrypoint_mdm_agent_utm.sh +++ b/modules/utils/docker/entrypoint_mdm_agent_utm.sh @@ -33,14 +33,6 @@ else sleep 1 done - echo "Starting 11s mesh service" - # Loop for mesh service - for i in {0..2}; do - if [ "$i" -eq 0 ] || [ -f "/opt/${i}_mesh.conf" ]; then - /opt/S9011sNatsMesh start id"$i" - fi - done - sleep 3 ####################################### From 5cad2ee82aeca059c3270ed371c9e75330444bfd Mon Sep 17 00:00:00 2001 From: Daniil Troshkov Date: Tue, 6 Feb 2024 15:09:12 +0400 Subject: [PATCH 16/23] cleanup: radio init --- modules/utils/docker/entrypoint_mdm_agent_utm.sh | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/modules/utils/docker/entrypoint_mdm_agent_utm.sh b/modules/utils/docker/entrypoint_mdm_agent_utm.sh index 9f0dff877..6ade3d9a7 100755 --- a/modules/utils/docker/entrypoint_mdm_agent_utm.sh +++ b/modules/utils/docker/entrypoint_mdm_agent_utm.sh @@ -23,16 +23,6 @@ else generate_identity_id fi - ####################################### - # Initialise default radios and IF # - ####################################### - - # Do not continue in case halow init has not finished - # Halow is slow to start, so we wait for it to finish - while ps aux | grep [i]nit_halow > /dev/null; do - sleep 1 - done - sleep 3 ####################################### From 749f886e7d6011cf63c8e6d4513264ae28c05543 Mon Sep 17 00:00:00 2001 From: Daniil Troshkov Date: Tue, 6 Feb 2024 17:23:49 +0400 Subject: [PATCH 17/23] cleanup: mesh basic init --- modules/utils/docker/entrypoint_mdm_agent_utm.sh | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/modules/utils/docker/entrypoint_mdm_agent_utm.sh b/modules/utils/docker/entrypoint_mdm_agent_utm.sh index 6ade3d9a7..11200906b 100755 --- a/modules/utils/docker/entrypoint_mdm_agent_utm.sh +++ b/modules/utils/docker/entrypoint_mdm_agent_utm.sh @@ -2,17 +2,6 @@ source /opt/mesh-helper.sh -# sources mesh configuration and sets start_opts -source_configuration "0" - -if [ "$MSVERSION" != "nats" ]; then - if [ -f "/usr/local/bin/entrypoint.sh" ]; then - /bin/bash /usr/local/bin/entrypoint.sh - else - /bin/bash /opt/mesh_com/modules/utils/docker/entrypoint.sh - fi -else - ####################################### # BC needs to be on place before this # ####################################### @@ -23,11 +12,8 @@ else generate_identity_id fi - sleep 3 - ####################################### # Enable MDM stuff # ####################################### echo "starting mdm agent for testing purposes" /opt/S90mdm_agent start -fi From a3c416110a7f351c4c52f0894ee5a918228036a4 Mon Sep 17 00:00:00 2001 From: Daniil Troshkov Date: Tue, 6 Feb 2024 17:44:35 +0400 Subject: [PATCH 18/23] style: NFC --- .../utils/docker/entrypoint_mdm_agent_utm.sh | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/modules/utils/docker/entrypoint_mdm_agent_utm.sh b/modules/utils/docker/entrypoint_mdm_agent_utm.sh index 11200906b..3348c0884 100755 --- a/modules/utils/docker/entrypoint_mdm_agent_utm.sh +++ b/modules/utils/docker/entrypoint_mdm_agent_utm.sh @@ -2,18 +2,18 @@ source /opt/mesh-helper.sh - ####################################### - # BC needs to be on place before this # - ####################################### +####################################### +# BC needs to be on place before this # +####################################### - # TODO: Identity from BC or HSM? - if [ ! -f "/opt/identity" ]; then - echo "generates identity id" - generate_identity_id - fi +# TODO: Identity from BC or HSM? +if [ ! -f "/opt/identity" ]; then + echo "generates identity id" + generate_identity_id +fi - ####################################### - # Enable MDM stuff # - ####################################### - echo "starting mdm agent for testing purposes" - /opt/S90mdm_agent start +####################################### +# Enable MDM stuff # +####################################### +echo "starting mdm agent for testing purposes" +/opt/S90mdm_agent start From 997b5c882f6237d3d276b38e646a5bdb26527fac Mon Sep 17 00:00:00 2001 From: Daniil Troshkov Date: Tue, 6 Feb 2024 18:16:37 +0400 Subject: [PATCH 19/23] fix: Try to avoid this error: Traceback (most recent call last): File "/opt/nats/comms_nats_controller.py", line 1498, in main_mdm results = await asyncio.gather(mdm.execute()) File "/opt/nats/comms_nats_controller.py", line 324, in execute self.setup_cbma() File "/opt/nats/comms_nats_controller.py", line 1193, in setup_cbma bridge_setting = self.__comms_ctrl.settings.bridge[0] IndexError: list index out of range with mdm_agent standalone run --- .../src/nats/comms_nats_controller.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/sc-mesh-secure-deployment/src/nats/comms_nats_controller.py b/modules/sc-mesh-secure-deployment/src/nats/comms_nats_controller.py index 50a551ae1..fd80411ea 100644 --- a/modules/sc-mesh-secure-deployment/src/nats/comms_nats_controller.py +++ b/modules/sc-mesh-secure-deployment/src/nats/comms_nats_controller.py @@ -321,7 +321,8 @@ async def execute(self) -> None: ): # Restart CBMA with new certificates self.stop_cbma() - self.setup_cbma() + if self.__is_cbma_feature_enabled(): + self.setup_cbma() if ( self.__status[StatusType.DOWNLOAD_CERTIFICATES.value] == "FAIL" From 64b16759ce1636f220df0207581cf3eae4c15751 Mon Sep 17 00:00:00 2001 From: Daniil Troshkov Date: Thu, 8 Feb 2024 09:35:52 +0400 Subject: [PATCH 20/23] fix: typo NFC --- .../sc-mesh-secure-deployment/src/nats/comms_nats_controller.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/sc-mesh-secure-deployment/src/nats/comms_nats_controller.py b/modules/sc-mesh-secure-deployment/src/nats/comms_nats_controller.py index fd80411ea..171a71389 100644 --- a/modules/sc-mesh-secure-deployment/src/nats/comms_nats_controller.py +++ b/modules/sc-mesh-secure-deployment/src/nats/comms_nats_controller.py @@ -512,7 +512,7 @@ def __action_radio_configuration(self, response: requests.Response) -> str: :return: status """ - # we do not need for UTM branch + # we do not need it for UTM branch # so just skip this step and return OK status return "OK" From 9648ed0684de1ee28245280d84cdfbfc4f345d1d Mon Sep 17 00:00:00 2001 From: Daniil Troshkov Date: Thu, 8 Feb 2024 10:11:40 +0400 Subject: [PATCH 21/23] style: NFC --- .../sc-mesh-secure-deployment/src/nats/comms_nats_controller.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/sc-mesh-secure-deployment/src/nats/comms_nats_controller.py b/modules/sc-mesh-secure-deployment/src/nats/comms_nats_controller.py index 171a71389..75566d6f6 100644 --- a/modules/sc-mesh-secure-deployment/src/nats/comms_nats_controller.py +++ b/modules/sc-mesh-secure-deployment/src/nats/comms_nats_controller.py @@ -1421,7 +1421,7 @@ async def __loop_run_executor(self, executor, config: ConfigType) -> None: self.__interval = Constants.OK_POLLING_TIME_SECONDS.value self.__mesh_conf_request_processed = True self.logger.debug( - "************ all statuses are OK !!!" + "All statuses are OK." ) else: self.__interval = Constants.FAIL_POLLING_TIME_SECONDS.value From a714a2448915298a81573ac8def5a013ffe3ca99 Mon Sep 17 00:00:00 2001 From: Daniil Troshkov Date: Thu, 8 Feb 2024 10:31:59 +0400 Subject: [PATCH 22/23] debug: decrease back polling ok time --- modules/sc-mesh-secure-deployment/src/nats/src/constants.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/sc-mesh-secure-deployment/src/nats/src/constants.py b/modules/sc-mesh-secure-deployment/src/nats/src/constants.py index 9a1537681..f3f050c26 100644 --- a/modules/sc-mesh-secure-deployment/src/nats/src/constants.py +++ b/modules/sc-mesh-secure-deployment/src/nats/src/constants.py @@ -60,7 +60,7 @@ class Constants(Enum): PUT_DEVICE_CERTIFICATES: str = "public/put_device_certificates" OK_POLLING_TIME_SECONDS: int = 600 - FAIL_POLLING_TIME_SECONDS: int = 10 + FAIL_POLLING_TIME_SECONDS: int = 1 if __name__ == "__main__": # Usage From 757476b06cf313a0f76829f0b69fed2eb53ab87f Mon Sep 17 00:00:00 2001 From: Daniil Troshkov Date: Thu, 8 Feb 2024 11:37:00 +0400 Subject: [PATCH 23/23] cleanup: NFC --- modules/utils/docker/entrypoint_mdm_agent_utm.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/utils/docker/entrypoint_mdm_agent_utm.sh b/modules/utils/docker/entrypoint_mdm_agent_utm.sh index 3348c0884..af4df0b79 100755 --- a/modules/utils/docker/entrypoint_mdm_agent_utm.sh +++ b/modules/utils/docker/entrypoint_mdm_agent_utm.sh @@ -15,5 +15,5 @@ fi ####################################### # Enable MDM stuff # ####################################### -echo "starting mdm agent for testing purposes" +echo "starting mdm agent" /opt/S90mdm_agent start