[config-chassisdb] use cached variables (#17342)

- Why I did it
Improve boot performance mostly needed for fast and warmboot

- How I did it
Use cached variable.

- How to verify it
Boot the system. Simply do "systemd-analyze blame" and look at service start time.

Signed-off-by: Stepan Blyschak <stepanb@nvidia.com>
This commit is contained in:
Stepan Blyshchak 2023-12-07 15:24:21 +02:00 committed by mssonicbld
parent bc4bc03239
commit 2cea4bcbdf

View File

@ -27,7 +27,7 @@
config_chassis_db() { config_chassis_db() {
startdb_file="/etc/sonic/chassisdb.conf" startdb_file="/etc/sonic/chassisdb.conf"
[ ! -e $startdb_file ] || rm $startdb_file [ ! -e $startdb_file ] || rm $startdb_file
platform=$(sonic-cfggen -H -v DEVICE_METADATA.localhost.platform) platform=${PLATFORM:-`sonic-cfggen -H -v DEVICE_METADATA.localhost.platform`}
# database-chassis services will start when $chassis_config file exists # database-chassis services will start when $chassis_config file exists
chassis_config="/usr/share/sonic/device/$platform/chassisdb.conf" chassis_config="/usr/share/sonic/device/$platform/chassisdb.conf"
if [ ! -e $chassis_config ]; then if [ ! -e $chassis_config ]; then
@ -54,6 +54,9 @@ config_chassis_db() {
fi fi
} }
# read SONiC immutable variables
[ -f /etc/sonic/sonic-environment ] && . /etc/sonic/sonic-environment
config_chassis_db config_chassis_db
exit 0 exit 0