sonic-buildimage/files/image_config/config-chassisdb/config-chassisdb
BrynXu a2e3d2fcea
[ChassisDB]: bring up ChassisDB service (#5283)
bring up chassisdb service on sonic switch according to the design in
Distributed Forwarding in VoQ Arch HLD

Signed-off-by: Honggang Xu <hxu@arista.com>

**- Why I did it**
To bring up new ChassisDB service in sonic as designed in ['Distributed forwarding in a VOQ architecture HLD' ](90c1289eaf/doc/chassis/architecture.md). 

**- How I did it**
Implement the section 2.3.1 Global DB Organization of the VOQ architecture HLD.

**- How to verify it**
ChassisDB service won't start without chassisdb.conf file on the existing platforms.
ChassisDB service is accessible with global.conf file in the distributed arichitecture.

Signed-off-by: Honggang Xu <hxu@arista.com>
2020-10-14 15:15:24 -07:00

60 lines
2.9 KiB
Bash
Executable File

#!/bin/bash
###########################################################################
# Copyright 2020 Arista. The term "Arista" refers to Arista Inc. #
# and/or its subsidiaries. #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); #
# you may not use this file except in compliance with the License. #
# You may obtain a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.#
# See the License for the specific language governing permissions and #
# limitations under the License. #
# #
###########################################################################
# SONiC chassis_db configuration #
# #
# This script is used to add chassis_db address in local hosts and #
# indicate to start database-chassis service. It should be excuted before #
# database-chassis.service started. #
# #
###########################################################################
config_chassis_db() {
startdb_file="/etc/sonic/chassisdb.conf"
[ ! -e $startdb_file ] || rm $startdb_file
platform=$(sonic-cfggen -H -v DEVICE_METADATA.localhost.platform)
# database-chassis services will start when $chassis_config file exists
chassis_config="/usr/share/sonic/device/$platform/chassisdb.conf"
if [ ! -e $chassis_config ]; then
echo "no chassisdb.conf found, bypass config-chassisdb service"
exit 0
fi
start_chassis_db=0
chassis_db_address=""
source $chassis_config
if [[ "$start_chassis_db" == "1" ]]; then
cp $chassis_config $startdb_file
echo "start chassisdb"
fi
if [[ "$start_chassis_db" == "1" ]] || [[ -n "$chassis_db_address" ]]; then
if [ -z "$chassis_db_address" ]; then
echo "no user configured chassisdb address"
else
grep redis_chassis /etc/hosts
if [ $? -ne 0 ]; then
echo "$chassis_db_address redis_chassis.server" >> /etc/hosts
echo "update chassis db address to $chassis_db_address"
fi
fi
fi
}
config_chassis_db
exit 0