[mux]: Make write_standby available on host

Signed-off-by: Lawrence Lee <lawlee@microsoft.com>

[write_standby]: Cleanup and fix build

Signed-off-by: Lawrence Lee <lawlee@microsoft.com>
This commit is contained in:
Lawrence Lee 2021-05-01 00:49:00 +00:00 committed by Ying Xie
parent 14403c61d2
commit 5232647b33
6 changed files with 11 additions and 4 deletions

View File

@ -29,7 +29,6 @@ COPY ["docker-init.sh", "/usr/bin/"]
COPY ["supervisord.conf", "/etc/supervisor/conf.d/"]
COPY ["files/supervisor-proc-exit-listener", "/usr/bin"]
COPY ["critical_processes", "/etc/supervisor/"]
COPY ["write_standby.py", "/usr/sbin/"]
## Copy all Jinja2 template files into the templates folder
COPY ["*.j2", "/usr/share/sonic/templates/"]

View File

@ -28,7 +28,7 @@ stderr_logfile=syslog
dependent_startup=true
[program:standby_init]
command=/usr/sbin/write_standby.py
command=/opt/write_standby/bin/write_standby.py
priority=2
autostart=false
autorestart=false

View File

@ -428,6 +428,9 @@ start() {
-v /var/run/redis-chassis:/var/run/redis-chassis:ro \
-v /usr/share/sonic/device/$PLATFORM/$HWSKU/$DEV:/usr/share/sonic/hwsku:ro \
{%- endif %}
{%- if docker_container_name == "mux" -%}
-v /opt/write_standby/bin:/opt/write_standby/bin:ro \
{%- endif -%}
$REDIS_MNT \
-v /usr/share/sonic/device/$PLATFORM:/usr/share/sonic/platform:ro \
{%- if sonic_asic_platform != "mellanox" %}

View File

@ -12,6 +12,7 @@ User={{ sonicadmin_user }}
ExecStartPre=/usr/bin/{{docker_container_name}}.sh start
ExecStart=/usr/bin/{{docker_container_name}}.sh wait
ExecStop=/usr/bin/{{docker_container_name}}.sh stop
ExecStopPost=/opt/write_standby/bin/write_standby.py
Restart=always
RestartSec=30

View File

@ -53,6 +53,7 @@ FILESYSTEM_ROOT_USR_SHARE_SONIC_TEMPLATES="$FILESYSTEM_ROOT_USR_SHARE_SONIC/temp
FILESYSTEM_ROOT_USR_SHARE_SONIC_FIRMWARE="$FILESYSTEM_ROOT_USR_SHARE_SONIC/firmware"
FILESYSTEM_ROOT_ETC="$FILESYSTEM_ROOT/etc"
FILESYSTEM_ROOT_ETC_SONIC="$FILESYSTEM_ROOT_ETC/sonic"
FILESYSTEM_ROOT_OPT="$FILESYSTEM_ROOT/opt"
GENERATED_SERVICE_FILE="$FILESYSTEM_ROOT/etc/sonic/generated_services.conf"
@ -813,6 +814,10 @@ sudo LANG=C cp $SCRIPTS_DIR/asic_status.py $FILESYSTEM_ROOT/usr/local/bin/asic_s
# Copy sonic-netns-exec script
sudo LANG=C cp $SCRIPTS_DIR/sonic-netns-exec $FILESYSTEM_ROOT/usr/bin/sonic-netns-exec
# Copy write_standby script for mux state
sudo LANG=C mkdir -p $FILESYSTEM_ROOT_OPT/write_standby/bin/
sudo LANG=C cp $SCRIPTS_DIR/write_standby.py $FILESYSTEM_ROOT_OPT/write_standby/bin/write_standby.py
# Copy systemd timer configuration
# It implements delayed start of services
sudo cp $BUILD_TEMPLATES/snmp.timer $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM

View File

@ -1,10 +1,9 @@
#!/usr/bin/env python3
import logging
import time
from swsscommon.swsscommon import ConfigDBConnector, DBConnector, FieldValuePairs, ProducerStateTable, SonicV2Connector
from swsscommon.swsscommon import APPL_DB, ASIC_DB
from swsscommon.swsscommon import APPL_DB
logger = logging.getLogger(__name__)