mirror of
https://github.com/Telecominfraproject/ols-nos.git
synced 2025-11-03 19:47:56 +00:00
[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>
This commit is contained in:
2
device/arista/x86_64-arista_7800_sup/chassisdb.conf
Normal file
2
device/arista/x86_64-arista_7800_sup/chassisdb.conf
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
start_chassis_db=1
|
||||||
|
chassis_db_address=127.100.1.1
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
chassis_db_address=127.100.1.1
|
||||||
@@ -45,5 +45,6 @@ COPY ["database_global.json.j2", "/usr/share/sonic/templates/"]
|
|||||||
COPY ["files/supervisor-proc-exit-listener", "/usr/bin"]
|
COPY ["files/supervisor-proc-exit-listener", "/usr/bin"]
|
||||||
COPY ["files/sysctl-net.conf", "/etc/sysctl.d/"]
|
COPY ["files/sysctl-net.conf", "/etc/sysctl.d/"]
|
||||||
COPY ["critical_processes", "/etc/supervisor"]
|
COPY ["critical_processes", "/etc/supervisor"]
|
||||||
|
COPY ["files/update_chassisdb_config", "/usr/local/bin/"]
|
||||||
|
|
||||||
ENTRYPOINT ["/usr/local/bin/docker-database-init.sh"]
|
ENTRYPOINT ["/usr/local/bin/docker-database-init.sh"]
|
||||||
|
|||||||
@@ -5,6 +5,12 @@
|
|||||||
"port" : 6379,
|
"port" : 6379,
|
||||||
"unix_socket_path" : "/var/run/redis{{NAMESPACE_ID}}/redis.sock",
|
"unix_socket_path" : "/var/run/redis{{NAMESPACE_ID}}/redis.sock",
|
||||||
"persistence_for_warm_boot" : "yes"
|
"persistence_for_warm_boot" : "yes"
|
||||||
|
},
|
||||||
|
"redis_chassis":{
|
||||||
|
"hostname" : "redis_chassis.server",
|
||||||
|
"port": 6380,
|
||||||
|
"unix_socket_path": "/var/run/redis-chassis/redis_chassis.sock",
|
||||||
|
"persistence_for_warm_boot" : "yes"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"DATABASES" : {
|
"DATABASES" : {
|
||||||
@@ -72,6 +78,11 @@
|
|||||||
"id" : 11,
|
"id" : 11,
|
||||||
"separator": "|",
|
"separator": "|",
|
||||||
"instance" : "redis"
|
"instance" : "redis"
|
||||||
|
},
|
||||||
|
"CHASSIS_APP_DB" : {
|
||||||
|
"id" : 12,
|
||||||
|
"separator": "|",
|
||||||
|
"instance" : "redis_chassis"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"VERSION" : "1.0"
|
"VERSION" : "1.0"
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ fi
|
|||||||
|
|
||||||
REDIS_DIR=/var/run/redis$NAMESPACE_ID
|
REDIS_DIR=/var/run/redis$NAMESPACE_ID
|
||||||
mkdir -p $REDIS_DIR/sonic-db
|
mkdir -p $REDIS_DIR/sonic-db
|
||||||
|
mkdir -p /etc/supervisor/conf.d/
|
||||||
|
|
||||||
if [ -f /etc/sonic/database_config$NAMESPACE_ID.json ]; then
|
if [ -f /etc/sonic/database_config$NAMESPACE_ID.json ]; then
|
||||||
cp /etc/sonic/database_config$NAMESPACE_ID.json $REDIS_DIR/sonic-db/database_config.json
|
cp /etc/sonic/database_config$NAMESPACE_ID.json $REDIS_DIR/sonic-db/database_config.json
|
||||||
@@ -26,7 +27,37 @@ else
|
|||||||
HOST_IP=$host_ip j2 /usr/share/sonic/templates/database_config.json.j2 > $REDIS_DIR/sonic-db/database_config.json
|
HOST_IP=$host_ip j2 /usr/share/sonic/templates/database_config.json.j2 > $REDIS_DIR/sonic-db/database_config.json
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mkdir -p /etc/supervisor/conf.d/
|
# on VoQ system, we only publish redis_chassis instance and CHASSIS_APP_DB when
|
||||||
|
# either chassisdb.conf indicates starts chassis_db or connect to chassis_db,
|
||||||
|
# and redis_chassis instance is started in different container.
|
||||||
|
# in order to do that, first we save original database config file, then
|
||||||
|
# call update_chasissdb_config to remove chassis_db config from
|
||||||
|
# the original database config file and use the modified config file to generate
|
||||||
|
# supervisord config, so that we won't start redis_chassis service.
|
||||||
|
# then we will decide to publish modified or original database config file based
|
||||||
|
# on the setting in chassisdb.conf
|
||||||
|
start_chassis_db=0
|
||||||
|
chassis_db_address=""
|
||||||
|
chassis_db_port=""
|
||||||
|
chassisdb_config="/etc/sonic/chassisdb.conf"
|
||||||
|
[ -f $chassisdb_config ] && source $chassisdb_config
|
||||||
|
|
||||||
|
db_cfg_file="/var/run/redis/sonic-db/database_config.json"
|
||||||
|
db_cfg_file_tmp="/var/run/redis/sonic-db/database_config.json.tmp"
|
||||||
|
cp $db_cfg_file $db_cfg_file_tmp
|
||||||
|
|
||||||
|
if [[ $DATABASE_TYPE == "chassisdb" ]]; then
|
||||||
|
# Docker init for database-chassis
|
||||||
|
echo "Init docker-database-chassis..."
|
||||||
|
update_chassisdb_config -j $db_cfg_file_tmp -k -p $chassis_db_port
|
||||||
|
mkdir -p /var/run/redis/sonic-db
|
||||||
|
cp /etc/default/sonic-db/database_config.json /var/run/redis/sonic-db
|
||||||
|
# generate all redis server supervisord configuration file
|
||||||
|
sonic-cfggen -j $db_cfg_file_tmp -t /usr/share/sonic/templates/supervisord.conf.j2 > /etc/supervisor/conf.d/supervisord.conf
|
||||||
|
rm $db_cfg_file_tmp
|
||||||
|
exec /usr/bin/supervisord
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
# copy/generate the database_global.json file if this is global database service in multi asic platform.
|
# copy/generate the database_global.json file if this is global database service in multi asic platform.
|
||||||
if [[ $NAMESPACE_ID == "" ]] && [[ $NAMESPACE_COUNT -gt 1 ]]
|
if [[ $NAMESPACE_ID == "" ]] && [[ $NAMESPACE_COUNT -gt 1 ]]
|
||||||
@@ -37,8 +68,15 @@ then
|
|||||||
j2 /usr/share/sonic/templates/database_global.json.j2 > $REDIS_DIR/sonic-db/database_global.json
|
j2 /usr/share/sonic/templates/database_global.json.j2 > $REDIS_DIR/sonic-db/database_global.json
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
# delete chassisdb config to generate supervisord config
|
||||||
|
update_chassisdb_config -j $db_cfg_file_tmp -d
|
||||||
|
sonic-cfggen -j $db_cfg_file_tmp -t /usr/share/sonic/templates/supervisord.conf.j2 > /etc/supervisor/conf.d/supervisord.conf
|
||||||
|
|
||||||
# generate all redis server supervisord configuration file
|
if [[ "$start_chassis_db" != "1" ]] && [[ -z "$chassis_db_address" ]]; then
|
||||||
sonic-cfggen -j /var/run/redis/sonic-db/database_config.json -t /usr/share/sonic/templates/supervisord.conf.j2 > /etc/supervisor/conf.d/supervisord.conf
|
cp $db_cfg_file_tmp $db_cfg_file
|
||||||
|
else
|
||||||
|
update_chassisdb_config -j $db_cfg_file -p $chassis_db_port
|
||||||
|
fi
|
||||||
|
rm $db_cfg_file_tmp
|
||||||
|
|
||||||
exec /usr/bin/supervisord
|
exec /usr/bin/supervisord
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ stderr_logfile=syslog
|
|||||||
{% if INSTANCES %}
|
{% if INSTANCES %}
|
||||||
{% for redis_inst, redis_items in INSTANCES.iteritems() %}
|
{% for redis_inst, redis_items in INSTANCES.iteritems() %}
|
||||||
[program: {{ redis_inst }}]
|
[program: {{ redis_inst }}]
|
||||||
{% if redis_items['hostname'] != '127.0.0.1' %}
|
{% if redis_items['hostname'] != '127.0.0.1' and redis_inst != 'redis_chassis' %}
|
||||||
{%- set LOOPBACK_IP = '127.0.0.1' -%}
|
{%- set LOOPBACK_IP = '127.0.0.1' -%}
|
||||||
{%- else -%}
|
{%- else -%}
|
||||||
{%- set LOOPBACK_IP = '' -%}
|
{%- set LOOPBACK_IP = '' -%}
|
||||||
|
|||||||
12
files/build_templates/config-chassisdb.service.j2
Normal file
12
files/build_templates/config-chassisdb.service.j2
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Config chassis_db
|
||||||
|
After=rc-local.service
|
||||||
|
Requires=rc-local.service
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
ExecStart=/usr/bin/config-chassisdb
|
||||||
|
RemainAfterExit=yes
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
@@ -12,7 +12,7 @@ link_namespace() {
|
|||||||
# /var/run/netns so it can be managed with iproute2
|
# /var/run/netns so it can be managed with iproute2
|
||||||
|
|
||||||
mkdir -p /var/run/netns
|
mkdir -p /var/run/netns
|
||||||
PID="$(docker inspect -f {{"'{{.State.Pid}}'"}} "{{docker_container_name}}$DEV")"
|
PID="$(docker inspect -f {{"'{{.State.Pid}}'"}} "${DOCKERNAME}")"
|
||||||
|
|
||||||
PIDS=`ip netns pids "$NET_NS" 2>/dev/null`
|
PIDS=`ip netns pids "$NET_NS" 2>/dev/null`
|
||||||
if [ "$?" -eq "0" ]; then # namespace exists
|
if [ "$?" -eq "0" ]; then # namespace exists
|
||||||
@@ -34,11 +34,11 @@ function updateSyslogConf()
|
|||||||
# Also update the container name
|
# Also update the container name
|
||||||
if [[ ($NUM_ASIC -gt 1) ]]; then
|
if [[ ($NUM_ASIC -gt 1) ]]; then
|
||||||
TARGET_IP=$(docker network inspect bridge --format={{ "'{{(index .IPAM.Config 0).Gateway}}'" }})
|
TARGET_IP=$(docker network inspect bridge --format={{ "'{{(index .IPAM.Config 0).Gateway}}'" }})
|
||||||
CONTAINER_NAME="{{docker_container_name}}$DEV"
|
CONTAINER_NAME="$DOCKERNAME"
|
||||||
TMP_FILE="/tmp/rsyslog.$CONTAINER_NAME.conf"
|
TMP_FILE="/tmp/rsyslog.$CONTAINER_NAME.conf"
|
||||||
|
|
||||||
sonic-cfggen -t /usr/share/sonic/templates/rsyslog-container.conf.j2 -a "{\"target_ip\": \"$TARGET_IP\", \"container_name\": \"$CONTAINER_NAME\" }" > $TMP_FILE
|
sonic-cfggen -t /usr/share/sonic/templates/rsyslog-container.conf.j2 -a "{\"target_ip\": \"$TARGET_IP\", \"container_name\": \"$CONTAINER_NAME\" }" > $TMP_FILE
|
||||||
docker cp $TMP_FILE {{docker_container_name}}$DEV:/etc/rsyslog.conf
|
docker cp $TMP_FILE ${DOCKERNAME}:/etc/rsyslog.conf
|
||||||
rm -rf $TMP_FILE
|
rm -rf $TMP_FILE
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@@ -71,6 +71,7 @@ function preStartAction()
|
|||||||
{
|
{
|
||||||
{%- if docker_container_name == "database" %}
|
{%- if docker_container_name == "database" %}
|
||||||
WARM_DIR=/host/warmboot
|
WARM_DIR=/host/warmboot
|
||||||
|
if [ "$DATABASE_TYPE" != "chassisdb" ]; then
|
||||||
if [[ ("$BOOT_TYPE" == "warm" || "$BOOT_TYPE" == "fastfast") && -f $WARM_DIR/dump.rdb ]]; then
|
if [[ ("$BOOT_TYPE" == "warm" || "$BOOT_TYPE" == "fastfast") && -f $WARM_DIR/dump.rdb ]]; then
|
||||||
# Load redis content from /host/warmboot/dump.rdb
|
# Load redis content from /host/warmboot/dump.rdb
|
||||||
docker cp $WARM_DIR/dump.rdb database$DEV:/var/lib/redis/dump.rdb
|
docker cp $WARM_DIR/dump.rdb database$DEV:/var/lib/redis/dump.rdb
|
||||||
@@ -79,6 +80,7 @@ function preStartAction()
|
|||||||
echo -n > /tmp/dump.rdb
|
echo -n > /tmp/dump.rdb
|
||||||
docker cp /tmp/dump.rdb database$DEV:/var/lib/redis/
|
docker cp /tmp/dump.rdb database$DEV:/var/lib/redis/
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
{%- elif docker_container_name == "snmp" %}
|
{%- elif docker_container_name == "snmp" %}
|
||||||
$SONIC_DB_CLI STATE_DB HSET 'DEVICE_METADATA|localhost' chassis_serial_number $(decode-syseeprom -s)
|
$SONIC_DB_CLI STATE_DB HSET 'DEVICE_METADATA|localhost' chassis_serial_number $(decode-syseeprom -s)
|
||||||
{%- else %}
|
{%- else %}
|
||||||
@@ -99,6 +101,11 @@ function postStartAction()
|
|||||||
link_namespace $DEV
|
link_namespace $DEV
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# chassisdb starts before database starts, bypass the PING check since other
|
||||||
|
# databases are not availbale until database container is ready.
|
||||||
|
# also chassisdb doesn't support warm/fast reboot, its dump.rdb is deleted
|
||||||
|
# at service startup time, nothing need to be done here.
|
||||||
|
if [ "$DATABASE_TYPE" != "chassisdb" ]; then
|
||||||
# Wait until supervisord and redis starts. This change is needed
|
# Wait until supervisord and redis starts. This change is needed
|
||||||
# because now database_config.json is jinja2 templated based
|
# because now database_config.json is jinja2 templated based
|
||||||
# and by the time file gets generated if we do redis ping
|
# and by the time file gets generated if we do redis ping
|
||||||
@@ -108,7 +115,6 @@ function postStartAction()
|
|||||||
until [[ ($(docker exec -i database$DEV pgrep -x -c supervisord) -gt 0) && ($($SONIC_DB_CLI PING | grep -c PONG) -gt 0) ]]; do
|
until [[ ($(docker exec -i database$DEV pgrep -x -c supervisord) -gt 0) && ($($SONIC_DB_CLI PING | grep -c PONG) -gt 0) ]]; do
|
||||||
sleep 1;
|
sleep 1;
|
||||||
done
|
done
|
||||||
|
|
||||||
if [[ ("$BOOT_TYPE" == "warm" || "$BOOT_TYPE" == "fastfast") && -f $WARM_DIR/dump.rdb ]]; then
|
if [[ ("$BOOT_TYPE" == "warm" || "$BOOT_TYPE" == "fastfast") && -f $WARM_DIR/dump.rdb ]]; then
|
||||||
rm -f $WARM_DIR/dump.rdb
|
rm -f $WARM_DIR/dump.rdb
|
||||||
else
|
else
|
||||||
@@ -132,11 +138,14 @@ function postStartAction()
|
|||||||
if [[ -x /usr/local/bin/db_migrator.py ]]; then
|
if [[ -x /usr/local/bin/db_migrator.py ]]; then
|
||||||
# Migrate the DB to the latest schema version if needed
|
# Migrate the DB to the latest schema version if needed
|
||||||
if [ -z "$DEV" ]; then
|
if [ -z "$DEV" ]; then
|
||||||
/usr/local/bin/db_migrator.py -o migrate
|
/usr/bin/db_migrator.py -o migrate
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
# Add redis UDS to the redis group and give read/write access to the group
|
# Add redis UDS to the redis group and give read/write access to the group
|
||||||
REDIS_SOCK="/var/run/redis${DEV}/redis.sock"
|
REDIS_SOCK="/var/run/redis${DEV}/redis.sock"
|
||||||
|
else
|
||||||
|
REDIS_SOCK="/var/run/redis-chassis/redis_chassis.sock"
|
||||||
|
fi
|
||||||
chgrp -f redis $REDIS_SOCK && chmod -f 0760 $REDIS_SOCK
|
chgrp -f redis $REDIS_SOCK && chmod -f 0760 $REDIS_SOCK
|
||||||
{%- elif docker_container_name == "swss" %}
|
{%- elif docker_container_name == "swss" %}
|
||||||
docker exec swss$DEV rm -f /ready # remove cruft
|
docker exec swss$DEV rm -f /ready # remove cruft
|
||||||
@@ -170,6 +179,7 @@ start() {
|
|||||||
# Obtain our platform as we will mount directories with these names in each docker
|
# Obtain our platform as we will mount directories with these names in each docker
|
||||||
PLATFORM=${PLATFORM:-`$SONIC_CFGGEN -H -v DEVICE_METADATA.localhost.platform`}
|
PLATFORM=${PLATFORM:-`$SONIC_CFGGEN -H -v DEVICE_METADATA.localhost.platform`}
|
||||||
|
|
||||||
|
|
||||||
# Parse the device specific asic conf file, if it exists
|
# Parse the device specific asic conf file, if it exists
|
||||||
ASIC_CONF=/usr/share/sonic/device/$PLATFORM/asic.conf
|
ASIC_CONF=/usr/share/sonic/device/$PLATFORM/asic.conf
|
||||||
if [ -f "$ASIC_CONF" ]; then
|
if [ -f "$ASIC_CONF" ]; then
|
||||||
@@ -183,8 +193,7 @@ start() {
|
|||||||
# Obtain our HWSKU as we will mount directories with these names in each docker
|
# Obtain our HWSKU as we will mount directories with these names in each docker
|
||||||
HWSKU=${HWSKU:-`$SONIC_CFGGEN -d -v 'DEVICE_METADATA["localhost"]["hwsku"]'`}
|
HWSKU=${HWSKU:-`$SONIC_CFGGEN -d -v 'DEVICE_METADATA["localhost"]["hwsku"]'`}
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
DOCKERCHECK=`docker inspect --type container ${DOCKERNAME} 2>/dev/null`
|
||||||
DOCKERCHECK=`docker inspect --type container {{docker_container_name}}$DEV 2>/dev/null`
|
|
||||||
if [ "$?" -eq "0" ]; then
|
if [ "$?" -eq "0" ]; then
|
||||||
{%- if docker_container_name == "database" %}
|
{%- if docker_container_name == "database" %}
|
||||||
DOCKERMOUNT=""
|
DOCKERMOUNT=""
|
||||||
@@ -193,23 +202,25 @@ start() {
|
|||||||
{%- endif %}
|
{%- endif %}
|
||||||
if [ x"$DOCKERMOUNT" == x"$HWSKU" ]; then
|
if [ x"$DOCKERMOUNT" == x"$HWSKU" ]; then
|
||||||
{%- if docker_container_name == "database" %}
|
{%- if docker_container_name == "database" %}
|
||||||
echo "Starting existing {{docker_container_name}}$DEV container"
|
echo "Starting existing ${DOCKERNAME} container"
|
||||||
{%- else %}
|
{%- else %}
|
||||||
echo "Starting existing {{docker_container_name}}$DEV container with HWSKU $HWSKU"
|
echo "Starting existing ${DOCKERNAME} container with HWSKU $HWSKU"
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
preStartAction
|
preStartAction
|
||||||
docker start {{docker_container_name}}$DEV
|
docker start ${DOCKERNAME}
|
||||||
postStartAction
|
postStartAction
|
||||||
exit $?
|
exit $?
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# docker created with a different HWSKU, remove and recreate
|
# docker created with a different HWSKU, remove and recreate
|
||||||
echo "Removing obsolete {{docker_container_name}}$DEV container with HWSKU $DOCKERMOUNT"
|
echo "Removing obsolete ${DOCKERNAME} container with HWSKU $DOCKERMOUNT"
|
||||||
docker rm -f {{docker_container_name}}$DEV
|
docker rm -f ${DOCKERNAME}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
{%- if docker_container_name == "database" %}
|
{%- if docker_container_name == "database" %}
|
||||||
echo "Creating new {{docker_container_name}}$DEV container"
|
|
||||||
|
echo "Creating new ${DOCKERNAME} container"
|
||||||
|
if [ "$DATABASE_TYPE" != "chassisdb" ]; then
|
||||||
if [ -z "$DEV" ]; then
|
if [ -z "$DEV" ]; then
|
||||||
# if database_global exists in old_config, use it; otherwise use the default one in new image
|
# if database_global exists in old_config, use it; otherwise use the default one in new image
|
||||||
if [ -f /etc/sonic/old_config/database_global.json ]; then
|
if [ -f /etc/sonic/old_config/database_global.json ]; then
|
||||||
@@ -222,8 +233,9 @@ start() {
|
|||||||
echo "Use database_config.json from old system..."
|
echo "Use database_config.json from old system..."
|
||||||
mv /etc/sonic/old_config/database_config$DEV.json /etc/sonic/
|
mv /etc/sonic/old_config/database_config$DEV.json /etc/sonic/
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
{%- else %}
|
{%- else %}
|
||||||
echo "Creating new {{docker_container_name}}$DEV container with HWSKU $HWSKU"
|
echo "Creating new ${DOCKERNAME} container with HWSKU $HWSKU"
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
|
||||||
# In Multi ASIC platforms the global database config file database_global.json will exist.
|
# In Multi ASIC platforms the global database config file database_global.json will exist.
|
||||||
@@ -238,6 +250,19 @@ start() {
|
|||||||
for elem in data['INCLUDES'] if 'namespace' in elem])); f.close()" $SONIC_DB_GLOBAL_JSON`
|
for elem in data['INCLUDES'] if 'namespace' in elem])); f.close()" $SONIC_DB_GLOBAL_JSON`
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
{%- if docker_container_name == "database" %}
|
||||||
|
start_chassis_db=0
|
||||||
|
chassis_db_address=""
|
||||||
|
chassisdb_config="/etc/sonic/chassisdb.conf"
|
||||||
|
[ -f $chassisdb_config ] && source $chassisdb_config
|
||||||
|
DB_OPT=" -v /var/run/redis-chassis:/var/run/redis-chassis:ro "
|
||||||
|
if [[ "$start_chassis_db" != "1" ]] && [[ -z "$chassis_db_address" ]]; then
|
||||||
|
DB_OPT=""
|
||||||
|
else
|
||||||
|
DB_OPT=$DB_OPT" --add-host=redis_chassis.server:$chassis_db_address "
|
||||||
|
fi
|
||||||
|
{%- endif %}
|
||||||
|
|
||||||
if [ -z "$DEV" ]; then
|
if [ -z "$DEV" ]; then
|
||||||
NET="host"
|
NET="host"
|
||||||
|
|
||||||
@@ -256,6 +281,14 @@ start() {
|
|||||||
REDIS_MNT=$REDIS_MNT" -v $redis_dir:$redis_dir:rw "
|
REDIS_MNT=$REDIS_MNT" -v $redis_dir:$redis_dir:rw "
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
{%- else %}
|
||||||
|
if [ "$DATABASE_TYPE" == "chassisdb" ]; then
|
||||||
|
DB_OPT=${DB_OPT/redis-chassis:ro/redis-chassis:rw}
|
||||||
|
DB_OPT=$DB_OPT" -v /var/run/redis-chassis:/var/run/redis:rw "
|
||||||
|
DB_OPT=$DB_OPT" --env DATABASE_TYPE=$DATABASE_TYPE"
|
||||||
|
else
|
||||||
|
DB_OPT=$DB_OPT" -v /var/run/redis$DEV:/var/run/redis:rw "
|
||||||
|
fi
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
else
|
else
|
||||||
# This part of code is applicable for Multi-ASIC platforms. Here we mount the namespace specific
|
# This part of code is applicable for Multi-ASIC platforms. Here we mount the namespace specific
|
||||||
@@ -269,9 +302,10 @@ start() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
{%- if docker_container_name == "database" %}
|
{%- if docker_container_name == "database" %}
|
||||||
NET="bridge"
|
DB_OPT=$DB_OPT" -v /var/run/redis$DEV:/var/run/redis:rw "
|
||||||
{%- else %}
|
{%- else %}
|
||||||
NET="container:database$DEV"
|
NET="container:database$DEV"
|
||||||
|
DB_OPT=""
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
fi
|
fi
|
||||||
{%- if docker_container_name == "bgp" %}
|
{%- if docker_container_name == "bgp" %}
|
||||||
@@ -319,12 +353,15 @@ start() {
|
|||||||
{%- if docker_container_name == "bgp" %}
|
{%- if docker_container_name == "bgp" %}
|
||||||
-v /etc/sonic/frr/$DEV:/etc/frr:rw \
|
-v /etc/sonic/frr/$DEV:/etc/frr:rw \
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
{%- if docker_container_name == "database" %}
|
||||||
|
$DB_OPT \
|
||||||
|
{%- else %}
|
||||||
-v /var/run/redis$DEV:/var/run/redis:rw \
|
-v /var/run/redis$DEV:/var/run/redis:rw \
|
||||||
$REDIS_MNT \
|
-v /var/run/redis-chassis:/var/run/redis-chassis:ro \
|
||||||
-v /usr/share/sonic/device/$PLATFORM:/usr/share/sonic/platform:ro \
|
|
||||||
{%- if docker_container_name != "database" %}
|
|
||||||
-v /usr/share/sonic/device/$PLATFORM/$HWSKU/$DEV:/usr/share/sonic/hwsku:ro \
|
-v /usr/share/sonic/device/$PLATFORM/$HWSKU/$DEV:/usr/share/sonic/hwsku:ro \
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
$REDIS_MNT \
|
||||||
|
-v /usr/share/sonic/device/$PLATFORM:/usr/share/sonic/platform:ro \
|
||||||
{%- if sonic_asic_platform != "mellanox" %}
|
{%- if sonic_asic_platform != "mellanox" %}
|
||||||
--tmpfs /tmp \
|
--tmpfs /tmp \
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
@@ -332,22 +369,22 @@ start() {
|
|||||||
--env "NAMESPACE_ID"="$DEV" \
|
--env "NAMESPACE_ID"="$DEV" \
|
||||||
--env "NAMESPACE_PREFIX"="$NAMESPACE_PREFIX" \
|
--env "NAMESPACE_PREFIX"="$NAMESPACE_PREFIX" \
|
||||||
--env "NAMESPACE_COUNT"=$NUM_ASIC \
|
--env "NAMESPACE_COUNT"=$NUM_ASIC \
|
||||||
--name={{docker_container_name}}$DEV {{docker_image_name}}:latest || {
|
--name=$DOCKERNAME {{docker_image_name}}:latest || {
|
||||||
echo "Failed to docker run" >&1
|
echo "Failed to docker run" >&1
|
||||||
exit 4
|
exit 4
|
||||||
}
|
}
|
||||||
|
|
||||||
preStartAction
|
preStartAction
|
||||||
docker start {{docker_container_name}}$DEV
|
docker start $DOCKERNAME
|
||||||
postStartAction
|
postStartAction
|
||||||
}
|
}
|
||||||
|
|
||||||
wait() {
|
wait() {
|
||||||
docker wait {{docker_container_name}}$DEV
|
docker wait $DOCKERNAME
|
||||||
}
|
}
|
||||||
|
|
||||||
stop() {
|
stop() {
|
||||||
docker stop {{docker_container_name}}$DEV
|
docker stop $DOCKERNAME
|
||||||
{%- if docker_container_name == "database" %}
|
{%- if docker_container_name == "database" %}
|
||||||
if [ "$DEV" ]; then
|
if [ "$DEV" ]; then
|
||||||
ip netns delete "$NET_NS"
|
ip netns delete "$NET_NS"
|
||||||
@@ -355,9 +392,18 @@ stop() {
|
|||||||
{%- endif %}
|
{%- endif %}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DOCKERNAME={{docker_container_name}}
|
||||||
OP=$1
|
OP=$1
|
||||||
DEV=$2 # namespace/device number to operate on
|
DEV=$2 # namespace/device number to operate on
|
||||||
|
{%- if docker_container_name == "database" %}
|
||||||
|
if [ "$DEV" == "chassisdb" ]; then
|
||||||
|
DATABASE_TYPE="chassisdb"
|
||||||
|
DOCKERNAME=$DOCKERNAME"-chassis"
|
||||||
|
unset DEV
|
||||||
|
fi
|
||||||
|
{%- endif %}
|
||||||
NAMESPACE_PREFIX="asic"
|
NAMESPACE_PREFIX="asic"
|
||||||
|
DOCKERNAME=$DOCKERNAME$DEV
|
||||||
if [ "$DEV" ]; then
|
if [ "$DEV" ]; then
|
||||||
NET_NS="$NAMESPACE_PREFIX$DEV" #name of the network namespace
|
NET_NS="$NAMESPACE_PREFIX$DEV" #name of the network namespace
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ Description=Database container
|
|||||||
Requires=database.service
|
Requires=database.service
|
||||||
After=database.service
|
After=database.service
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
Wants=database-chassis.service
|
||||||
|
After=database-chassis.service
|
||||||
Requires=docker.service
|
Requires=docker.service
|
||||||
After=docker.service
|
After=docker.service
|
||||||
After=rc-local.service
|
After=rc-local.service
|
||||||
|
|||||||
20
files/build_templates/share_image/database.service.j2
Normal file
20
files/build_templates/share_image/database.service.j2
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=database-chassis container
|
||||||
|
Requires=docker.service
|
||||||
|
ConditionPathExists=/etc/sonic/chassisdb.conf
|
||||||
|
After=docker.service
|
||||||
|
After=config-chassisdb.service
|
||||||
|
Requires=config-chassisdb.service
|
||||||
|
StartLimitIntervalSec=1200
|
||||||
|
StartLimitBurst=3
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
User=root
|
||||||
|
ExecStartPre=/usr/bin/{{docker_container_name}}.sh start chassisdb
|
||||||
|
ExecStart=/usr/bin/{{docker_container_name}}.sh wait chassisdb
|
||||||
|
ExecStop=/usr/bin/{{docker_container_name}}.sh stop chassisdb
|
||||||
|
Restart=always
|
||||||
|
RestartSec=30
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
@@ -381,6 +381,12 @@ sudo cp $IMAGE_CONFIGS/config-setup/config-setup $FILESYSTEM_ROOT/usr/bin/config
|
|||||||
echo "config-setup.service" | sudo tee -a $GENERATED_SERVICE_FILE
|
echo "config-setup.service" | sudo tee -a $GENERATED_SERVICE_FILE
|
||||||
sudo LANG=C chroot $FILESYSTEM_ROOT systemctl enable config-setup.service
|
sudo LANG=C chroot $FILESYSTEM_ROOT systemctl enable config-setup.service
|
||||||
|
|
||||||
|
# Copy config-chassisdb script and service file
|
||||||
|
j2 files/build_templates/config-chassisdb.service.j2 | sudo tee $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM/config-chassisdb.service
|
||||||
|
sudo cp $IMAGE_CONFIGS/config-chassisdb/config-chassisdb $FILESYSTEM_ROOT/usr/bin/config-chassisdb
|
||||||
|
echo "config-chassisdb.service" | sudo tee -a $GENERATED_SERVICE_FILE
|
||||||
|
sudo LANG=C chroot $FILESYSTEM_ROOT systemctl enable config-chassisdb.service
|
||||||
|
|
||||||
# Copy SNMP configuration files
|
# Copy SNMP configuration files
|
||||||
sudo cp $IMAGE_CONFIGS/snmp/snmp.yml $FILESYSTEM_ROOT/etc/sonic/
|
sudo cp $IMAGE_CONFIGS/snmp/snmp.yml $FILESYSTEM_ROOT/etc/sonic/
|
||||||
|
|
||||||
|
|||||||
59
files/image_config/config-chassisdb/config-chassisdb
Executable file
59
files/image_config/config-chassisdb/config-chassisdb
Executable file
@@ -0,0 +1,59 @@
|
|||||||
|
#!/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
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
#!/usr/bin/python
|
|
||||||
import json
|
|
||||||
import os
|
|
||||||
import syslog
|
|
||||||
import argparse
|
|
||||||
|
|
||||||
database_config_file = "/var/run/redis/sonic-db/database_config.json"
|
|
||||||
redis_chassis = 'redis_chassis'
|
|
||||||
chassis_db = 'CHASSIS_DB'
|
|
||||||
|
|
||||||
def main():
|
|
||||||
parser=argparse.ArgumentParser(description=
|
|
||||||
"Remove chassis_db config from database-config.json")
|
|
||||||
parser.add_argument("-j", "--json", help="databse-config json file", nargs='?',
|
|
||||||
const=database_config_file)
|
|
||||||
args = parser.parse_args()
|
|
||||||
jsonfile = ""
|
|
||||||
if args.json != None:
|
|
||||||
jsonfile = args.json
|
|
||||||
else:
|
|
||||||
return
|
|
||||||
data = {}
|
|
||||||
if os.path.isfile(jsonfile):
|
|
||||||
with open(jsonfile, "r") as read_file:
|
|
||||||
data = json.load(read_file)
|
|
||||||
else:
|
|
||||||
syslog.syslog(syslog.LOG_ERR,
|
|
||||||
'config file {} does notexist'.format(jsonfile))
|
|
||||||
return
|
|
||||||
if 'INSTANCES' in data and redis_chassis in data['INSTANCES']:
|
|
||||||
del data['INSTANCES'][redis_chassis]
|
|
||||||
if 'DATABASES' in data and chassis_db in data['DATABASES']:
|
|
||||||
del data['DATABASES'][chassis_db]
|
|
||||||
with open(jsonfile, "w") as write_file:
|
|
||||||
json.dump(data, write_file, indent=4, separators=(',', ': '))
|
|
||||||
syslog.syslog(syslog.LOG_INFO,
|
|
||||||
'remove chassis_db from config file {}'.format(jsonfile))
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main()
|
|
||||||
67
files/scripts/update_chassisdb_config
Executable file
67
files/scripts/update_chassisdb_config
Executable file
@@ -0,0 +1,67 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
import syslog
|
||||||
|
import argparse
|
||||||
|
|
||||||
|
database_config_file = "/var/run/redis/sonic-db/database_config.json"
|
||||||
|
redis_chassis = 'redis_chassis'
|
||||||
|
chassis_db = 'CHASSIS_APP_DB'
|
||||||
|
|
||||||
|
def main():
|
||||||
|
parser = argparse.ArgumentParser(description=
|
||||||
|
"Update chassis_db config from database-config.json")
|
||||||
|
parser.add_argument("-j", "--json", help="databse-config json file", nargs='?',
|
||||||
|
const=database_config_file)
|
||||||
|
parser.add_argument("-p", "--port", help="update port number", nargs='?' )
|
||||||
|
group = parser.add_mutually_exclusive_group()
|
||||||
|
group.add_argument("-k", "--keep", help="keep configuration", action='store_true' )
|
||||||
|
group.add_argument("-d", "--delete", help="delete configuration", action='store_true' )
|
||||||
|
|
||||||
|
args = parser.parse_args()
|
||||||
|
jsonfile = ""
|
||||||
|
if args.json != None:
|
||||||
|
jsonfile = args.json
|
||||||
|
else:
|
||||||
|
return
|
||||||
|
if args.port != None:
|
||||||
|
port_number = args.port
|
||||||
|
else:
|
||||||
|
port_number = ""
|
||||||
|
if args.keep:
|
||||||
|
keep_config = True
|
||||||
|
else:
|
||||||
|
keep_config = False
|
||||||
|
if args.delete:
|
||||||
|
delete_config = True
|
||||||
|
else:
|
||||||
|
delete_config = False
|
||||||
|
data = {}
|
||||||
|
data_keep = {}
|
||||||
|
if os.path.isfile(jsonfile):
|
||||||
|
with open(jsonfile, "r") as read_file:
|
||||||
|
data = json.load(read_file)
|
||||||
|
else:
|
||||||
|
syslog.syslog(syslog.LOG_ERR,
|
||||||
|
'config file {} does notexist'.format(jsonfile))
|
||||||
|
return
|
||||||
|
if 'INSTANCES' in data and redis_chassis in data['INSTANCES']:
|
||||||
|
data_keep['INSTANCES'] = {}
|
||||||
|
data_keep['INSTANCES'][redis_chassis] = data['INSTANCES'][redis_chassis]
|
||||||
|
if delete_config:
|
||||||
|
del data['INSTANCES'][redis_chassis]
|
||||||
|
if 'DATABASES' in data and chassis_db in data['DATABASES']:
|
||||||
|
data_keep['DATABASES'] = {}
|
||||||
|
data_keep['DATABASES'][chassis_db] = data['DATABASES'][chassis_db]
|
||||||
|
if delete_config:
|
||||||
|
del data['DATABASES'][chassis_db]
|
||||||
|
with open(jsonfile, "w") as write_file:
|
||||||
|
data_publish = data_keep if keep_config else data
|
||||||
|
if port_number:
|
||||||
|
data_publish['INSTANCES']['redis_chassis']['port'] = int(port_number)
|
||||||
|
json.dump(data_publish, write_file, indent=4, separators=(',', ': '))
|
||||||
|
syslog.syslog(syslog.LOG_INFO,
|
||||||
|
'remove chassis_db from config file {}'.format(jsonfile))
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
@@ -46,7 +46,7 @@ $(DOCKER_SONIC_VS)_FILES += $(CONFIGDB_LOAD_SCRIPT) \
|
|||||||
$(BUFFERS_CONFIG_TEMPLATE) \
|
$(BUFFERS_CONFIG_TEMPLATE) \
|
||||||
$(QOS_CONFIG_TEMPLATE) \
|
$(QOS_CONFIG_TEMPLATE) \
|
||||||
$(SONIC_VERSION) \
|
$(SONIC_VERSION) \
|
||||||
$(RM_CHASSISDB_CONFIG_SCRIPT)
|
$(UPDATE_CHASSISDB_CONFIG_SCRIPT)
|
||||||
|
|
||||||
$(DOCKER_SONIC_VS)_LOAD_DOCKERS += $(DOCKER_CONFIG_ENGINE_BUSTER)
|
$(DOCKER_SONIC_VS)_LOAD_DOCKERS += $(DOCKER_CONFIG_ENGINE_BUSTER)
|
||||||
SONIC_DOCKER_IMAGES += $(DOCKER_SONIC_VS)
|
SONIC_DOCKER_IMAGES += $(DOCKER_SONIC_VS)
|
||||||
|
|||||||
@@ -134,7 +134,7 @@ RUN sed -ri 's/^(save .*$)/# \1/g;
|
|||||||
' /etc/redis/redis.conf
|
' /etc/redis/redis.conf
|
||||||
|
|
||||||
COPY ["50-default.conf", "/etc/rsyslog.d/"]
|
COPY ["50-default.conf", "/etc/rsyslog.d/"]
|
||||||
COPY ["start.sh", "orchagent.sh", "files/remove_chassisdb_config", "/usr/bin/"]
|
COPY ["start.sh", "orchagent.sh", "files/update_chassisdb_config", "/usr/bin/"]
|
||||||
COPY ["supervisord.conf", "/etc/supervisor/conf.d/"]
|
COPY ["supervisord.conf", "/etc/supervisor/conf.d/"]
|
||||||
COPY ["files/configdb-load.sh", "/usr/bin/"]
|
COPY ["files/configdb-load.sh", "/usr/bin/"]
|
||||||
COPY ["files/arp_update", "/usr/bin/"]
|
COPY ["files/arp_update", "/usr/bin/"]
|
||||||
|
|||||||
@@ -3,11 +3,11 @@
|
|||||||
import swsssdk
|
import swsssdk
|
||||||
import json
|
import json
|
||||||
chassisdb = swsssdk.SonicV2Connector(host='10.0.0.200', port='6380')
|
chassisdb = swsssdk.SonicV2Connector(host='10.0.0.200', port='6380')
|
||||||
chassisdb.connect(chassisdb.CHASSIS_DB)
|
chassisdb.connect(chassisdb.CHASSIS_APP_DB)
|
||||||
fname='/usr/share/sonic/virtual_chassis/chassis_db.json'
|
fname='/usr/share/sonic/virtual_chassis/chassis_db.json'
|
||||||
with open(fname) as f:
|
with open(fname) as f:
|
||||||
js = json.load(f)
|
js = json.load(f)
|
||||||
client=chassisdb.get_redis_client(chassisdb.CHASSIS_DB)
|
client=chassisdb.get_redis_client(chassisdb.CHASSIS_APP_DB)
|
||||||
for h, table in js.items():
|
for h, table in js.items():
|
||||||
for k, v in table.items():
|
for k, v in table.items():
|
||||||
client.hset(h, k, v)
|
client.hset(h, k, v)
|
||||||
|
|||||||
@@ -73,7 +73,7 @@
|
|||||||
"separator": "|",
|
"separator": "|",
|
||||||
"instance" : "redis"
|
"instance" : "redis"
|
||||||
},
|
},
|
||||||
"CHASSIS_DB" : {
|
"CHASSIS_APP_DB" : {
|
||||||
"id" : 11,
|
"id" : 11,
|
||||||
"separator": "|",
|
"separator": "|",
|
||||||
"instance" : "redis_chassis"
|
"instance" : "redis_chassis"
|
||||||
|
|||||||
@@ -54,16 +54,16 @@ rm -f /var/run/rsyslogd.pid
|
|||||||
supervisorctl start rsyslogd
|
supervisorctl start rsyslogd
|
||||||
|
|
||||||
supervisord_cfg="/etc/supervisor/conf.d/supervisord.conf"
|
supervisord_cfg="/etc/supervisor/conf.d/supervisord.conf"
|
||||||
chassis_cfg_file="/usr/share/sonic/virtual_chassis/default_config.json"
|
chassisdb_cfg_file="/usr/share/sonic/virtual_chassis/default_config.json"
|
||||||
chassis_cfg_file_default="/etc/default/sonic-db/default_chassis_cfg.json"
|
chassisdb_cfg_file_default="/etc/default/sonic-db/default_chassis_cfg.json"
|
||||||
host_template="/usr/share/sonic/templates/hostname.j2"
|
host_template="/usr/share/sonic/templates/hostname.j2"
|
||||||
db_cfg_file="/var/run/redis/sonic-db/database_config.json"
|
db_cfg_file="/var/run/redis/sonic-db/database_config.json"
|
||||||
db_cfg_file_tmp="/var/run/redis/sonic-db/database_config.json.tmp"
|
db_cfg_file_tmp="/var/run/redis/sonic-db/database_config.json.tmp"
|
||||||
|
|
||||||
if [ -r "$chassis_cfg_file" ]; then
|
if [ -r "$chassisdb_cfg_file" ]; then
|
||||||
echo $(sonic-cfggen -j $chassis_cfg_file -t $host_template) >> /etc/hosts
|
echo $(sonic-cfggen -j $chassisdb_cfg_file -t $host_template) >> /etc/hosts
|
||||||
else
|
else
|
||||||
chassis_cfg_file="$chassis_cfg_file_default"
|
chassisdb_cfg_file="$chassisdb_cfg_file_default"
|
||||||
echo "10.8.1.200 redis_chassis.server" >> /etc/hosts
|
echo "10.8.1.200 redis_chassis.server" >> /etc/hosts
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -72,16 +72,16 @@ cp /etc/default/sonic-db/database_config.json /var/run/redis/sonic-db/
|
|||||||
|
|
||||||
supervisorctl start redis-server
|
supervisorctl start redis-server
|
||||||
|
|
||||||
start_chassis_db=`sonic-cfggen -v DEVICE_METADATA.localhost.start_chassis_db -y $chassis_cfg_file`
|
start_chassis_db=`sonic-cfggen -v DEVICE_METADATA.localhost.start_chassis_db -y $chassisdb_cfg_file`
|
||||||
if [[ "$HOSTNAME" == *"supervisor"* ]] || [ "$start_chassis_db" == "1" ]; then
|
if [[ "$HOSTNAME" == *"supervisor"* ]] || [ "$start_chassis_db" == "1" ]; then
|
||||||
supervisorctl start redis-chassis
|
supervisorctl start redis-chassis
|
||||||
python /usr/bin/chassis_db.py
|
python /usr/bin/chassis_db.py
|
||||||
fi
|
fi
|
||||||
|
|
||||||
conn_chassis_db=`sonic-cfggen -v DEVICE_METADATA.localhost.connect_to_chassis_db -y $chassis_cfg_file`
|
conn_chassis_db=`sonic-cfggen -v DEVICE_METADATA.localhost.connect_to_chassis_db -y $chassisdb_cfg_file`
|
||||||
if [ "$start_chassis_db" != "1" ] && [ "$conn_chassis_db" != "1" ]; then
|
if [ "$start_chassis_db" != "1" ] && [ "$conn_chassis_db" != "1" ]; then
|
||||||
cp $db_cfg_file $db_cfg_file_tmp
|
cp $db_cfg_file $db_cfg_file_tmp
|
||||||
remove_chassisdb_config -j $db_cfg_file_tmp
|
update_chassisdb_config -j $db_cfg_file_tmp -d
|
||||||
cp $db_cfg_file_tmp $db_cfg_file
|
cp $db_cfg_file_tmp $db_cfg_file
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@@ -25,3 +25,4 @@ $(DOCKER_DATABASE)_RUN_OPT += -v /etc/sonic:/etc/sonic:ro
|
|||||||
$(DOCKER_DATABASE)_BASE_IMAGE_FILES += redis-cli:/usr/bin/redis-cli
|
$(DOCKER_DATABASE)_BASE_IMAGE_FILES += redis-cli:/usr/bin/redis-cli
|
||||||
$(DOCKER_DATABASE)_BASE_IMAGE_FILES += monit_database:/etc/monit/conf.d
|
$(DOCKER_DATABASE)_BASE_IMAGE_FILES += monit_database:/etc/monit/conf.d
|
||||||
$(DOCKER_DATABASE)_FILES += $(SYSCTL_NET_CONFIG) $(SUPERVISOR_PROC_EXIT_LISTENER_SCRIPT)
|
$(DOCKER_DATABASE)_FILES += $(SYSCTL_NET_CONFIG) $(SUPERVISOR_PROC_EXIT_LISTENER_SCRIPT)
|
||||||
|
$(DOCKER_DATABASE)_FILES += $(UPDATE_CHASSISDB_CONFIG_SCRIPT)
|
||||||
|
|||||||
@@ -20,8 +20,8 @@ $(SUPERVISOR_PROC_EXIT_LISTENER_SCRIPT)_PATH = files/scripts
|
|||||||
SYSCTL_NET_CONFIG = sysctl-net.conf
|
SYSCTL_NET_CONFIG = sysctl-net.conf
|
||||||
$(SYSCTL_NET_CONFIG)_PATH = files/image_config/sysctl
|
$(SYSCTL_NET_CONFIG)_PATH = files/image_config/sysctl
|
||||||
|
|
||||||
RM_CHASSISDB_CONFIG_SCRIPT = remove_chassisdb_config
|
UPDATE_CHASSISDB_CONFIG_SCRIPT = update_chassisdb_config
|
||||||
$(RM_CHASSISDB_CONFIG_SCRIPT)_PATH = files/scripts
|
$(UPDATE_CHASSISDB_CONFIG_SCRIPT)_PATH = files/scripts
|
||||||
|
|
||||||
SONIC_COPY_FILES += $(CONFIGDB_LOAD_SCRIPT) \
|
SONIC_COPY_FILES += $(CONFIGDB_LOAD_SCRIPT) \
|
||||||
$(ARP_UPDATE_SCRIPT) \
|
$(ARP_UPDATE_SCRIPT) \
|
||||||
@@ -30,4 +30,4 @@ SONIC_COPY_FILES += $(CONFIGDB_LOAD_SCRIPT) \
|
|||||||
$(QOS_CONFIG_TEMPLATE) \
|
$(QOS_CONFIG_TEMPLATE) \
|
||||||
$(SUPERVISOR_PROC_EXIT_LISTENER_SCRIPT) \
|
$(SUPERVISOR_PROC_EXIT_LISTENER_SCRIPT) \
|
||||||
$(SYSCTL_NET_CONFIG) \
|
$(SYSCTL_NET_CONFIG) \
|
||||||
$(RM_CHASSISDB_CONFIG_SCRIPT)
|
$(UPDATE_CHASSISDB_CONFIG_SCRIPT)
|
||||||
|
|||||||
12
slave.mk
12
slave.mk
@@ -892,6 +892,15 @@ $(addprefix $(TARGET_PATH)/, $(SONIC_INSTALLERS)) : $(TARGET_PATH)/% : \
|
|||||||
export multi_instance="false"
|
export multi_instance="false"
|
||||||
j2 files/build_templates/per_namespace/$($(docker:-dbg.gz=.gz)_CONTAINER_NAME).service.j2 > $($(docker:-dbg.gz=.gz)_CONTAINER_NAME).service
|
j2 files/build_templates/per_namespace/$($(docker:-dbg.gz=.gz)_CONTAINER_NAME).service.j2 > $($(docker:-dbg.gz=.gz)_CONTAINER_NAME).service
|
||||||
fi
|
fi
|
||||||
|
# Any service template, inside share_image directory, will be used to generate -chassis.service file.
|
||||||
|
# TODO: need better way to name the image-shared service
|
||||||
|
if [ -f files/build_templates/share_image/$($(docker:-dbg.gz=.gz)_CONTAINER_NAME).service.j2 ]; then
|
||||||
|
j2 files/build_templates/share_image/$($(docker:-dbg.gz=.gz)_CONTAINER_NAME).service.j2 > $($(docker:-dbg.gz=.gz)_CONTAINER_NAME)-chassis.service
|
||||||
|
$(if $(shell ls files/build_templates/share_image/$($(docker:-dbg.gz=.gz)_CONTAINER_NAME).service.j2 2>/dev/null),\
|
||||||
|
$(eval $(docker:-dbg.gz=.gz)_SHARE = yes)
|
||||||
|
)
|
||||||
|
fi
|
||||||
|
|
||||||
j2 files/build_templates/docker_image_ctl.j2 > $($(docker:-dbg.gz=.gz)_CONTAINER_NAME).sh
|
j2 files/build_templates/docker_image_ctl.j2 > $($(docker:-dbg.gz=.gz)_CONTAINER_NAME).sh
|
||||||
chmod +x $($(docker:-dbg.gz=.gz)_CONTAINER_NAME).sh
|
chmod +x $($(docker:-dbg.gz=.gz)_CONTAINER_NAME).sh
|
||||||
)
|
)
|
||||||
@@ -910,6 +919,9 @@ $(addprefix $(TARGET_PATH)/, $(SONIC_INSTALLERS)) : $(TARGET_PATH)/% : \
|
|||||||
$(eval SERVICES += "$(addsuffix @.service, $($(docker:-dbg.gz=.gz)_CONTAINER_NAME))"),\
|
$(eval SERVICES += "$(addsuffix @.service, $($(docker:-dbg.gz=.gz)_CONTAINER_NAME))"),\
|
||||||
$(eval SERVICES += "$(addsuffix .service, $($(docker:-dbg.gz=.gz)_CONTAINER_NAME))")
|
$(eval SERVICES += "$(addsuffix .service, $($(docker:-dbg.gz=.gz)_CONTAINER_NAME))")
|
||||||
)
|
)
|
||||||
|
$(if $($(docker:-dbg.gz=.gz)_SHARE),\
|
||||||
|
$(eval SERVICES += "$(addsuffix -chassis.service, $($(docker:-dbg.gz=.gz)_CONTAINER_NAME))")
|
||||||
|
)
|
||||||
)
|
)
|
||||||
export installer_services="$(SERVICES)"
|
export installer_services="$(SERVICES)"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user