From 3da6f12b0bbc1fd2ae3860a848c4c164e4b949bb Mon Sep 17 00:00:00 2001 From: Blueve <672454911@qq.com> Date: Thu, 15 Jul 2021 08:56:35 +0800 Subject: [PATCH] [port_config] Introduce ad-hoc mport_config.json file (#8066) Signed-off-by: Jing Kan jika@microsoft.com --- files/Aboot/boot0.j2 | 3 ++- files/image_config/config-setup/config-setup | 2 +- files/image_config/platform/rc.local | 6 ++++++ files/image_config/secureboot/allowlist_paths.conf | 1 + 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/files/Aboot/boot0.j2 b/files/Aboot/boot0.j2 index 408b05b5dd..bb8bd65875 100644 --- a/files/Aboot/boot0.j2 +++ b/files/Aboot/boot0.j2 @@ -117,7 +117,8 @@ clean_flash() { [ $f != "old_config" ] && [ $f != "minigraph.xml" ] && [ $f != "snmp.yml" ] && - [ $f != "acl.json" ] + [ $f != "acl.json" ] && + [ $f != "port_config.json" ] then rm -rf "$target_path/$f" fi diff --git a/files/image_config/config-setup/config-setup b/files/image_config/config-setup/config-setup index aacbdff000..b151437b9e 100755 --- a/files/image_config/config-setup/config-setup +++ b/files/image_config/config-setup/config-setup @@ -305,7 +305,7 @@ check_all_config_db_present() do_config_migration() { # Identify list of files to migrate - copy_list="minigraph.xml snmp.yml acl.json frr telemetry" + copy_list="minigraph.xml snmp.yml acl.json port_config.json frr telemetry" # Migrate all configuration files from old to new copy_config_files_and_directories $copy_list diff --git a/files/image_config/platform/rc.local b/files/image_config/platform/rc.local index b299f9fe2b..b63caef0f4 100755 --- a/files/image_config/platform/rc.local +++ b/files/image_config/platform/rc.local @@ -120,6 +120,8 @@ migrate_nos_configuration() MG_FILE=$NOS_DIR/minigraph.xml ACL_GZFILE=$NOS_DIR/acl.json.gz.base64.txt ACL_FILE=$NOS_DIR/acl.json + PORT_CONFIG_GZFILE=$NOS_DIR/port_config.json.gz.base64.txt + PORT_CONFIG_FILE=$NOS_DIR/port_config.json SNMP_FILE=$NOS_DIR/snmp.yml mkdir -p $NOS_DIR @@ -131,11 +133,13 @@ migrate_nos_configuration() # decode & unzip minigraph.xml.gz.base64.txt [ -f $MG_GZFILE ] && /usr/bin/base64 -d $MG_GZFILE | /bin/gunzip > $MG_FILE [ -f $ACL_GZFILE ] && /usr/bin/base64 -d $ACL_GZFILE | /bin/gunzip > $ACL_FILE + [ -f $PORT_CONFIG_GZFILE ] && /usr/bin/base64 -d $PORT_CONFIG_GZFILE | /bin/gunzip > $PORT_CONFIG_FILE # Copy relevant files nos_migration_import $NOS_DIR/mgmt_interface.cfg /host/migration nos_migration_import $MG_FILE /host/migration nos_migration_import $ACL_FILE /host/migration + nos_migration_import $PORT_CONFIG_FILE /host/migration nos_migration_import $SNMP_FILE /host/migration if [ "$sonic_fast_reboot" == true ]; then @@ -243,12 +247,14 @@ if [ -f $FIRST_BOOT_FILE ]; then mkdir -p /etc/sonic/old_config mv /host/minigraph.xml /etc/sonic/old_config/ [ -f /host/acl.json ] && mv /host/acl.json /etc/sonic/old_config/ + [ -f /host/port_config.json ] && mv /host/port_config.json /etc/sonic/old_config/ [ -f /host/snmp.yml ] && mv /host/snmp.yml /etc/sonic/old_config/ touch /tmp/pending_config_migration elif [ -n "$migration" ] && [ -f /host/migration/minigraph.xml ]; then mkdir -p /etc/sonic/old_config mv /host/migration/minigraph.xml /etc/sonic/old_config/ [ -f /host/migration/acl.json ] && mv /host/migration/acl.json /etc/sonic/old_config/ + [ -f /host/migration/port_config.json ] && mv /host/migration/port_config.json /etc/sonic/old_config/ [ -f /host/migration/snmp.yml ] && mv /host/migration/snmp.yml /etc/sonic/old_config/ touch /tmp/pending_config_migration [ -f /etc/sonic/updategraph.conf ] && sed -i -e "s/enabled=false/enabled=true/g" /etc/sonic/updategraph.conf diff --git a/files/image_config/secureboot/allowlist_paths.conf b/files/image_config/secureboot/allowlist_paths.conf index f1021f5c13..80b176178c 100644 --- a/files/image_config/secureboot/allowlist_paths.conf +++ b/files/image_config/secureboot/allowlist_paths.conf @@ -25,6 +25,7 @@ etc/sonic/acl.json etc/sonic/config_db.json etc/sonic/minigraph.xml etc/sonic/old_config/.* +etc/sonic/port_config.json etc/sonic/snmp.yml etc/sonic/sonic-environment etc/sonic/updategraph.conf