From f9c078f907b7aec9e52d1402a0ddf13e1fbf2f30 Mon Sep 17 00:00:00 2001 From: sonic-otn Date: Thu, 11 Jan 2024 18:30:23 +0800 Subject: [PATCH] generate otn linecards configuration at boot time and set bgp service as global service on otn platform --- files/build_templates/init_cfg.json.j2 | 4 +++ files/image_config/config-setup/config-setup | 37 ++++++++++++++++++-- 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/files/build_templates/init_cfg.json.j2 b/files/build_templates/init_cfg.json.j2 index c3e2e61f1806..63d5b3234724 100644 --- a/files/build_templates/init_cfg.json.j2 +++ b/files/build_templates/init_cfg.json.j2 @@ -74,7 +74,11 @@ "{{feature}}": { "state": "{{state}}", "delayed" : {{delayed | lower()}}, + {%- if feature in ["bgp"] and sonic_asic_platform.startswith('ot-') %} + "has_global_scope": true, + {%- else %} "has_global_scope": {% if feature + '.service' in installer_services.split(' ') %}true{% else %}false{% endif %}, + {%- endif %} {%- if feature in ["lldp"] %} {%- if sonic_asic_platform.startswith('ot-') %} "has_per_asic_scope": "False", diff --git a/files/image_config/config-setup/config-setup b/files/image_config/config-setup/config-setup index a70c6c92cae5..0f5db16380f8 100755 --- a/files/image_config/config-setup/config-setup +++ b/files/image_config/config-setup/config-setup @@ -298,6 +298,37 @@ do_config_initialization() sonic-db-cli CONFIG_DB SET "CONFIG_DB_INITIALIZED" "1" } +# Create OTN device SONiC configuration for first time bootup, it will generate global configration from init_cfg, +# and empty configruations for other asic namespaces +do_otn_config_initialization() +{ + echo "init otn configuration" + need_reload_config=false + + cfg_file_json_list='' + for cfg_file in $(get_config_db_file_list); do + cfg_file_json=${CONFIG_DB_PATH}${cfg_file} + if [ ! -e $cfg_file_json ]; then + need_reload_config=true + + if [ ${cfg_file_json} = ${CONFIG_DB_JSON} ]; then + generate_config factory ${CONFIG_DB_JSON} + else + # For otn device, usr can plugin any linecard, system will generate linecard configuration + # when user start to provisioning a linecard. Generate an empty configuration file by default. + echo "{}" > ${cfg_file_json} + fi + fi + cfg_file_json_list+=','$cfg_file_json + done + + if [ x"$need_reload_config" == x"true" ]; then + config reload -y -n $(cfg_file_json_list) + fi + + sonic-db-cli CONFIG_DB SET "CONFIG_DB_INITIALIZED" "1" +} + # Restore config-setup post migration hooks from a backup copy copy_post_migration_hooks() { @@ -431,10 +462,10 @@ boot_config() if [[ ($NUM_ASIC -gt 1) ]]; then # For otn platform, do config initialization here if [[ $PALTFROM_ASIC = ot-* ]]; then - echo "init otn configuration" - else - return 0 + do_otn_config_initialization fi + + return 0 fi if [ -e /tmp/pending_config_initialization ] || [ -e ${CONFIG_SETUP_INITIALIZATION_FLAG} ]; then