From e1cc3675bcf9e04d12ac50f192128e931db8ae54 Mon Sep 17 00:00:00 2001 From: Sreemoolanathan Iyer Date: Thu, 18 Jun 2026 06:09:33 +0000 Subject: [PATCH] docker-sonic-alpinevs base code Includes the makefile and docker-sonic-alpinevs directory Signed-off-by: Sreemoolanathan Iyer --- docker-sonic-alpinevs.dep | 9 + docker-sonic-alpinevs.mk | 68 ++ docker-sonic-alpinevs/50-default.conf | 68 ++ docker-sonic-alpinevs/Dockerfile.j2 | 172 +++++ docker-sonic-alpinevs/alpinevs-healthcheck.sh | 300 ++++++++ docker-sonic-alpinevs/alpinevs-script.sh | 10 + docker-sonic-alpinevs/asic_table.json | 11 + docker-sonic-alpinevs/buffermgrd.sh | 16 + docker-sonic-alpinevs/config_db.json | 692 ++++++++++++++++++ docker-sonic-alpinevs/copp_cfg_alpinevs.j2 | 329 +++++++++ docker-sonic-alpinevs/database_config.json | 103 +++ .../default_chassis_cfg.json | 7 + .../x86_64-kvm_x86_64-r0/alpinevs/hwsku.json | 100 +++ .../x86_64-kvm_x86_64-r0/alpinevs/sai.profile | 1 + .../device/x86_64-kvm_x86_64-r0/platform.json | 164 +++++ docker-sonic-alpinevs/docker | 2 + docker-sonic-alpinevs/etc/rsyslog.conf | 76 ++ docker-sonic-alpinevs/hostname.j2 | 3 + docker-sonic-alpinevs/init_cfg.json.j2 | 53 ++ docker-sonic-alpinevs/orchagent.sh | 37 + docker-sonic-alpinevs/p4rt.sh | 99 +++ docker-sonic-alpinevs/p4rt_vars.j2 | 5 + .../port_breakout_config_db.json | 61 ++ docker-sonic-alpinevs/sai.profile | 1 + docker-sonic-alpinevs/sshd.conf | 7 + docker-sonic-alpinevs/start.sh | 98 +++ docker-sonic-alpinevs/supervisord.conf.j2 | 302 ++++++++ docker-sonic-alpinevs/telemetry.sh | 133 ++++ docker-sonic-alpinevs/telemetry_vars.j2 | 5 + docker-sonic-alpinevs/uptime | 68 ++ docker-sonic-alpinevs/zero_profiles.json | 57 ++ rules.dep | 1 + rules.mk | 3 +- 33 files changed, 3060 insertions(+), 1 deletion(-) create mode 100644 docker-sonic-alpinevs.dep create mode 100644 docker-sonic-alpinevs.mk create mode 100644 docker-sonic-alpinevs/50-default.conf create mode 100644 docker-sonic-alpinevs/Dockerfile.j2 create mode 100755 docker-sonic-alpinevs/alpinevs-healthcheck.sh create mode 100755 docker-sonic-alpinevs/alpinevs-script.sh create mode 100644 docker-sonic-alpinevs/asic_table.json create mode 100755 docker-sonic-alpinevs/buffermgrd.sh create mode 100644 docker-sonic-alpinevs/config_db.json create mode 100644 docker-sonic-alpinevs/copp_cfg_alpinevs.j2 create mode 100644 docker-sonic-alpinevs/database_config.json create mode 100644 docker-sonic-alpinevs/default_chassis_cfg.json create mode 100644 docker-sonic-alpinevs/device/x86_64-kvm_x86_64-r0/alpinevs/hwsku.json create mode 100644 docker-sonic-alpinevs/device/x86_64-kvm_x86_64-r0/alpinevs/sai.profile create mode 100644 docker-sonic-alpinevs/device/x86_64-kvm_x86_64-r0/platform.json create mode 100755 docker-sonic-alpinevs/docker create mode 100644 docker-sonic-alpinevs/etc/rsyslog.conf create mode 100644 docker-sonic-alpinevs/hostname.j2 create mode 100644 docker-sonic-alpinevs/init_cfg.json.j2 create mode 100755 docker-sonic-alpinevs/orchagent.sh create mode 100755 docker-sonic-alpinevs/p4rt.sh create mode 100644 docker-sonic-alpinevs/p4rt_vars.j2 create mode 100644 docker-sonic-alpinevs/port_breakout_config_db.json create mode 100644 docker-sonic-alpinevs/sai.profile create mode 100644 docker-sonic-alpinevs/sshd.conf create mode 100755 docker-sonic-alpinevs/start.sh create mode 100644 docker-sonic-alpinevs/supervisord.conf.j2 create mode 100755 docker-sonic-alpinevs/telemetry.sh create mode 100644 docker-sonic-alpinevs/telemetry_vars.j2 create mode 100755 docker-sonic-alpinevs/uptime create mode 100644 docker-sonic-alpinevs/zero_profiles.json diff --git a/docker-sonic-alpinevs.dep b/docker-sonic-alpinevs.dep new file mode 100644 index 0000000..824a949 --- /dev/null +++ b/docker-sonic-alpinevs.dep @@ -0,0 +1,9 @@ +#DPKG FRK +DPATH := $($(DOCKER_SONIC_ALPINEVS)_PATH) +DEP_FILES := $(SONIC_COMMON_FILES_LIST) platform/alpinevs/docker-sonic-alpinevs.mk platform/alpinevs/docker-sonic-alpinevs.dep +DEP_FILES += $(SONIC_COMMON_BASE_FILES_LIST) +DEP_FILES += $(shell git ls-files $(DPATH)) + +$(DOCKER_SONIC_ALPINEVS)_CACHE_MODE := GIT_CONTENT_SHA +$(DOCKER_SONIC_ALPINEVS)_DEP_FLAGS := $(SONIC_COMMON_FLAGS_LIST) +$(DOCKER_SONIC_ALPINEVS)_DEP_FILES := $(DEP_FILES) diff --git a/docker-sonic-alpinevs.mk b/docker-sonic-alpinevs.mk new file mode 100644 index 0000000..d0485e1 --- /dev/null +++ b/docker-sonic-alpinevs.mk @@ -0,0 +1,68 @@ +# docker image for alpine virtual switch based sonic docker image + +DOCKER_SONIC_ALPINEVS = docker-sonic-alpinevs.gz +$(DOCKER_SONIC_ALPINEVS)_PATH = $(PLATFORM_PATH)/docker-sonic-alpinevs +$(DOCKER_SONIC_ALPINEVS)_DEPENDS += $(SYNCD_VS) \ + $(LEMMINGSAI) \ + $(PKT_HANDLER) \ + $(PYTHON3_SWSSCOMMON) \ + $(SONIC_DEVICE_DATA) \ + $(LIBYANG) \ + $(LIBYANG3) \ + $(LIBYANG_CPP) \ + $(LIBYANG_PY3) \ + $(SONIC_UTILITIES_DATA) \ + $(SONIC_HOST_SERVICES_DATA) \ + $(SYSMGR) \ + $(SONIC_P4RT) \ + $(SONIC_TELEMETRY) \ + $(SONIC_MGMT_FRAMEWORK) \ + $(SONIC_MGMT_COMMON) + +$(DOCKER_SONIC_ALPINEVS)_PYTHON_WHEELS += $(SONIC_PY_COMMON_PY3) \ + $(SONIC_PLATFORM_COMMON_PY3) \ + $(SONIC_YANG_MODELS_PY3) \ + $(SONIC_YANG_MGMT_PY3) \ + $(SONIC_UTILITIES_PY3) \ + $(SONIC_HOST_SERVICES_PY3) + +ifeq ($(INSTALL_DEBUG_TOOLS), y) +$(DOCKER_SONIC_ALPINEVS)_DEPENDS += $(LIBSWSSCOMMON_DBG) \ + $(LIBSAIREDIS_DBG) \ + $(SYNCD_VS_DBG) +endif + +$(DOCKER_SONIC_ALPINEVS)_FILES += $(CONFIGDB_LOAD_SCRIPT) \ + $(ARP_UPDATE_SCRIPT) \ + $(ARP_UPDATE_VARS_TEMPLATE) \ + $(BUFFERS_CONFIG_TEMPLATE) \ + $(QOS_CONFIG_TEMPLATE) \ + $(SONIC_VERSION) \ + $(UPDATE_CHASSISDB_CONFIG_SCRIPT) \ + $(COPP_CONFIG_TEMPLATE) + +$(DOCKER_SONIC_ALPINEVS)_LOAD_DOCKERS += $(DOCKER_SWSS_LAYER_TRIXIE) +SONIC_DOCKER_IMAGES += $(DOCKER_SONIC_ALPINEVS) +SONIC_TRIXIE_DOCKERS += $(DOCKER_SONIC_ALPINEVS) + +ALPINEVS_DOCKER_STAGING_DIR := $(PLATFORM_PATH)/docker-sonic-alpinevs/bin +ALPINEVS_DOCKER_STAGE_FILES := \ + $(ALPINEVS_DOCKER_STAGING_DIR)/pkt-handler \ + $(ALPINEVS_DOCKER_STAGING_DIR)/alpinevs-config.sh \ + $(ALPINEVS_DOCKER_STAGING_DIR)/alpinevs-init.sh + +$(ALPINEVS_DOCKER_STAGING_DIR): + mkdir -p $@ + +$(ALPINEVS_DOCKER_STAGING_DIR)/pkt-handler: | $(ALPINEVS_DOCKER_STAGING_DIR) + $(MAKE) -C $(PLATFORM_PATH)/src/services/pkt-handler all + cp $(PLATFORM_PATH)/src/services/pkt-handler/pkt-handler $@ + +$(ALPINEVS_DOCKER_STAGING_DIR)/alpinevs-config.sh: | $(ALPINEVS_DOCKER_STAGING_DIR) + cp -L $(PLATFORM_PATH)/src/services/config/alpinevs-config.sh $@ + +$(ALPINEVS_DOCKER_STAGING_DIR)/alpinevs-init.sh: | $(ALPINEVS_DOCKER_STAGING_DIR) + cp -L $(PLATFORM_PATH)/src/services/init/alpinevs-init.sh $@ + +$(addprefix $(TARGET_PATH)/,$(DOCKER_SONIC_ALPINEVS)): $(ALPINEVS_DOCKER_STAGE_FILES) + diff --git a/docker-sonic-alpinevs/50-default.conf b/docker-sonic-alpinevs/50-default.conf new file mode 100644 index 0000000..53a54ca --- /dev/null +++ b/docker-sonic-alpinevs/50-default.conf @@ -0,0 +1,68 @@ +# Default rules for rsyslog. +# +# For more information see rsyslog.conf(5) and /etc/rsyslog.conf + +# +# First some standard log files. Log by facility. +# +auth,authpriv.* /var/log/auth.log +*.*;auth,authpriv.none -/var/log/syslog +#cron.* /var/log/cron.log +#daemon.* -/var/log/daemon.log +kern.* -/var/log/kern.log +#lpr.* -/var/log/lpr.log +mail.* -/var/log/mail.log +#user.* -/var/log/user.log + +# +# Logging for the mail system. Split it up so that +# it is easy to write scripts to parse these files. +# +#mail.info -/var/log/mail.info +#mail.warn -/var/log/mail.warn +mail.err /var/log/mail.err + +# +# Logging for INN news system. +# +news.crit /var/log/news/news.crit +news.err /var/log/news/news.err +news.notice -/var/log/news/news.notice + +# +# Some "catch-all" log files. +# +#*.=debug;\ +# auth,authpriv.none;\ +# news.none;mail.none -/var/log/debug +#*.=info;*.=notice;*.=warn;\ +# auth,authpriv.none;\ +# cron,daemon.none;\ +# mail,news.none -/var/log/messages + +# +# Emergencies are sent to everybody logged in. +# +*.emerg :omusrmsg:* + +# +# I like to have messages displayed on the console, but only on a virtual +# console I usually leave idle. +# +#daemon,mail.*;\ +# news.=crit;news.=err;news.=notice;\ +# *.=debug;*.=info;\ +# *.=notice;*.=warn /dev/tty8 + +# The named pipe /dev/xconsole is for the `xconsole' utility. To use it, +# you must invoke `xconsole' with the `-file' option: +# +# $ xconsole -file /dev/xconsole [...] +# +# NOTE: adjust the list below, or you'll go crazy if you have a reasonably +# busy site.. +# +daemon.*;mail.*;\ + news.err;\ + *.=debug;*.=info;\ + *.=notice;*.=warn |/dev/xconsole diff --git a/docker-sonic-alpinevs/Dockerfile.j2 b/docker-sonic-alpinevs/Dockerfile.j2 new file mode 100644 index 0000000..a4d2726 --- /dev/null +++ b/docker-sonic-alpinevs/Dockerfile.j2 @@ -0,0 +1,172 @@ +{% from "dockers/dockerfile-macros.j2" import install_debian_packages, install_python_wheels, copy_files, rsync_from_builder_stage %} +ARG BASE=docker-swss-layer-trixie-{{DOCKER_USERNAME}}:{{DOCKER_USERTAG}} + +FROM $BASE AS base + +ARG docker_container_name + +COPY ["etc/rsyslog.conf", "/etc/rsyslog.conf"] +RUN [ -f /etc/rsyslog.conf ] && sed -ri "s/%syslogtag%/$docker_container_name#%syslogtag%/;" /etc/rsyslog.conf + +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt-get update && apt-get install -y \ + gnupg \ + net-tools \ + iproute2 \ + arping \ + ndisc6 \ + ethtool \ + tcpdump \ + ifupdown \ + bridge-utils \ + libjudydebian1 \ + openssh-client \ + openssh-server \ + sudo \ + libc-ares2 \ + bash-completion \ + logrotate \ + apt-utils \ + psmisc \ + python3-scapy \ + conntrack \ + iptables \ + jq \ + uuid-dev \ + build-essential \ + python3-dev \ + python3-gi \ + libssl-dev \ + swig \ + openssl \ + libcairo2-dev \ + libdbus-1-dev \ + libgirepository1.0-dev \ + libsystemd-dev \ + pkg-config \ + gir1.2-glib-2.0 \ + libdbus-1-3 \ + libgirepository-1.0-1 \ + {%- if ENABLE_ASAN == "y" %} + libasan6 \ + {%- endif %} + dbus \ + redis-server \ + libprotobuf-c-dev \ + protobuf-c-compiler \ + libgoogle-glog-dev \ + libgrpc++1.51t64 \ + libgrpc29t64 \ + libprotobuf32t64 \ + libgrpc++-dev \ + libgrpc-dev \ + libzmq5 \ + protobuf-compiler \ + protobuf-compiler-grpc \ + python3-protobuf \ + python3-grpcio + +RUN pip3 uninstall -y enum34 +RUN pip3 install \ + pyangbind==0.8.1 \ + pyroute2==0.7.2 \ + netifaces==0.11.0 + +RUN pip3 install meson-python meson ninja patchelf + +{% if docker_sonic_alpinevs_debs.strip() -%} +{{ copy_files("debs/", docker_sonic_alpinevs_debs.split(' '), "/debs/") }} +{{ install_debian_packages(docker_sonic_alpinevs_debs.split(' ')) }} +{%- endif %} + +{% if docker_sonic_alpinevs_pydebs.strip() -%} +{{ copy_files("python-debs/", docker_sonic_alpinevs_pydebs.split(' '), "/debs/") }} +{{ install_debian_packages(docker_sonic_alpinevs_pydebs.split(' ')) }} +{%- endif %} + +# Gracefully remove the Debian-managed cffi package if it exists, otherwise continue +RUN apt-get purge -y python3-cffi python3-cffi-backend || true + +{% if docker_sonic_alpinevs_whls.strip() %} +{{ copy_files("python-wheels/", docker_sonic_alpinevs_whls.split(' '), "/python-wheels/") }} +{{ install_python_wheels(docker_sonic_alpinevs_whls.split(' ')) }} +{% endif %} + +RUN apt-get purge -y build-essential libssl-dev swig python3-dev +RUN apt-get purge -y libcairo2-dev libdbus-1-dev libgirepository1.0-dev libsystemd-dev pkg-config +RUN apt-get clean -y; apt-get autoclean -y; apt-get autoremove -y +RUN pip3 uninstall -y meson-python meson ninja patchelf +RUN rm -rf /debs ~/.cache + +RUN sed -ri 's/^# save ""$/save ""/g; \ + s/^daemonize yes$/daemonize no/; \ + s/^logfile .*$/logfile ""/; \ + s/^# syslog-enabled no$/syslog-enabled no/; \ + s/^# unixsocket/unixsocket/; \ + s/redis-server.sock/redis.sock/g; \ + s/^client-output-buffer-limit pubsub [0-9]+mb [0-9]+mb [0-9]+/client-output-buffer-limit pubsub 0 0 0/; \ + s/^notify-keyspace-events ""$/notify-keyspace-events AKE/; \ + s/^databases [0-9]+$/databases 100/ \ + ' /etc/redis/redis.conf + +COPY ["50-default.conf", "/etc/rsyslog.d/"] +COPY ["start.sh", "orchagent.sh", "telemetry.sh", "files/update_chassisdb_config", "/usr/bin/"] +COPY ["alpinevs-script.sh", "alpinevs-healthcheck.sh", "p4rt.sh", "bin/alpinevs-init.sh","bin/alpinevs-config.sh","bin/pkt-handler", "/usr/bin/"] +COPY ["uptime", "/usr/local/bin/uptime"] +COPY ["docker", "/usr/local/bin/docker"] +COPY ["supervisord.conf.j2", "/usr/share/sonic/templates/"] +COPY ["p4rt_vars.j2", "telemetry_vars.j2", "swss_vars.j2", "/usr/share/sonic/templates/"] +COPY ["files/configdb-load.sh", "/usr/bin/"] +COPY ["files/arp_update", "/usr/bin/"] +COPY ["files/buffers_config.j2", "files/qos_config.j2", "files/arp_update_vars.j2", "/usr/share/sonic/templates/"] +COPY ["copp_cfg_alpinevs.j2", "/usr/share/sonic/templates/"] +COPY ["files/sonic_version.yml", "/etc/sonic/"] +COPY ["port_breakout_config_db.json", "/etc/sonic/"] +COPY ["database_config.json", "/etc/default/sonic-db/"] +COPY ["hostname.j2", "/usr/share/sonic/templates/"] +COPY ["init_cfg.json.j2", "/usr/share/sonic/templates/"] +COPY ["config_db.json", "/etc/sonic/"] +COPY ["default_chassis_cfg.json", "/etc/default/sonic-db/"] +COPY ["asic_table.json", "/etc/sonic/"] +COPY ["zero_profiles.json", "/etc/sonic"] +COPY ["buffermgrd.sh", "/usr/bin/"] + +# Copy the entire device hardware profile directory structure +COPY ["device/", "/usr/share/sonic/device/"] + +RUN mkdir -p /etc/supervisor/conf.d/ +RUN sonic-cfggen -a "{\"ENABLE_ASAN\":\"{{ENABLE_ASAN}}\"}" -t /usr/share/sonic/templates/supervisord.conf.j2 > /etc/supervisor/conf.d/supervisord.conf +RUN rm -f /usr/share/sonic/templates/supervisord.conf.j2 + +{%- if ENABLE_ASAN == "y" %} +RUN mkdir -p /var/log/asan +{%- endif %} + +RUN echo "docker-sonic-alpinevs" > /etc/hostname + +FROM $BASE + +{{ rsync_from_builder_stage() }} + +# Create /zmq_swss directory for ZMQ IPC sockets +RUN mkdir -p /zmq_swss + +# Create the sock directory for p4rt's use +RUN mkdir -p /sock + +RUN mkdir -p /var/run/sshd + +RUN useradd -m -s /bin/bash admin && \ + echo "admin:google" | chpasswd && \ + echo "admin ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers && \ + chown -R admin:admin /home/admin && \ + sed -i 's/^#PermitRootLogin.*/PermitRootLogin no/' /etc/ssh/sshd_config + +COPY sshd.conf /etc/supervisor/conf.d/sshd.conf + +ENV PLATFORM=x86_64-kvm_x86_64-r0 +ENV HWSKU=alpinevs +ENV SOC_TARGET_SERVER=127.0.0.1:50000 + +ENTRYPOINT ["/usr/local/bin/supervisord"] diff --git a/docker-sonic-alpinevs/alpinevs-healthcheck.sh b/docker-sonic-alpinevs/alpinevs-healthcheck.sh new file mode 100755 index 0000000..fe28470 --- /dev/null +++ b/docker-sonic-alpinevs/alpinevs-healthcheck.sh @@ -0,0 +1,300 @@ +#!/bin/bash + +set -u + +FAILURES=0 +WARNINGS=0 + +if [[ $EUID -ne 0 ]];then + echo "ERROR: alpinevs-healthcheck.sh requires root privileges. Run with sudo." + exit 1 +fi + +info() { + echo "INFO: $*" +} + +pass() { + echo "PASS: $*" +} + +warn() { + echo "WARN: $*" + WARNINGS=$((WARNINGS + 1)) +} + +fail() { + echo "FAIL: $*" + FAILURES=$((FAILURES + 1)) +} + +check_file() { + local path="$1" + + if [ -e "$path" ]; then + pass "found $path" + else + fail "missing $path" + fi +} + +check_executable() { + local path="$1" + + if [ -x "$path" ]; then + pass "found executable $path" + elif [ -e "$path" ]; then + fail "$path exists but is not executable" + else + fail "missing executable $path" + fi +} + +supervisor_has_program() { + local program="$1" + + supervisorctl status "$program" >/dev/null 2>&1 +} + +check_supervisor_running() { + local program="$1" + local status + + status=$(supervisorctl status "$program" 2>/dev/null || true) + + if [ -z "$status" ]; then + fail "supervisor program $program is not defined" + return + fi + + if echo "$status" | grep -q "RUNNING"; then + status=$(trim_supervisor_status "$program" "$status") + pass "supervisor program $program is running. Status: $status" + else + status=$(trim_supervisor_status "$program" "$status") + fail "supervisor program $program is not running. Status: $status" + fi +} + +trim_supervisor_status() { + local program="$1" + local status="$2" + + echo "$status" | sed -E "s/^$program[[:space:]]+//" +} + +check_supervisor_running_or_exited() { + local program="$1" + local status + + status=$(supervisorctl status "$program" 2>/dev/null || true) + + if [ -z "$status" ]; then + fail "supervisor program $program is not defined" + elif echo "$status" | grep -Eq "RUNNING|EXITED"; then + status=$(trim_supervisor_status "$program" "$status") + pass "supervisor program $program is healthy. Status: $status" + else + fail "supervisor program $program is not healthy: $status" + fi +} + +check_supervisor_defined() { + local program="$1" + local status + + status=$(supervisorctl status "$program" 2>/dev/null || true) + if [ -n "$status" ]; then + status=$(trim_supervisor_status "$program" "$status") + pass "supervisor program $program is defined. Status: $status" + else + fail "supervisor program $program is not defined" + fi +} + +check_supervisor_any_running() { + local label="$1" + shift + local program + local status + + for program in "$@"; do + if status=$(supervisorctl status "$program" 2>/dev/null); then + if echo "$status" | grep -q "RUNNING"; then + pass "supervisor program $label is running as $program" + return + fi + fi + done + + for program in "$@"; do + if supervisor_has_program "$program"; then + status=$(supervisorctl status "$program" 2>/dev/null || true) + fail "supervisor program $label is defined but not running: $status" + return + fi + done + + fail "none of the supervisor programs for $label are defined: $*" +} + +check_process() { + local label="$1" + local pattern="$2" + + if ps -ef | grep -E "$pattern" | grep -v grep >/dev/null 2>&1; then + pass "process $label is present" + else + fail "process $label is missing" + fi +} + +check_process_any() { + local label="$1" + shift + local pattern + + for pattern in "$@"; do + if ps -ef | grep -E "$pattern" | grep -v grep >/dev/null 2>&1; then + pass "process $label is present" + return + fi + done + + fail "process $label is missing" +} + +check_json() { + local path="$1" + + if [ ! -f "$path" ]; then + fail "cannot parse missing JSON file $path" + return + fi + + if command -v python3 >/dev/null 2>&1; then + if python3 -m json.tool "$path" >/dev/null 2>&1; then + pass "valid JSON $path" + else + fail "invalid JSON $path" + fi + elif command -v jq >/dev/null 2>&1; then + if jq empty "$path" >/dev/null 2>&1; then + pass "valid JSON $path" + else + fail "invalid JSON $path" + fi + else + warn "skipping JSON validation for $path; python3 and jq are unavailable" + fi +} + +check_interfaces_up() { + # Uses awk to check if the 8th column (Oper status) is 'up' for any Ethernet interface row + if show interface status 2>/dev/null | awk '/^[[:space:]]*Ethernet/ { if ($8 == "up") found=1 } END { exit !found }'; then + pass "at least one interface operational status is up" + else + fail "no interfaces are operationally up" + fi +} + +check_syslog() { + local path="/var/log/syslog" + local pattern="(segmentation fault|abrt|segv|traceback|panic|fatal|critical|cannot initialize system|supervisor:.*ERROR)" + + if [ ! -f "$path" ]; then + warn "$path is not present; skipping syslog scan" + return + fi + + if tail -n 300 "$path" | grep -Ei "$pattern" >/dev/null 2>&1; then + fail "recent syslog contains startup error patterns" + tail -n 300 "$path" | grep -Ei "$pattern" | tail -n 20 + else + pass "no recent critical startup patterns found in $path" + fi +} + +info "checking required Alpine files" +check_executable /usr/bin/start.sh +check_executable /usr/bin/alpinevs-script.sh +check_executable /usr/bin/alpinevs-init.sh +check_executable /usr/bin/alpinevs-config.sh +check_executable /usr/bin/pkt-handler +check_executable /usr/bin/p4rt.sh +check_executable /usr/bin/telemetry.sh +check_file /etc/sonic/config_db.json +check_file /etc/sonic/copp_cfg.json +check_file /etc/default/sonic-db/database_config.json +check_file /var/run/redis/sonic-db/database_config.json +check_file /etc/sai.d/sai.profile +check_file /usr/share/sonic/platform +check_file /usr/share/sonic/hwsku + +info "checking JSON configuration" +check_json /etc/sonic/config_db.json +check_json /etc/sonic/copp_cfg.json +check_json /etc/default/sonic-db/database_config.json +check_json /var/run/redis/sonic-db/database_config.json + +info "checking supervisor programs" +check_supervisor_running_or_exited start.sh +check_supervisor_running rsyslogd +check_supervisor_running redis-server +check_supervisor_running syncd +check_supervisor_running portsyncd +check_supervisor_running orchagent +check_supervisor_running coppmgrd +check_supervisor_running neighsyncd +check_supervisor_running fdbsyncd +check_supervisor_running vlanmgrd +check_supervisor_running intfmgrd +check_supervisor_running buffermgrd +check_supervisor_running vrfmgrd +check_supervisor_running portmgrd +check_supervisor_running nbrmgrd +check_supervisor_running vxlanmgrd +check_supervisor_running tunnelmgrd +check_supervisor_running fabricmgrd +check_supervisor_running rebootbackend +check_supervisor_running p4rt +check_supervisor_running telemetry +check_supervisor_running alpine + +info "checking processes" +check_process rsyslogd "/usr/sbin/rsyslogd" +check_process redis-server "/usr/bin/redis-server|[[:space:]]redis-server[[:space:]]" +check_process syncd "syncd" +check_process portsyncd "portsyncd" +check_process orchagent "orchagent" +check_process coppmgrd "coppmgrd" +check_process neighsyncd "neighsyncd" +check_process fdbsyncd "fdbsyncd" +check_process vlanmgrd "vlanmgrd" +check_process intfmgrd "intfmgrd" +check_process buffermgrd "buffermgrd" +check_process vrfmgrd "vrfmgrd" +check_process portmgrd "portmgrd" +check_process nbrmgrd "nbrmgrd" +check_process vxlanmgrd "vxlanmgrd" +check_process tunnelmgrd "tunnelmgrd" +check_process fabricmgrd "fabricmgrd" +check_process rebootbackend "rebootbackend" +check_process p4rt "/usr/local/bin/p4rt|[[:space:]]p4rt[[:space:]]" +check_process_any telemetry "/usr/sbin/telemetry" "[[:space:]]telemetry[[:space:]]" +check_process_any pkt-handler "pkt-handler" + +info "checking interface status" +check_interfaces_up + +info "checking logs" +check_syslog + +echo +echo "AlpineVS healthcheck summary: ${FAILURES} failure(s), ${WARNINGS} warning(s)" + +if [ "$FAILURES" -ne 0 ]; then + exit 1 +fi + +exit 0 diff --git a/docker-sonic-alpinevs/alpinevs-script.sh b/docker-sonic-alpinevs/alpinevs-script.sh new file mode 100755 index 0000000..4e657f4 --- /dev/null +++ b/docker-sonic-alpinevs/alpinevs-script.sh @@ -0,0 +1,10 @@ +#!/bin/bash -ex + +# This script now calls pkt-handler at the end and blocks. Because of this, +# alpinevs-healthcheck.sh expects the script to be always running. +# If pkt-handler is made to run in the background and this script terminates +# modify the health script, perhaps handling this as a special case. + +/usr/bin/alpinevs-init.sh +/usr/bin/alpinevs-config.sh +/usr/bin/pkt-handler diff --git a/docker-sonic-alpinevs/asic_table.json b/docker-sonic-alpinevs/asic_table.json new file mode 100644 index 0000000..f0ed938 --- /dev/null +++ b/docker-sonic-alpinevs/asic_table.json @@ -0,0 +1,11 @@ +[ + { + "ASIC_TABLE:VS-ASIC": { + "cell_size": "128", + "pipeline_latency": "18", + "mac_phy_delay": "0.8", + "peer_response_time": "3.8" + }, + "OP": "SET" + } +] diff --git a/docker-sonic-alpinevs/buffermgrd.sh b/docker-sonic-alpinevs/buffermgrd.sh new file mode 100755 index 0000000..ab2903f --- /dev/null +++ b/docker-sonic-alpinevs/buffermgrd.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +BUFFER_CALCULATION_MODE=$(redis-cli -n 4 hget "DEVICE_METADATA|localhost" buffer_model) +export ASIC_VENDOR=vs + +if [ "$BUFFER_CALCULATION_MODE" == "dynamic" ]; then + BUFFERMGRD_ARGS="-a /etc/sonic/asic_table.json" + + if [ -f /etc/sonic/zero_profiles.json ]; then + BUFFERMGRD_ZERO_PROFILE_ARGS=" -z /etc/sonic/zero_profiles.json" + fi +else + BUFFERMGRD_ARGS="-l /usr/share/sonic/hwsku/pg_profile_lookup.ini" +fi + +exec /usr/bin/buffermgrd ${BUFFERMGRD_ARGS} ${BUFFERMGRD_ZERO_PROFILE_ARGS} diff --git a/docker-sonic-alpinevs/config_db.json b/docker-sonic-alpinevs/config_db.json new file mode 100644 index 0000000..262ff9b --- /dev/null +++ b/docker-sonic-alpinevs/config_db.json @@ -0,0 +1,692 @@ +{ + "AUTO_TECHSUPPORT": { + "GLOBAL": { + "available_mem_threshold": "10.0", + "max_core_limit": "5.0", + "max_techsupport_limit": "10.0", + "min_available_mem": "200", + "rate_limit_interval": "180", + "since": "2 days ago", + "state": "enabled" + } + }, + "AUTO_TECHSUPPORT_FEATURE": { + "bgp": { + "available_mem_threshold": "10.0", + "rate_limit_interval": "600", + "state": "disabled" + }, + "database": { + "available_mem_threshold": "10.0", + "rate_limit_interval": "600", + "state": "enabled" + }, + "dhcp_relay": { + "available_mem_threshold": "10.0", + "rate_limit_interval": "600", + "state": "enabled" + }, + "eventd": { + "available_mem_threshold": "10.0", + "rate_limit_interval": "600", + "state": "disabled" + }, + "inbandmgr": { + "available_mem_threshold": "10.0", + "rate_limit_interval": "600", + "state": "enabled" + }, + "linkqual": { + "available_mem_threshold": "10.0", + "rate_limit_interval": "600", + "state": "enabled" + }, + "lldp": { + "available_mem_threshold": "10.0", + "rate_limit_interval": "600", + "state": "disabled" + }, + "macsec": { + "available_mem_threshold": "10.0", + "rate_limit_interval": "600", + "state": "enabled" + }, + "mux": { + "available_mem_threshold": "10.0", + "rate_limit_interval": "600", + "state": "enabled" + }, + "p4rt": { + "available_mem_threshold": "10.0", + "rate_limit_interval": "600", + "state": "enabled" + }, + "pmon": { + "available_mem_threshold": "10.0", + "rate_limit_interval": "600", + "state": "enabled" + }, + "radv": { + "available_mem_threshold": "10.0", + "rate_limit_interval": "600", + "state": "disabled" + }, + "sflow": { + "available_mem_threshold": "10.0", + "rate_limit_interval": "600", + "state": "enabled" + }, + "snmp": { + "available_mem_threshold": "10.0", + "rate_limit_interval": "600", + "state": "disabled" + }, + "swss": { + "available_mem_threshold": "10.0", + "rate_limit_interval": "600", + "state": "enabled" + }, + "syncd": { + "available_mem_threshold": "10.0", + "rate_limit_interval": "600", + "state": "enabled" + }, + "teamd": { + "available_mem_threshold": "10.0", + "rate_limit_interval": "600", + "state": "enabled" + }, + "telemetry": { + "available_mem_threshold": "10.0", + "rate_limit_interval": "600", + "state": "enabled" + } + }, + "BGP_DEVICE_GLOBAL": { + "STATE": { + "tsa_enabled": "false" + } + }, + "CRM": { + "Config": { + "acl_counter_high_threshold": "85", + "acl_counter_low_threshold": "70", + "acl_counter_threshold_type": "percentage", + "acl_entry_high_threshold": "85", + "acl_entry_low_threshold": "70", + "acl_entry_threshold_type": "percentage", + "acl_group_high_threshold": "85", + "acl_group_low_threshold": "70", + "acl_group_threshold_type": "percentage", + "acl_table_high_threshold": "85", + "acl_table_low_threshold": "70", + "acl_table_threshold_type": "percentage", + "dnat_entry_high_threshold": "85", + "dnat_entry_low_threshold": "70", + "dnat_entry_threshold_type": "percentage", + "fdb_entry_high_threshold": "85", + "fdb_entry_low_threshold": "70", + "fdb_entry_threshold_type": "percentage", + "ipmc_entry_high_threshold": "85", + "ipmc_entry_low_threshold": "70", + "ipmc_entry_threshold_type": "percentage", + "ipv4_neighbor_high_threshold": "85", + "ipv4_neighbor_low_threshold": "70", + "ipv4_neighbor_threshold_type": "percentage", + "ipv4_nexthop_high_threshold": "85", + "ipv4_nexthop_low_threshold": "70", + "ipv4_nexthop_threshold_type": "percentage", + "ipv4_route_high_threshold": "85", + "ipv4_route_low_threshold": "70", + "ipv4_route_threshold_type": "percentage", + "ipv6_neighbor_high_threshold": "85", + "ipv6_neighbor_low_threshold": "70", + "ipv6_neighbor_threshold_type": "percentage", + "ipv6_nexthop_high_threshold": "85", + "ipv6_nexthop_low_threshold": "70", + "ipv6_nexthop_threshold_type": "percentage", + "ipv6_route_high_threshold": "85", + "ipv6_route_low_threshold": "70", + "ipv6_route_threshold_type": "percentage", + "mpls_inseg_high_threshold": "85", + "mpls_inseg_low_threshold": "70", + "mpls_inseg_threshold_type": "percentage", + "mpls_nexthop_high_threshold": "85", + "mpls_nexthop_low_threshold": "70", + "mpls_nexthop_threshold_type": "percentage", + "nexthop_group_high_threshold": "85", + "nexthop_group_low_threshold": "70", + "nexthop_group_member_high_threshold": "85", + "nexthop_group_member_low_threshold": "70", + "nexthop_group_member_threshold_type": "percentage", + "nexthop_group_threshold_type": "percentage", + "polling_interval": "300", + "snat_entry_high_threshold": "85", + "snat_entry_low_threshold": "70", + "snat_entry_threshold_type": "percentage" + } + }, + "DEVICE_METADATA": { + "localhost": { + "bgp_asn": "65100", + "buffer_model": "traditional", + "default_bgp_status": "down", + "default_pfcwd_status": "disable", + "hostname": "sonic", + "hwsku": "alpine_vs", + "mac": "52:54:00:12:34:56", + "platform": "x86_64-kvm_x86_64-r0", + "synchronous_mode": "enable", + "type": "LeafRouter", + "zmq_mode": "enable" + }, + "intf_translate": { + "intf_translate": "enabled" + } + }, + "FEATURE": { + "bgp": { + "auto_restart": "disabled", + "check_up_status": "false", + "has_global_scope": "False", + "has_per_asic_scope": "True", + "high_mem_alert": "disabled", + "state": "disabled" + }, + "database": { + "auto_restart": "always_enabled", + "has_global_scope": "True", + "has_per_asic_scope": "True", + "high_mem_alert": "disabled", + "state": "always_enabled" + }, + "dhcp_relay": { + "auto_restart": "enabled", + "check_up_status": "False", + "has_global_scope": "True", + "has_per_asic_scope": "False", + "high_mem_alert": "disabled", + "set_owner": "local", + "state": "disabled" + }, + "eventd": { + "auto_restart": "disabled", + "has_global_scope": "True", + "has_per_asic_scope": "False", + "high_mem_alert": "disabled", + "state": "disabled" + }, + "inbandmgr": { + "auto_restart": "enabled", + "has_global_scope": "True", + "has_per_asic_scope": "False", + "high_mem_alert": "disabled", + "state": "enabled" + }, + "linkqual": { + "auto_restart": "enabled", + "has_global_scope": "True", + "has_per_asic_scope": "False", + "high_mem_alert": "disabled", + "state": "enabled" + }, + "lldp": { + "auto_restart": "disabled", + "has_global_scope": "True", + "has_per_asic_scope": "False", + "high_mem_alert": "disabled", + "state": "disabled" + }, + "macsec": { + "auto_restart": "enabled", + "check_up_status": "False", + "has_global_scope": "False", + "has_per_asic_scope": "True", + "high_mem_alert": "disabled", + "set_owner": "local", + "state": "disabled" + }, + "mux": { + "auto_restart": "enabled", + "has_global_scope": "True", + "has_per_asic_scope": "False", + "high_mem_alert": "disabled", + "state": "disabled" + }, + "p4rt": { + "auto_restart": "enabled", + "has_global_scope": "True", + "has_per_asic_scope": "False", + "high_mem_alert": "disabled", + "state": "enabled" + }, + "pmon": { + "auto_restart": "enabled", + "check_up_status": "false", + "has_global_scope": "True", + "has_per_asic_scope": "False", + "high_mem_alert": "disabled", + "state": "enabled" + }, + "radv": { + "auto_restart": "disabled", + "has_global_scope": "True", + "has_per_asic_scope": "False", + "high_mem_alert": "disabled", + "state": "disabled" + }, + "sflow": { + "auto_restart": "enabled", + "has_global_scope": "True", + "has_per_asic_scope": "False", + "high_mem_alert": "disabled", + "state": "disabled" + }, + "snmp": { + "auto_restart": "disabled", + "has_global_scope": "True", + "has_per_asic_scope": "False", + "high_mem_alert": "disabled", + "state": "disabled" + }, + "swss": { + "auto_restart": "enabled", + "check_up_status": "false", + "has_global_scope": "False", + "has_per_asic_scope": "True", + "high_mem_alert": "disabled", + "state": "enabled" + }, + "syncd": { + "auto_restart": "enabled", + "has_global_scope": "False", + "has_per_asic_scope": "True", + "high_mem_alert": "disabled", + "state": "enabled" + }, + "teamd": { + "auto_restart": "enabled", + "has_global_scope": "False", + "has_per_asic_scope": "True", + "high_mem_alert": "disabled", + "state": "disabled" + }, + "telemetry": { + "auto_restart": "enabled", + "has_global_scope": "True", + "has_per_asic_scope": "False", + "high_mem_alert": "disabled", + "state": "enabled" + } + }, + "FLEX_COUNTER_TABLE": { + "ACL": { + "FLEX_COUNTER_DELAY_STATUS": "true", + "FLEX_COUNTER_STATUS": "disable", + "POLL_INTERVAL": "10000" + } + }, + "INTERFACE": { + "Ethernet0": {}, + "Ethernet4": {}, + "Ethernet8": {}, + "Ethernet12": {}, + "Ethernet16": {}, + "Ethernet20": {}, + "Ethernet24": {}, + "Ethernet28": {}, + "Ethernet32": {}, + "Ethernet36": {}, + "Ethernet40": {}, + "Ethernet44": {}, + "Ethernet48": {}, + "Ethernet52": {}, + "Ethernet56": {}, + "Ethernet60": {}, + "Ethernet64": {}, + "Ethernet68": {}, + "Ethernet72": {}, + "Ethernet76": {}, + "Ethernet80": {}, + "Ethernet84": {}, + "Ethernet88": {}, + "Ethernet92": {}, + "Ethernet96": {}, + "Ethernet100": {}, + "Ethernet104": {}, + "Ethernet108": {}, + "Ethernet112": {}, + "Ethernet116": {}, + "Ethernet120": {}, + "Ethernet124": {} + }, + "NODE_CFG": { + "integrated_circuit0": { + "node-id": "1" + } + }, + "P4RT": { + "p4rt_app": { + "p4rt_unix_socket": "/sock/p4rt.sock", + "port": "9559", + "save_forwarding_config_file": "/etc/sonic/p4rt_forwarding_config.pb.txt", + "use_genetlink": "false", + "use_port_ids": "true" + } + }, + "PASSW_HARDENING": { + "POLICIES": { + "digits_class": "true", + "expiration": "180", + "expiration_warning": "15", + "history_cnt": "10", + "len_min": "8", + "lower_class": "true", + "reject_user_passw_match": "true", + "special_class": "true", + "state": "disabled", + "upper_class": "true" + } + }, + "PORT": { + "Ethernet0": { + "admin_status": "up", + "alias": "fortyGigE0/0", + "index": "1", + "lanes": "1,2,3,4", + "mtu": "9100", + "presence": "1", + "speed": "40000" + }, + "Ethernet4": { + "admin_status": "up", + "alias": "fortyGigE0/4", + "index": "2", + "lanes": "5,6,7,8", + "mtu": "9100", + "presence": "1", + "speed": "40000" + }, + "Ethernet8": { + "admin_status": "up", + "alias": "fortyGigE0/8", + "index": "3", + "lanes": "9,10,11,12", + "mtu": "9100", + "presence": "1", + "speed": "40000" + }, + "Ethernet12": { + "admin_status": "up", + "alias": "fortyGigE0/12", + "index": "4", + "lanes": "13,14,15,16", + "mtu": "9100", + "presence": "1", + "speed": "40000" + }, + "Ethernet16": { + "admin_status": "up", + "alias": "fortyGigE0/16", + "index": "5", + "lanes": "17,18,19,20", + "mtu": "9100", + "presence": "1", + "speed": "40000" + }, + "Ethernet20": { + "admin_status": "up", + "alias": "fortyGigE0/20", + "index": "6", + "lanes": "21,22,23,24", + "mtu": "9100", + "presence": "1", + "speed": "40000" + }, + "Ethernet24": { + "admin_status": "up", + "alias": "fortyGigE0/24", + "index": "7", + "lanes": "25,26,27,28", + "mtu": "9100", + "presence": "1", + "speed": "40000" + }, + "Ethernet28": { + "admin_status": "up", + "alias": "fortyGigE0/28", + "index": "8", + "lanes": "29,30,31,32", + "mtu": "9100", + "presence": "1", + "speed": "40000" + }, + "Ethernet32": { + "admin_status": "up", + "alias": "fortyGigE0/32", + "index": "9", + "lanes": "33,34,35,36", + "mtu": "9100", + "presence": "1", + "speed": "40000" + }, + "Ethernet36": { + "admin_status": "up", + "alias": "fortyGigE0/36", + "index": "10", + "lanes": "37,38,39,40", + "mtu": "9100", + "presence": "1", + "speed": "40000" + }, + "Ethernet40": { + "admin_status": "up", + "alias": "fortyGigE0/40", + "index": "11", + "lanes": "41,42,43,44", + "mtu": "9100", + "presence": "1", + "speed": "40000" + }, + "Ethernet44": { + "admin_status": "up", + "alias": "fortyGigE0/44", + "index": "12", + "lanes": "45,46,47,48", + "mtu": "9100", + "presence": "1", + "speed": "40000" + }, + "Ethernet48": { + "admin_status": "up", + "alias": "fortyGigE0/48", + "index": "13", + "lanes": "49,50,51,52", + "mtu": "9100", + "presence": "1", + "speed": "40000" + }, + "Ethernet52": { + "admin_status": "up", + "alias": "fortyGigE0/52", + "index": "14", + "lanes": "53,54,55,56", + "mtu": "9100", + "presence": "1", + "speed": "40000" + }, + "Ethernet56": { + "admin_status": "up", + "alias": "fortyGigE0/56", + "index": "15", + "lanes": "57,58,59,60", + "mtu": "9100", + "presence": "1", + "speed": "40000" + }, + "Ethernet60": { + "admin_status": "up", + "alias": "fortyGigE0/60", + "index": "16", + "lanes": "61,62,63,64", + "mtu": "9100", + "presence": "1", + "speed": "40000" + }, + "Ethernet64": { + "admin_status": "up", + "alias": "fortyGigE0/64", + "index": "17", + "lanes": "65,66,67,68", + "mtu": "9100", + "presence": "1", + "speed": "40000" + }, + "Ethernet68": { + "admin_status": "up", + "alias": "fortyGigE0/68", + "index": "18", + "lanes": "69,70,71,72", + "mtu": "9100", + "presence": "1", + "speed": "40000" + }, + "Ethernet72": { + "admin_status": "up", + "alias": "fortyGigE0/72", + "index": "19", + "lanes": "73,74,75,76", + "mtu": "9100", + "presence": "1", + "speed": "40000" + }, + "Ethernet76": { + "admin_status": "up", + "alias": "fortyGigE0/76", + "index": "20", + "lanes": "77,78,79,80", + "mtu": "9100", + "presence": "1", + "speed": "40000" + }, + "Ethernet80": { + "admin_status": "up", + "alias": "fortyGigE0/80", + "index": "21", + "lanes": "81,82,83,84", + "mtu": "9100", + "presence": "1", + "speed": "40000" + }, + "Ethernet84": { + "admin_status": "up", + "alias": "fortyGigE0/84", + "index": "22", + "lanes": "85,86,87,88", + "mtu": "9100", + "presence": "1", + "speed": "40000" + }, + "Ethernet88": { + "admin_status": "up", + "alias": "fortyGigE0/88", + "index": "23", + "lanes": "89,90,91,92", + "mtu": "9100", + "presence": "1", + "speed": "40000" + }, + "Ethernet92": { + "admin_status": "up", + "alias": "fortyGigE0/92", + "index": "24", + "lanes": "93,94,95,96", + "mtu": "9100", + "presence": "1", + "speed": "40000" + }, + "Ethernet96": { + "admin_status": "up", + "alias": "fortyGigE0/96", + "index": "25", + "lanes": "97,98,99,100", + "mtu": "9100", + "presence": "1", + "speed": "40000" + }, + "Ethernet100": { + "admin_status": "up", + "alias": "fortyGigE0/100", + "index": "26", + "lanes": "101,102,103,104", + "mtu": "9100", + "presence": "1", + "speed": "40000" + }, + "Ethernet104": { + "admin_status": "up", + "alias": "fortyGigE0/104", + "index": "27", + "lanes": "105,106,107,108", + "mtu": "9100", + "presence": "1", + "speed": "40000" + }, + "Ethernet108": { + "admin_status": "up", + "alias": "fortyGigE0/108", + "index": "28", + "lanes": "109,110,111,112", + "mtu": "9100", + "presence": "1", + "speed": "40000" + }, + "Ethernet112": { + "admin_status": "up", + "alias": "fortyGigE0/112", + "index": "29", + "lanes": "113,114,115,116", + "mtu": "9100", + "presence": "1", + "speed": "40000" + }, + "Ethernet116": { + "admin_status": "up", + "alias": "fortyGigE0/116", + "index": "30", + "lanes": "117,118,119,120", + "mtu": "9100", + "presence": "1", + "speed": "40000" + }, + "Ethernet120": { + "admin_status": "up", + "alias": "fortyGigE0/120", + "index": "31", + "lanes": "121,122,123,124", + "mtu": "9100", + "presence": "1", + "speed": "40000" + }, + "Ethernet124": { + "admin_status": "up", + "alias": "fortyGigE0/124", + "index": "32", + "lanes": "125,126,127,128", + "mtu": "9100", + "presence": "1", + "speed": "40000" + } + }, + "GNMI": { + "gnmi": { + "port": "9339", + "save_on_set": "true" + } + }, + "VERSIONS": { + "DATABASE": { + "VERSION": "version_4_0_0" + } + } +} diff --git a/docker-sonic-alpinevs/copp_cfg_alpinevs.j2 b/docker-sonic-alpinevs/copp_cfg_alpinevs.j2 new file mode 100644 index 0000000..18e3076 --- /dev/null +++ b/docker-sonic-alpinevs/copp_cfg_alpinevs.j2 @@ -0,0 +1,329 @@ +{ + "COPP_GROUP": { + "queue40_group1": { + "trap_action":"trap", + "trap_priority": "40", + "queue": "40" + }, + "queue41_group1": { + "trap_action":"trap", + "trap_priority":"41", + "queue": "41" + }, + "queue3_group1": { + "genetlink_mcgrp_name": "packets", + "genetlink_name": "psample", + "trap_action": "trap", + "trap_priority": "3", + "queue": "3" + }, + "queue4_group1": { + "trap_action":"trap", + "trap_priority":"4", + "queue": "4" + }, + "queue5_group1": { + "trap_action":"trap", + "trap_priority":"5", + "queue": "5" + }, + "queue7_group1": { + "trap_action":"trap", + "trap_priority":"7", + "queue": "7" + }, + "trap.group.cpu.queue.0": { + "queue": "0", + "genetlink_name" : "genl_packet_q0", + "genetlink_mcgrp_name" : "packets" + }, + "trap.group.cpu.queue.1": { + "queue": "1", + "genetlink_name" : "genl_packet_q1", + "genetlink_mcgrp_name" : "packets" + }, + "trap.group.cpu.queue.2": { + "queue": "2", + "genetlink_name" : "genl_packet_q2", + "genetlink_mcgrp_name" : "packets" + }, + "trap.group.cpu.queue.3": { + "queue": "3", + "genetlink_name" : "genl_packet_q3", + "genetlink_mcgrp_name" : "packets" + }, + "trap.group.cpu.queue.4": { + "queue": "4", + "genetlink_name" : "genl_packet_q4", + "genetlink_mcgrp_name" : "packets" + }, + "trap.group.cpu.queue.5": { + "queue": "5", + "genetlink_name" : "genl_packet_q5", + "genetlink_mcgrp_name" : "packets" + }, + "trap.group.cpu.queue.6": { + "queue": "6", + "genetlink_name" : "genl_packet_q6", + "genetlink_mcgrp_name" : "packets" + }, + "trap.group.cpu.queue.7": { + "queue": "7", + "genetlink_name" : "genl_packet_q7", + "genetlink_mcgrp_name" : "packets" + }, + "trap.group.cpu.queue.8": { + "queue": "8", + "genetlink_name" : "genl_packet_q8", + "genetlink_mcgrp_name" : "packets" + }, + "trap.group.cpu.queue.9": { + "queue": "9", + "genetlink_name" : "genl_packet_q9", + "genetlink_mcgrp_name" : "packets" + }, + "trap.group.cpu.queue.10": { + "queue": "10", + "genetlink_name" : "genl_packet_q10", + "genetlink_mcgrp_name" : "packets" + }, + "trap.group.cpu.queue.11": { + "queue": "11", + "genetlink_name" : "genl_packet_q11", + "genetlink_mcgrp_name" : "packets" + }, + "trap.group.cpu.queue.12": { + "queue": "12", + "genetlink_name" : "genl_packet_q12", + "genetlink_mcgrp_name" : "packets" + }, + "trap.group.cpu.queue.13": { + "queue": "13", + "genetlink_name" : "genl_packet_q13", + "genetlink_mcgrp_name" : "packets" + }, + "trap.group.cpu.queue.14": { + "queue": "14", + "genetlink_name" : "genl_packet_q14", + "genetlink_mcgrp_name" : "packets" + }, + "trap.group.cpu.queue.15": { + "queue": "15", + "genetlink_name" : "genl_packet_q15", + "genetlink_mcgrp_name" : "packets" + }, + "trap.group.cpu.queue.16": { + "queue": "16", + "genetlink_name" : "genl_packet_q16", + "genetlink_mcgrp_name" : "packets" + }, + "trap.group.cpu.queue.17": { + "queue": "17", + "genetlink_name" : "genl_packet_q17", + "genetlink_mcgrp_name" : "packets" + }, + "trap.group.cpu.queue.18": { + "queue": "18", + "genetlink_name" : "genl_packet_q18", + "genetlink_mcgrp_name" : "packets" + }, + "trap.group.cpu.queue.19": { + "queue": "19", + "genetlink_name" : "genl_packet_q19", + "genetlink_mcgrp_name" : "packets" + }, + "trap.group.cpu.queue.20": { + "queue": "20", + "genetlink_name" : "genl_packet_q20", + "genetlink_mcgrp_name" : "packets" + }, + "trap.group.cpu.queue.21": { + "queue": "21", + "genetlink_name" : "genl_packet_q21", + "genetlink_mcgrp_name" : "packets" + }, + "trap.group.cpu.queue.22": { + "queue": "22", + "genetlink_name" : "genl_packet_q22", + "genetlink_mcgrp_name" : "packets" + }, + "trap.group.cpu.queue.23": { + "queue": "23", + "genetlink_name" : "genl_packet_q23", + "genetlink_mcgrp_name" : "packets" + }, + "trap.group.cpu.queue.24": { + "queue": "24", + "genetlink_name" : "genl_packet_q24", + "genetlink_mcgrp_name" : "packets" + }, + "trap.group.cpu.queue.25": { + "queue": "25", + "genetlink_name" : "genl_packet_q25", + "genetlink_mcgrp_name" : "packets" + }, + "trap.group.cpu.queue.26": { + "queue": "26", + "genetlink_name" : "genl_packet_q26", + "genetlink_mcgrp_name" : "packets" + }, + "trap.group.cpu.queue.27": { + "queue": "27", + "genetlink_name" : "genl_packet_q27", + "genetlink_mcgrp_name" : "packets" + }, + "trap.group.cpu.queue.28": { + "queue": "28", + "genetlink_name" : "genl_packet_q28", + "genetlink_mcgrp_name" : "packets" + }, + "trap.group.cpu.queue.29": { + "queue": "29", + "genetlink_name" : "genl_packet_q29", + "genetlink_mcgrp_name" : "packets" + }, + "trap.group.cpu.queue.30": { + "queue": "30", + "genetlink_name" : "genl_packet_q30", + "genetlink_mcgrp_name" : "packets" + }, + "trap.group.cpu.queue.31": { + "queue": "31", + "genetlink_name" : "genl_packet_q31", + "genetlink_mcgrp_name" : "packets" + }, + "trap.group.cpu.queue.32": { + "queue": "32", + "genetlink_name" : "genl_packet_q32", + "genetlink_mcgrp_name" : "packets" + }, + "trap.group.cpu.queue.33": { + "queue": "33", + "genetlink_name" : "genl_packet_q33", + "genetlink_mcgrp_name" : "packets" + }, + "trap.group.cpu.queue.34": { + "queue": "34", + "genetlink_name" : "genl_packet_q34", + "genetlink_mcgrp_name" : "packets" + }, + "trap.group.cpu.queue.35": { + "queue": "35", + "genetlink_name" : "genl_packet_q35", + "genetlink_mcgrp_name" : "packets" + }, + "trap.group.cpu.queue.36": { + "queue": "36", + "genetlink_name" : "genl_packet_q36", + "genetlink_mcgrp_name" : "packets" + }, + "trap.group.cpu.queue.37": { + "queue": "37", + "genetlink_name" : "genl_packet_q37", + "genetlink_mcgrp_name" : "packets" + }, + "trap.group.cpu.queue.38": { + "queue": "38", + "genetlink_name" : "genl_packet_q38", + "genetlink_mcgrp_name" : "packets" + }, + "trap.group.cpu.queue.39": { + "queue": "39", + "genetlink_name" : "genl_packet_q39", + "genetlink_mcgrp_name" : "packets" + }, + "trap.group.cpu.queue.40": { + "queue": "40", + "genetlink_name" : "genl_packet_q40", + "genetlink_mcgrp_name" : "packets" + }, + "trap.group.cpu.queue.41": { + "queue": "41", + "genetlink_name" : "genl_packet_q41", + "genetlink_mcgrp_name" : "packets" + }, + "trap.group.cpu.queue.42": { + "queue": "42", + "genetlink_name" : "genl_packet_q42", + "genetlink_mcgrp_name" : "packets" + }, + "trap.group.cpu.queue.43": { + "queue": "43", + "genetlink_name" : "genl_packet_q43", + "genetlink_mcgrp_name" : "packets" + }, + "trap.group.cpu.queue.44": { + "queue": "44", + "genetlink_name" : "genl_packet_q44", + "genetlink_mcgrp_name" : "packets" + }, + "trap.group.cpu.queue.45": { + "queue": "45", + "genetlink_name" : "genl_packet_q45", + "genetlink_mcgrp_name" : "packets" + }, + "trap.group.cpu.queue.46": { + "queue": "46", + "genetlink_name" : "genl_packet_q46", + "genetlink_mcgrp_name" : "packets" + }, + "trap.group.cpu.queue.47": { + "queue": "47", + "genetlink_name" : "genl_packet_q47", + "genetlink_mcgrp_name" : "packets" + } + }, + "COPP_TRAP": { + "teamd": { + "trap_ids": "lacp", + "trap_group": "queue40_group1" + }, + "ssh": { + "trap_ids": "ssh", + "trap_group": "queue4_group1", + "always_enabled": "true" + }, + "p4rt": { + "trap_ids": "p4rt", + "trap_group": "queue41_group1" + }, + "gnmi": { + "trap_ids": "gnmi", + "trap_group": "queue41_group1" + }, + "ntp_client": { + "trap_ids": "ntp_client", + "trap_group": "queue7_group1", + "always_enabled": "true" + }, + "ntp_server": { + "trap_ids": "ntp_server", + "trap_group": "queue7_group1", + "always_enabled": "true" + }, + "sflow": { + "trap_group": "queue3_group1", + "trap_ids": "sample_packet" + }, + "http": { + "trap_ids": "http_client", + "trap_group": "queue4_group1", + "always_enabled": "true" + }, + "icmp": { + "trap_ids": "icmp", + "trap_group": "queue5_group1", + "always_enabled": "true" + }, + "icmpv6": { + "trap_ids": "icmpv6", + "trap_group": "queue5_group1", + "always_enabled": "true" + }, + "vrmu": { + "trap_ids": "vrmu", + "trap_group": "queue7_group1", + "always_enabled": "true" + } + } +} diff --git a/docker-sonic-alpinevs/database_config.json b/docker-sonic-alpinevs/database_config.json new file mode 100644 index 0000000..a4e2c62 --- /dev/null +++ b/docker-sonic-alpinevs/database_config.json @@ -0,0 +1,103 @@ +{ + "INSTANCES": { + "redis":{ + "hostname" : "127.0.0.1", + "port" : 6379, + "unix_socket_path" : "/var/run/redis/redis.sock" + }, + + "redis_chassis":{ + "hostname" : "redis_chassis.server", + "port": 6380, + "unix_socket_path": "/var/run/redis/redis_chassis.sock" + } + }, + "DATABASES" : { + "APPL_DB" : { + "id" : 0, + "separator": ":", + "instance" : "redis" + }, + "ASIC_DB" : { + "id" : 1, + "separator": ":", + "instance" : "redis" + }, + "COUNTERS_DB" : { + "id" : 2, + "separator": ":", + "instance" : "redis" + }, + "CONFIG_DB" : { + "id" : 4, + "separator": "|", + "instance" : "redis" + }, + "PFC_WD_DB" : { + "id" : 5, + "separator": ":", + "instance" : "redis" + }, + "FLEX_COUNTER_DB" : { + "id" : 5, + "separator": ":", + "instance" : "redis" + }, + "STATE_DB" : { + "id" : 6, + "separator": "|", + "instance" : "redis" + }, + "SNMP_OVERLAY_DB" : { + "id" : 7, + "separator": "|", + "instance" : "redis" + }, + "GB_ASIC_DB" : { + "id" : 9, + "separator": ":", + "instance" : "redis" + }, + "GB_COUNTERS_DB" : { + "id" : 10, + "separator": ":", + "instance" : "redis" + }, + "GB_FLEX_COUNTER_DB" : { + "id" : 11, + "separator": ":", + "instance" : "redis" + }, + "CHASSIS_APP_DB" : { + "id" : 12, + "separator": "|", + "instance" : "redis_chassis" + }, + "APPL_STATE_DB" : { + "id" : 14, + "separator": ":", + "instance" : "redis" + }, + "DPU_APPL_DB" : { + "id" : 15, + "separator": ":", + "instance" : "redis" + }, + "DPU_APPL_STATE_DB" : { + "id" : 16, + "separator": "|", + "instance" : "redis" + }, + "DPU_STATE_DB" : { + "id": 17, + "separator": "|", + "instance" : "redis" + }, + "DPU_COUNTERS_DB" : { + "id": 18, + "separator": ":", + "instance" : "redis" + } + }, + "VERSION" : "1.0" +} diff --git a/docker-sonic-alpinevs/default_chassis_cfg.json b/docker-sonic-alpinevs/default_chassis_cfg.json new file mode 100644 index 0000000..673a479 --- /dev/null +++ b/docker-sonic-alpinevs/default_chassis_cfg.json @@ -0,0 +1,7 @@ +{ + "DEVICE_METADATA": { + "localhost": { + "chassis_db_address" : "10.8.1.200" + } + } +} diff --git a/docker-sonic-alpinevs/device/x86_64-kvm_x86_64-r0/alpinevs/hwsku.json b/docker-sonic-alpinevs/device/x86_64-kvm_x86_64-r0/alpinevs/hwsku.json new file mode 100644 index 0000000..7c5a8c1 --- /dev/null +++ b/docker-sonic-alpinevs/device/x86_64-kvm_x86_64-r0/alpinevs/hwsku.json @@ -0,0 +1,100 @@ +{ + "interfaces": { + "Ethernet0": { + "default_brkout_mode": "1x100G[40G]" + }, + "Ethernet4": { + "default_brkout_mode": "1x100G[40G]" + }, + "Ethernet8": { + "default_brkout_mode": "1x100G[40G]" + }, + "Ethernet12": { + "default_brkout_mode": "1x100G[40G]" + }, + "Ethernet16": { + "default_brkout_mode": "1x100G[40G]" + }, + "Ethernet20": { + "default_brkout_mode": "1x100G[40G]" + }, + "Ethernet24": { + "default_brkout_mode": "1x100G[40G]" + }, + "Ethernet28": { + "default_brkout_mode": "1x100G[40G]" + }, + "Ethernet32": { + "default_brkout_mode": "1x100G[40G]" + }, + "Ethernet36": { + "default_brkout_mode": "1x100G[40G]" + }, + "Ethernet40": { + "default_brkout_mode": "1x100G[40G]" + }, + "Ethernet44": { + "default_brkout_mode": "1x100G[40G]" + }, + "Ethernet48": { + "default_brkout_mode": "1x100G[40G]" + }, + "Ethernet52": { + "default_brkout_mode": "1x100G[40G]" + }, + "Ethernet56": { + "default_brkout_mode": "1x100G[40G]" + }, + "Ethernet60": { + "default_brkout_mode": "1x100G[40G]" + }, + "Ethernet64": { + "default_brkout_mode": "1x100G[40G]" + }, + "Ethernet68": { + "default_brkout_mode": "1x100G[40G]" + }, + "Ethernet72": { + "default_brkout_mode": "1x100G[40G]" + }, + "Ethernet76": { + "default_brkout_mode": "1x100G[40G]" + }, + "Ethernet80": { + "default_brkout_mode": "1x100G[40G]" + }, + "Ethernet84": { + "default_brkout_mode": "1x100G[40G]" + }, + "Ethernet88": { + "default_brkout_mode": "1x100G[40G]" + }, + "Ethernet92": { + "default_brkout_mode": "1x100G[40G]" + }, + "Ethernet96": { + "default_brkout_mode": "1x100G[40G]" + }, + "Ethernet100": { + "default_brkout_mode": "1x100G[40G]" + }, + "Ethernet104": { + "default_brkout_mode": "1x100G[40G]" + }, + "Ethernet108": { + "default_brkout_mode": "1x100G[40G]" + }, + "Ethernet112": { + "default_brkout_mode": "1x100G[40G]" + }, + "Ethernet116": { + "default_brkout_mode": "1x100G[40G]" + }, + "Ethernet120": { + "default_brkout_mode": "1x100G[40G]" + }, + "Ethernet124": { + "default_brkout_mode": "1x100G[40G]" + } + } +} diff --git a/docker-sonic-alpinevs/device/x86_64-kvm_x86_64-r0/alpinevs/sai.profile b/docker-sonic-alpinevs/device/x86_64-kvm_x86_64-r0/alpinevs/sai.profile new file mode 100644 index 0000000..46adadb --- /dev/null +++ b/docker-sonic-alpinevs/device/x86_64-kvm_x86_64-r0/alpinevs/sai.profile @@ -0,0 +1 @@ +SAI_DATAPLANE_URL=127.0.0.1:50000 diff --git a/docker-sonic-alpinevs/device/x86_64-kvm_x86_64-r0/platform.json b/docker-sonic-alpinevs/device/x86_64-kvm_x86_64-r0/platform.json new file mode 100644 index 0000000..83806f2 --- /dev/null +++ b/docker-sonic-alpinevs/device/x86_64-kvm_x86_64-r0/platform.json @@ -0,0 +1,164 @@ +{ + "interfaces": { + "Ethernet0": { + "index": "1", + "lanes": "1,2,3,4", + "breakout_modes": { "1x100G[40G]": ["1,2,3,4"] } + }, + "Ethernet4": { + "index": "2", + "lanes": "5,6,7,8", + "breakout_modes": { "1x100G[40G]": ["5,6,7,8"] } + }, + "Ethernet8": { + "index": "3", + "lanes": "9,10,11,12", + "breakout_modes": { "1x100G[40G]": ["9,10,11,12"] } + }, + "Ethernet12": { + "index": "4", + "lanes": "13,14,15,16", + "breakout_modes": { "1x100G[40G]": ["13,14,15,16"] } + }, + "Ethernet16": { + "index": "5", + "lanes": "17,18,19,20", + "breakout_modes": { "1x100G[40G]": ["17,18,19,20"] } + }, + "Ethernet20": { + "index": "6", + "lanes": "21,22,23,24", + "breakout_modes": { "1x100G[40G]": ["21,22,23,24"] } + }, + "Ethernet24": { + "index": "7", + "lanes": "25,26,27,28", + "breakout_modes": { "1x100G[40G]": ["25,26,27,28"] } + }, + "Ethernet28": { + "index": "8", + "lanes": "29,30,31,32", + "breakout_modes": { "1x100G[40G]": ["29,30,31,32"] } + }, + "Ethernet32": { + "index": "9", + "lanes": "33,34,35,36", + "breakout_modes": { "1x100G[40G]": ["33,34,35,36"] } + }, + "Ethernet36": { + "index": "10", + "lanes": "37,38,39,40", + "breakout_modes": { "1x100G[40G]": ["37,38,39,40"] } + }, + "Ethernet40": { + "index": "11", + "lanes": "41,42,43,44", + "breakout_modes": { "1x100G[40G]": ["41,42,43,44"] } + }, + "Ethernet44": { + "index": "12", + "lanes": "45,46,47,48", + "breakout_modes": { "1x100G[40G]": ["45,46,47,48"] } + }, + "Ethernet48": { + "index": "13", + "lanes": "49,50,51,52", + "breakout_modes": { "1x100G[40G]": ["49,50,51,52"] } + }, + "Ethernet52": { + "index": "14", + "lanes": "53,54,55,56", + "breakout_modes": { "1x100G[40G]": ["53,54,55,56"] } + }, + "Ethernet56": { + "index": "15", + "lanes": "57,58,59,60", + "breakout_modes": { "1x100G[40G]": ["57,58,59,60"] } + }, + "Ethernet60": { + "index": "16", + "lanes": "61,62,63,64", + "breakout_modes": { "1x100G[40G]": ["61,62,63,64"] } + }, + "Ethernet64": { + "index": "17", + "lanes": "65,66,67,68", + "breakout_modes": { "1x100G[40G]": ["65,66,67,68"] } + }, + "Ethernet68": { + "index": "18", + "lanes": "69,70,71,72", + "breakout_modes": { "1x100G[40G]": ["69,70,71,72"] } + }, + "Ethernet72": { + "index": "19", + "lanes": "73,74,75,76", + "breakout_modes": { "1x100G[40G]": ["73,74,75,76"] } + }, + "Ethernet76": { + "index": "20", + "lanes": "77,78,79,80", + "breakout_modes": { "1x100G[40G]": ["77,78,79,80"] } + }, + "Ethernet80": { + "index": "21", + "lanes": "81,82,83,84", + "breakout_modes": { "1x100G[40G]": ["81,82,83,84"] } + }, + "Ethernet84": { + "index": "22", + "lanes": "85,86,87,88", + "breakout_modes": { "1x100G[40G]": ["85,86,87,88"] } + }, + "Ethernet88": { + "index": "23", + "lanes": "89,90,91,92", + "breakout_modes": { "1x100G[40G]": ["89,90,91,92"] } + }, + "Ethernet92": { + "index": "24", + "lanes": "93,94,95,96", + "breakout_modes": { "1x100G[40G]": ["93,94,95,96"] } + }, + "Ethernet96": { + "index": "25", + "lanes": "97,98,99,100", + "breakout_modes": { "1x100G[40G]": ["97,98,99,100"] } + }, + "Ethernet100": { + "index": "26", + "lanes": "101,102,103,104", + "breakout_modes": { "1x100G[40G]": ["101,102,103,104"] } + }, + "Ethernet104": { + "index": "27", + "lanes": "105,106,107,108", + "breakout_modes": { "1x100G[40G]": ["105,106,107,108"] } + }, + "Ethernet108": { + "index": "28", + "lanes": "109,110,111,112", + "breakout_modes": { "1x100G[40G]": ["109,110,111,112"] } + }, + "Ethernet112": { + "index": "29", + "lanes": "113,114,115,116", + "breakout_modes": { "1x100G[40G]": ["113,114,115,116"] } + }, + "Ethernet116": { + "index": "30", + "lanes": "117,118,119,120", + "breakout_modes": { "1x100G[40G]": ["117,118,119,120"] } + }, + "Ethernet120": { + "index": "31", + "lanes": "121,122,123,124", + "breakout_modes": { "1x100G[40G]": ["121,122,123,124"] } + }, + "Ethernet124": { + "index": "32", + "lanes": "125,126,127,128", + "breakout_modes": { "1x100G[40G]": ["125,126,127,128"] } + } + } +} diff --git a/docker-sonic-alpinevs/docker b/docker-sonic-alpinevs/docker new file mode 100755 index 0000000..039e4d0 --- /dev/null +++ b/docker-sonic-alpinevs/docker @@ -0,0 +1,2 @@ +#!/bin/sh +exit 0 diff --git a/docker-sonic-alpinevs/etc/rsyslog.conf b/docker-sonic-alpinevs/etc/rsyslog.conf new file mode 100644 index 0000000..ef24922 --- /dev/null +++ b/docker-sonic-alpinevs/etc/rsyslog.conf @@ -0,0 +1,76 @@ +# +# /etc/rsyslog.conf Configuration file for rsyslog. +# +# For more information see +# /usr/share/doc/rsyslog-doc/html/rsyslog_conf.html + + +################# +#### MODULES #### +################# + +$ModLoad imuxsock # provides support for local system logging + +# +# Set a rate limit on messages from the container +# +$SystemLogRateLimitInterval 300 +$SystemLogRateLimitBurst 20000 + +#$ModLoad imklog # provides kernel logging support +#$ModLoad immark # provides --MARK-- message capability + +# provides UDP syslog reception +#$ModLoad imudp +#$UDPServerRun 514 + +# provides TCP syslog reception +#$ModLoad imtcp +#$InputTCPServerRun 514 + + +########################### +#### GLOBAL DIRECTIVES #### +########################### + +# Set remote syslog server +template (name="ForwardFormatInContainer" type="string" string="<%PRI%>%TIMESTAMP:::date-rfc3339% %HOSTNAME% %syslogtag%%msg:::sp-if-no-1st-sp%%msg%") +*.* action(type="omfwd" target="127.0.0.1" port="514" protocol="udp" Template="ForwardFormatInContainer") + +# +# Use traditional timestamp format. +# To enable high precision timestamps, comment out the following line. +# +#$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat + +# Define a custom template +$template SONiCFileFormat,"%TIMESTAMP%.%timestamp:::date-subseconds% %HOSTNAME% %syslogseverity-text:::uppercase% %syslogtag%%msg:::sp-if-no-1st-sp%%msg:::drop-last-lf%\n" +$ActionFileDefaultTemplate SONiCFileFormat + +# +# Set the default permissions for all log files. +# +$FileOwner root +$FileGroup adm +$FileCreateMode 0640 +$DirCreateMode 0755 +$Umask 0022 + +# +# Where to place spool and state files +# +$WorkDirectory /var/spool/rsyslog + +# +# Include all config files in /etc/rsyslog.d/ +# +$IncludeConfig /etc/rsyslog.d/*.conf + +# +# Suppress duplicate messages and report "message repeated n times" +# +$RepeatedMsgReduction on + +############### +#### RULES #### +############### diff --git a/docker-sonic-alpinevs/hostname.j2 b/docker-sonic-alpinevs/hostname.j2 new file mode 100644 index 0000000..91d7cba --- /dev/null +++ b/docker-sonic-alpinevs/hostname.j2 @@ -0,0 +1,3 @@ +{% if DEVICE_METADATA.localhost.chassis_db_address %} +{{ DEVICE_METADATA.localhost.chassis_db_address }} redis_chassis.server +{% endif %} diff --git a/docker-sonic-alpinevs/init_cfg.json.j2 b/docker-sonic-alpinevs/init_cfg.json.j2 new file mode 100644 index 0000000..600c882 --- /dev/null +++ b/docker-sonic-alpinevs/init_cfg.json.j2 @@ -0,0 +1,53 @@ +{ + "DEVICE_METADATA": { + "localhost": { + "mac": "{{ system_mac }}", + "switch_type": "{{ switch_type }}", + "buffer_model": "traditional" + } + }, +{%- set features = ({"swss": "enabled", "nat": "enabled", "database": "enabled", "lldp": "enabled", "p4rt": "enabled", "telemetry": "enabled"}) %} + "FEATURE": { +{%- for feature, state in features.items() %} + "{{ feature }}": { + "state": "{{ state }}" + }{% if not loop.last %},{% endif %} +{%- endfor %} + }, + "FLEX_COUNTER_TABLE": { + "ACL": { + "FLEX_COUNTER_STATUS": "enable", + "POLL_INTERVAL": "10000" + }, + "PORT": { + "FLEX_COUNTER_STATUS": "enable" + }, + "PORT_PHY_ATTR": { + "FLEX_COUNTER_STATUS": "enable" + }, + "RIF": { + "FLEX_COUNTER_STATUS": "enable" + }, + "QUEUE": { + "FLEX_COUNTER_STATUS": "enable" + }, + "PFCWD": { + "FLEX_COUNTER_STATUS": "enable" + }, + "PG_WATERMARK": { + "FLEX_COUNTER_STATUS": "enable" + }, + "PG_DROP": { + "FLEX_COUNTER_STATUS": "enable" + }, + "QUEUE_WATERMARK": { + "FLEX_COUNTER_STATUS": "enable" + }, + "BUFFER_POOL_WATERMARK": { + "FLEX_COUNTER_STATUS": "enable" + }, + "PORT_BUFFER_DROP": { + "FLEX_COUNTER_STATUS": "enable" + } + } +} diff --git a/docker-sonic-alpinevs/orchagent.sh b/docker-sonic-alpinevs/orchagent.sh new file mode 100755 index 0000000..18474a8 --- /dev/null +++ b/docker-sonic-alpinevs/orchagent.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash + +export platform=alpinevs + +SWSS_VARS_FILE=/usr/share/sonic/templates/swss_vars.j2 +SWSS_VARS=$(sonic-cfggen -d -y /etc/sonic/sonic_version.yml -t $SWSS_VARS_FILE) || exit 1 + +MAC_ADDRESS=$(echo $SWSS_VARS | jq -r '.mac') +if [ "$MAC_ADDRESS" == "None" ] || [ -z "$MAC_ADDRESS" ]; then + MAC_ADDRESS=$(ip link show eth0 | grep ether | awk '{print $2}') + logger "Mac address not found in Device Metadata, Falling back to eth0" +fi + +mkdir -p /var/log/swss +ORCHAGENT_ARGS="-d /var/log/swss " + +# Alpine always uses switch type (not dpu) +ORCHAGENT_ARGS+="-b 8192 " + +# Alpine config_db has synchronous_mode=enable and zmq_mode=enable +SYNC_MODE=$(echo $SWSS_VARS | jq -r '.synchronous_mode') +ZMQ_MODE=$(echo $SWSS_VARS | jq -r '.zmq_mode') + +if [ "$ZMQ_MODE" == "enable" ]; then + ORCHAGENT_ARGS+="-z zmq_sync " +elif [ "$SYNC_MODE" == "enable" ]; then + ORCHAGENT_ARGS+="-s " +fi + +ORCHDAEMON_RING_ENABLED=`sonic-db-cli CONFIG_DB hget "DEVICE_METADATA|localhost" "ring_thread_enabled"` +if [[ x"${ORCHDAEMON_RING_ENABLED}" == x"true" ]]; then + ORCHAGENT_ARGS+="-R " +fi + +ORCHAGENT_ARGS+="-m $MAC_ADDRESS" + +exec /usr/bin/orchagent ${ORCHAGENT_ARGS} diff --git a/docker-sonic-alpinevs/p4rt.sh b/docker-sonic-alpinevs/p4rt.sh new file mode 100755 index 0000000..ebdd6c7 --- /dev/null +++ b/docker-sonic-alpinevs/p4rt.sh @@ -0,0 +1,99 @@ +#!/usr/bin/env bash + +EXIT_P4RT_VARS_FILE_NOT_FOUND=1 +readonly P4RT_VARS_FILE=/usr/share/sonic/templates/p4rt_vars.j2 + +if [ ! -f "${P4RT_VARS_FILE}" ]; then + echo "P4rt vars template file not found" + exit ${EXIT_P4RT_VARS_FILE_NOT_FOUND} +fi + +# Try to read p4rt and certs config from ConfigDB. +# Use default value if no valid config exists. +P4RT_VARS=$(sonic-cfggen -d -t ${P4RT_VARS_FILE}) +readonly P4RT_VARS=${P4RT_VARS//[\']/\"} +readonly X509=$(echo ${P4RT_VARS} | jq -r '.x509') +readonly P4RT=$(echo ${P4RT_VARS} | jq -r '.p4rt') +readonly CERTS=$(echo ${P4RT_VARS} | jq -r '.certs') + +P4RT_ARGS="" + +if [ -n "${CERTS}" ]; then + readonly SERVER_CRT=$(echo ${CERTS} | jq -r '.server_crt // empty') + readonly SERVER_KEY=$(echo ${CERTS} | jq -r '.server_key // empty') + if [ -z "${SERVER_CRT}" ] || [ -z "${SERVER_KEY}" ]; then + P4RT_ARGS+=" --use_insecure_server_credentials" + else + P4RT_ARGS+=" --server_certificate_file=${SERVER_CRT} --server_key_file=${SERVER_KEY}" + fi + + readonly CA_CRT=$(echo ${CERTS} | jq -r '.ca_crt // empty') + if [ -n "${CA_CRT}" ]; then + P4RT_ARGS+=" --ca_certificate_file=${CA_CRT}" + readonly CRL=$(echo ${CERTS} | jq -r '.cert_crl_dir // empty') + if [ -n "${CRL}" ]; then + P4RT_ARGS+=" --cert_crl_dir=${CRL}" + fi + fi +elif [ -n "${X509}" ]; then + readonly SERVER_CRT=$(echo ${X509} | jq -r '.server_crt // empty') + readonly SERVER_KEY=$(echo ${X509} | jq -r '.server_key // empty') + if [ -z "${SERVER_CRT}" ] || [ -z "${SERVER_KEY}" ]; then + P4RT_ARGS+=" --use_insecure_server_credentials" + else + P4RT_ARGS+=" --server_certificate_file=${SERVER_CRT} --server_key_file=${SERVER_KEY}" + fi + + readonly CA_CRT=$(echo ${X509} | jq -r '.ca_crt // empty') + if [ -n "${CA_CRT}" ]; then + P4RT_ARGS+=" --ca_certificate_file=${CA_CRT}" + readonly CRL=$(echo ${X509} | jq -r '.cert_crl_dir // empty') + if [ -n "${CRL}" ]; then + P4RT_ARGS+=" --cert_crl_dir=${CRL}" + fi + fi +else + P4RT_ARGS+=" --use_insecure_server_credentials" +fi + +# Try to read P4RT authorization config from ConfigDB. +readonly AUTHZ_FILE=$(echo ${P4RT} | jq -r '.authz_policy // empty') +if [ -n "${AUTHZ_FILE}" ]; then + P4RT_ARGS+=" --authz_policy_enabled --authorization_policy_file=${AUTHZ_FILE}" +fi + +# Try to read P4RT port config from ConfigDB. +readonly PORT=$(echo ${P4RT} | jq -r '.port // empty') +if [ -n "${PORT}" ]; then + P4RT_ARGS+=" --p4rt_grpc_port=${PORT}" +fi + +# Try to read P4RT genetlink config from ConfigDB. +readonly GENETLINK=$(echo ${P4RT} | jq -r '.use_genetlink // empty') +if [ -n "${GENETLINK}" ]; then + P4RT_ARGS+=" --use_genetlink=${GENETLINK}" +fi + +# Try to read P4RT port ID config from ConfigDB. +readonly PORT_ID=$(echo ${P4RT} | jq -r '.use_port_ids // empty') +if [ -n "${PORT_ID}" ]; then + P4RT_ARGS+=" --use_port_ids=${PORT_ID}" +fi + +# Try to read P4RT save forwarding config from ConfigDB. +readonly SAVE_FORWARDING_CONFIG=$(echo ${P4RT} | jq -r '.save_forwarding_config_file // empty') +if [ -n "${SAVE_FORWARDING_CONFIG}" ]; then + P4RT_ARGS+=" --save_forwarding_config_file=${SAVE_FORWARDING_CONFIG}" +fi + +# Try to read P4RT unix socket config from ConfigDB. +readonly UNIX_SOCKET=$(echo ${P4RT} | jq -r '.p4rt_unix_socket // empty') +if [ -n "${UNIX_SOCKET}" ]; then + SOCK_DIR="$(dirname "$UNIX_SOCKET")" + if [ ! -d "$SOCK_DIR" ]; then + mkdir -p "$SOCK_DIR" + fi + P4RT_ARGS+=" --p4rt_unix_socket=${UNIX_SOCKET}" +fi + +exec /usr/local/bin/p4rt ${P4RT_ARGS} diff --git a/docker-sonic-alpinevs/p4rt_vars.j2 b/docker-sonic-alpinevs/p4rt_vars.j2 new file mode 100644 index 0000000..a62fee1 --- /dev/null +++ b/docker-sonic-alpinevs/p4rt_vars.j2 @@ -0,0 +1,5 @@ +{ + "certs": {% if P4RT %}{% if "certs" in P4RT.keys() %}{{ P4RT["certs"] }}{% else %}""{% endif %}{% else %}""{% endif %}, + "p4rt" : {% if P4RT %}{% if "p4rt_app" in P4RT.keys() %}{{ P4RT["p4rt_app"] }}{% else %}""{% endif %}{% else %}""{% endif %}, + "x509" : {% if DEVICE_METADATA %}{% if "x509" in DEVICE_METADATA.keys() %}{{ DEVICE_METADATA["x509"] }}{% else %}""{% endif %}{% else %}""{% endif %} +} diff --git a/docker-sonic-alpinevs/port_breakout_config_db.json b/docker-sonic-alpinevs/port_breakout_config_db.json new file mode 100644 index 0000000..16b40e1 --- /dev/null +++ b/docker-sonic-alpinevs/port_breakout_config_db.json @@ -0,0 +1,61 @@ +{ + "ACL_TABLE": { + "DPB_ACL_TBL_1": { + "policy_desc": "ACL table to test DPB/ACL dependency", + "ports": [ + "Ethernet0", + "Ethernet1", + "Ethernet2", + "Ethernet3", + "Ethernet4", + "Ethernet5" + ], + "type": "L3" + }, + "DPB_ACL_TBL_2": { + "policy_desc": "ACL table to test DPB/ACL dependency", + "ports": [ + "Ethernet0", + "Ethernet1", + "Ethernet2", + "Ethernet3", + "Ethernet6", + "Ethernet7" + ], + "type": "L3" + } + }, + "INTERFACE": { + "Ethernet8": {}, + "Ethernet8|10.0.0.8/31": { + "family": "IPv4", + "scope": "global" + } + }, + "VLAN_MEMBER": { + "Vlan100|Ethernet0": { + "tagging_mode": "untagged" + }, + "Vlan100|Ethernet1": { + "tagging_mode": "untagged" + }, + "Vlan100|Ethernet2": { + "tagging_mode": "untagged" + }, + "Vlan100|Ethernet3": { + "tagging_mode": "untagged" + }, + "Vlan100|Ethernet4": { + "tagging_mode": "untagged" + }, + "Vlan100|Ethernet5": { + "tagging_mode": "untagged" + }, + "Vlan101|Ethernet6": { + "tagging_mode": "tagged" + }, + "Vlan101|Ethernet7": { + "tagging_mode": "tagged" + } + } +} diff --git a/docker-sonic-alpinevs/sai.profile b/docker-sonic-alpinevs/sai.profile new file mode 100644 index 0000000..eb32f2c --- /dev/null +++ b/docker-sonic-alpinevs/sai.profile @@ -0,0 +1 @@ +SAI_VS_HOSTIF_USE_TAP_DEVICE=true diff --git a/docker-sonic-alpinevs/sshd.conf b/docker-sonic-alpinevs/sshd.conf new file mode 100644 index 0000000..6930318 --- /dev/null +++ b/docker-sonic-alpinevs/sshd.conf @@ -0,0 +1,7 @@ +[program:sshd] +command=/usr/sbin/sshd -D +autostart=true +autorestart=true +priority=10 +stdout_logfile=syslog +stderr_logfile=syslog diff --git a/docker-sonic-alpinevs/start.sh b/docker-sonic-alpinevs/start.sh new file mode 100755 index 0000000..73f0a53 --- /dev/null +++ b/docker-sonic-alpinevs/start.sh @@ -0,0 +1,98 @@ +#!/bin/bash -ex + +ln -sf /usr/share/sonic/device/$PLATFORM /usr/share/sonic/platform +ln -sf /usr/share/sonic/device/$PLATFORM/$HWSKU /usr/share/sonic/hwsku + +SWITCH_TYPE=switch +PLATFORM_CONF=platform.json +export PLATFORM=${PLATFORM:-"x86_64-kvm_x86_64-r0"} + +[ -d /etc/sonic ] || mkdir -p /etc/sonic + +mkdir -p /var/run/redis/sonic-db +cp /etc/default/sonic-db/database_config.json /var/run/redis/sonic-db/ + +# Install Alpine SAI profile for lucius +mkdir -p /etc/sai.d/ +cp /usr/share/sonic/hwsku/sai.profile /etc/sai.d/sai.profile + +SYSTEM_MAC_ADDRESS=$(ip link show eth0 | grep ether | awk '{print $2}') +sonic-cfggen -t /usr/share/sonic/templates/init_cfg.json.j2 -a "{\"system_mac\": \"$SYSTEM_MAC_ADDRESS\", \"switch_type\": \"$SWITCH_TYPE\"}" > /etc/sonic/init_cfg.json + +if [[ -f /usr/share/sonic/virtual_chassis/default_config.json ]]; then + sonic-cfggen -j /etc/sonic/init_cfg.json -j /usr/share/sonic/virtual_chassis/default_config.json --print-data > /tmp/init_cfg.json + mv /tmp/init_cfg.json /etc/sonic/init_cfg.json +fi + +if [ -f /etc/sonic/config_db.json ]; then + # Merge basic system init properties into config_db.json + sonic-cfggen -j /etc/sonic/init_cfg.json -j /etc/sonic/config_db.json --print-data > /tmp/config_db.json + mv /tmp/config_db.json /etc/sonic/config_db.json + echo "Using existing config_db.json" +else + echo "ERROR: /etc/sonic/config_db.json is missing! Cannot initialize system." + exit 1 +fi + +sonic-cfggen -t /usr/share/sonic/templates/copp_cfg_alpinevs.j2 > /etc/sonic/copp_cfg.json + +mkdir -p /etc/swss/config.d/ + +rm -f /var/run/rsyslogd.pid + +supervisorctl start rsyslogd + +supervisord_cfg="/etc/supervisor/conf.d/supervisord.conf" +chassisdb_cfg_file="/usr/share/sonic/virtual_chassis/default_config.json" +chassisdb_cfg_file_default="/etc/default/sonic-db/default_chassis_cfg.json" +host_template="/usr/share/sonic/templates/hostname.j2" +db_cfg_file="/var/run/redis/sonic-db/database_config.json" +db_cfg_file_tmp="/var/run/redis/sonic-db/database_config.json.tmp" + +if [ -r "$chassisdb_cfg_file" ]; then + echo $(sonic-cfggen -j $chassisdb_cfg_file -t $host_template) >> /etc/hosts +else + chassisdb_cfg_file="$chassisdb_cfg_file_default" + echo "10.8.1.200 redis_chassis.server" >> /etc/hosts +fi + +supervisorctl start redis-server + +start_chassis_db=`sonic-cfggen -v DEVICE_METADATA.localhost.start_chassis_db -y $chassisdb_cfg_file` +if [[ "$HOSTNAME" == *"supervisor"* ]] || [ "$start_chassis_db" == "1" ]; then + supervisorctl start redis-chassis +fi + +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 + cp $db_cfg_file $db_cfg_file_tmp + update_chassisdb_config -j $db_cfg_file_tmp -d + cp $db_cfg_file_tmp $db_cfg_file +fi + +/usr/bin/configdb-load.sh + +supervisorctl start syncd +supervisorctl start portsyncd +supervisorctl start orchagent +supervisorctl start coppmgrd +supervisorctl start neighsyncd +supervisorctl start fdbsyncd +supervisorctl start vlanmgrd +supervisorctl start intfmgrd +supervisorctl start buffermgrd +supervisorctl start vrfmgrd +supervisorctl start portmgrd +supervisorctl start nbrmgrd +supervisorctl start vxlanmgrd +supervisorctl start tunnelmgrd +supervisorctl start fabricmgrd +supervisorctl start rebootbackend +supervisorctl start p4rt +supervisorctl start telemetry +supervisorctl start alpine + +VLAN=`sonic-cfggen -d -v 'VLAN.keys() | join(" ") if VLAN'` +if [ "$VLAN" != "" ]; then + supervisorctl start arp_update +fi diff --git a/docker-sonic-alpinevs/supervisord.conf.j2 b/docker-sonic-alpinevs/supervisord.conf.j2 new file mode 100644 index 0000000..572d3b2 --- /dev/null +++ b/docker-sonic-alpinevs/supervisord.conf.j2 @@ -0,0 +1,302 @@ +{% set asan_extra_options = ':print_suppressions=0' %} +[supervisord] +logfile_maxbytes=1MB +logfile_backups=2 +nodaemon=true + +[program:start.sh] +command=/usr/bin/start.sh +priority=1 +autostart=true +autorestart=false +stdout_logfile=NONE +stdout_syslog=true +stderr_logfile=NONE +stderr_syslog=true + +[program:rsyslogd] +command=/usr/sbin/rsyslogd -n +priority=2 +autostart=false +autorestart=false +stdout_logfile=NONE +stdout_syslog=true +stderr_logfile=NONE +stderr_syslog=true + +[program:redis-server] +command=/usr/bin/redis-server /etc/redis/redis.conf +priority=3 +autostart=false +autorestart=false +stdout_logfile=NONE +stdout_syslog=true +stderr_logfile=NONE +stderr_syslog=true + +[program:redis-chassis] +command=/bin/bash -c "{ [[ -s /var/lib/redis_chassis/dump.rdb ]] || rm -f /var/lib/redis_chassis/dump.rdb; } && mkdir -p /var/lib/redis_chassis && exec /usr/bin/redis-server /etc/redis/redis.conf --bind redis_chassis.server --port 6380 --protected-mode no --unixsocket /var/run/redis/redis_chassis.sock --pidfile /var/run/redis/redis_chassis.pid --dir /var/lib/redis_chassis" +priority=3 +autostart=false +autorestart=false +stdout_logfile=NONE +stdout_syslog=true +stderr_logfile=NONE +stderr_syslog=true + +[program:syncd] +command=/usr/bin/syncd_start.sh +priority=4 +autostart=false +autorestart=false +stdout_logfile=NONE +stdout_syslog=true +stderr_logfile=NONE +stderr_syslog=true +{% if ENABLE_ASAN == "y" %} +environment=ASAN_OPTIONS="log_path=/var/log/asan/syncd-asan.log{{ asan_extra_options }}" +{% endif %} + +[program:portsyncd] +command=/usr/bin/portsyncd +priority=5 +autostart=false +autorestart=false +stdout_logfile=NONE +stdout_syslog=true +stderr_logfile=NONE +stderr_syslog=true +{% if ENABLE_ASAN == "y" %} +environment=ASAN_OPTIONS="log_path=/var/log/asan/portsyncd-asan.log{{ asan_extra_options }}" +{% endif %} + +[program:orchagent] +command=/usr/bin/orchagent.sh +priority=6 +autostart=false +autorestart=false +stdout_logfile=NONE +stdout_syslog=true +stderr_logfile=NONE +stderr_syslog=true +{% if ENABLE_ASAN == "y" %} +environment=ASAN_OPTIONS="log_path=/var/log/asan/orchagent-asan.log{{ asan_extra_options }}" +{% endif %} + +[program:coppmgrd] +command=/usr/bin/coppmgrd +priority=7 +autostart=false +autorestart=false +stdout_logfile=NONE +stdout_syslog=true +stderr_logfile=NONE +stderr_syslog=true +{% if ENABLE_ASAN == "y" %} +environment=ASAN_OPTIONS="log_path=/var/log/asan/coppmgrd-asan.log{{ asan_extra_options }}" +{% endif %} + +[program:neighsyncd] +command=/usr/bin/neighsyncd +priority=8 +autostart=false +autorestart=false +stdout_logfile=NONE +stdout_syslog=true +stderr_logfile=NONE +stderr_syslog=true +{% if ENABLE_ASAN == "y" %} +environment=ASAN_OPTIONS="log_path=/var/log/asan/neighsyncd-asan.log{{ asan_extra_options }}" +{% endif %} + +[program:vlanmgrd] +command=/usr/bin/vlanmgrd +priority=10 +autostart=false +autorestart=false +stdout_logfile=NONE +stdout_syslog=true +stderr_logfile=NONE +stderr_syslog=true +{% if ENABLE_ASAN == "y" %} +environment=ASAN_OPTIONS="log_path=/var/log/asan/vlanmgrd-asan.log{{ asan_extra_options }}" +{% endif %} + +[program:intfmgrd] +command=/usr/bin/intfmgrd +priority=11 +autostart=false +autorestart=false +stdout_logfile=NONE +stdout_syslog=true +stderr_logfile=NONE +stderr_syslog=true +{% if ENABLE_ASAN == "y" %} +environment=ASAN_OPTIONS="log_path=/var/log/asan/intfmgrd-asan.log{{ asan_extra_options }}" +{% endif %} + +[program:portmgrd] +command=/usr/bin/portmgrd +priority=12 +autostart=false +autorestart=false +stdout_logfile=NONE +stdout_syslog=true +stderr_logfile=NONE +stderr_syslog=true +{% if ENABLE_ASAN == "y" %} +environment=ASAN_OPTIONS="log_path=/var/log/asan/portmgrd-asan.log{{ asan_extra_options }}" +{% endif %} + +[program:buffermgrd] +command=/usr/bin/buffermgrd.sh +priority=13 +autostart=false +autorestart=false +stdout_logfile=NONE +stdout_syslog=true +stderr_logfile=NONE +stderr_syslog=true +{% if ENABLE_ASAN == "y" %} +environment=ASAN_OPTIONS="log_path=/var/log/asan/buffermgrd-asan.log{{ asan_extra_options }}" +{% endif %} + +[program:vrfmgrd] +command=/usr/bin/vrfmgrd +priority=14 +autostart=false +autorestart=false +stdout_logfile=NONE +stdout_syslog=true +stderr_logfile=NONE +stderr_syslog=true +{% if ENABLE_ASAN == "y" %} +environment=ASAN_OPTIONS="log_path=/var/log/asan/vrfmgrd-asan.log{{ asan_extra_options }}" +{% endif %} + +[program:nbrmgrd] +command=/usr/bin/nbrmgrd +priority=15 +autostart=false +autorestart=false +stdout_logfile=NONE +stdout_syslog=true +stderr_logfile=NONE +stderr_syslog=true +{% if ENABLE_ASAN == "y" %} +environment=ASAN_OPTIONS="log_path=/var/log/asan/nbrmgrd-asan.log{{ asan_extra_options }}" +{% endif %} + +[program:vxlanmgrd] +command=/usr/bin/vxlanmgrd +priority=16 +autostart=false +autorestart=false +stdout_logfile=NONE +stdout_syslog=true +stderr_logfile=NONE +stderr_syslog=true +{% if ENABLE_ASAN == "y" %} +environment=ASAN_OPTIONS="log_path=/var/log/asan/vxlanmgrd-asan.log{{ asan_extra_options }}" +{% endif %} + +[program:tunnelmgrd] +command=/usr/bin/tunnelmgrd +priority=17 +autostart=false +autorestart=false +stdout_logfile=NONE +stdout_syslog=true +stderr_logfile=NONE +stderr_syslog=true +{% if ENABLE_ASAN == "y" %} +environment=ASAN_OPTIONS="log_path=/var/log/asan/tunnelmgrd-asan.log{{ asan_extra_options }}" +{% endif %} + +[program:fabricmgrd] +command=/usr/bin/fabricmgrd +priority=18 +autostart=false +autorestart=false +stdout_logfile=NONE +stdout_syslog=true +stderr_logfile=NONE +stderr_syslog=true +{% if ENABLE_ASAN == "y" %} +environment=ASAN_OPTIONS="log_path=/var/log/asan/fabricmgrd-asan.log{{ asan_extra_options }}" +{% endif %} + +[program:fdbsyncd] +command=/usr/bin/fdbsyncd +priority=19 +autostart=false +autorestart=false +stdout_logfile=NONE +stdout_syslog=true +stderr_logfile=NONE +stderr_syslog=true +{% if ENABLE_ASAN == "y" %} +environment=ASAN_OPTIONS="log_path=/var/log/asan/fdbsyncd-asan.log{{ asan_extra_options }}" +{% endif %} + +[program:rebootbackend] +command=/usr/bin/rebootbackend +priority=20 +autostart=false +autorestart=false +stdout_logfile=NONE +stdout_syslog=true +stderr_logfile=NONE +stderr_syslog=true + +[program:arp_update] +command=/usr/bin/arp_update +priority=21 +autostart=false +autorestart=unexpected +stdout_logfile=NONE +stdout_syslog=true +stderr_logfile=NONE +stderr_syslog=true + +[program:restore_neighbors] +command=/usr/bin/restore_neighbors.py +priority=22 +autostart=false +autorestart=false +startsecs=0 +startretries=0 +stdout_logfile=NONE +stdout_syslog=true +stderr_logfile=NONE +stderr_syslog=true + +[program:telemetry] +command=/usr/bin/telemetry.sh +priority=23 +autostart=false +autorestart=true +stdout_logfile=NONE +stdout_syslog=true +stderr_logfile=NONE +stderr_syslog=true + +[program:p4rt] +command=/usr/bin/p4rt.sh +priority=24 +autostart=false +autorestart=true +stdout_logfile=NONE +stdout_syslog=true +stderr_logfile=NONE +stderr_syslog=true + +[program:alpine] +command=/usr/bin/alpinevs-script.sh +priority=25 +autostart=true +autorestart=false +stdout_logfile=NONE +stdout_syslog=true +stderr_logfile=NONE +stderr_syslog=true diff --git a/docker-sonic-alpinevs/telemetry.sh b/docker-sonic-alpinevs/telemetry.sh new file mode 100755 index 0000000..cb36c99 --- /dev/null +++ b/docker-sonic-alpinevs/telemetry.sh @@ -0,0 +1,133 @@ +#!/usr/bin/env bash + +EXIT_TELEMETRY_VARS_FILE_NOT_FOUND=1 +INCORRECT_TELEMETRY_VALUE=2 +TELEMETRY_VARS_FILE=/usr/share/sonic/templates/telemetry_vars.j2 + +extract_field() { + echo "$(echo "$1" | jq -r "$2")" +} + +if [ ! -f "$TELEMETRY_VARS_FILE" ]; then + echo "Telemetry vars template file not found" + exit $EXIT_TELEMETRY_VARS_FILE_NOT_FOUND +fi + +TELEMETRY_VARS=$(sonic-cfggen -d -t "$TELEMETRY_VARS_FILE") +TELEMETRY_VARS=${TELEMETRY_VARS//[\']/\"} +X509=$(echo "$TELEMETRY_VARS" | jq -r '.x509') +GNMI=$(echo "$TELEMETRY_VARS" | jq -r '.gnmi') +CERTS=$(echo "$TELEMETRY_VARS" | jq -r '.certs') + +export GRPC_GO_LOG_VERBOSITY_LEVEL=99 +export GRPC_GO_LOG_SEVERITY_LEVEL=info +export CVL_SCHEMA_PATH=/usr/sbin/schema +export GOTRACEBACK=crash + +TELEMETRY_ARGS=" -logtostderr" + +if [ -n "$CERTS" ]; then + SERVER_CRT=$(extract_field "$CERTS" '.server_crt') + SERVER_KEY=$(extract_field "$CERTS" '.server_key') + if [ -z "$SERVER_CRT" ] || [ -z "$SERVER_KEY" ]; then + TELEMETRY_ARGS+=" --insecure" + else + TELEMETRY_ARGS+=" --server_crt $SERVER_CRT --server_key $SERVER_KEY" + fi + + CA_CRT=$(extract_field "$CERTS" '.ca_crt') + if [ -n "$CA_CRT" ]; then + TELEMETRY_ARGS+=" --ca_crt $CA_CRT" + fi +elif [ -n "$X509" ]; then + SERVER_CRT=$(extract_field "$X509" '.server_crt') + SERVER_KEY=$(extract_field "$X509" '.server_key') + if [ -z "$SERVER_CRT" ] || [ -z "$SERVER_KEY" ]; then + TELEMETRY_ARGS+=" --insecure" + else + TELEMETRY_ARGS+=" --server_crt $SERVER_CRT --server_key $SERVER_KEY" + fi + + CA_CRT=$(extract_field "$X509" '.ca_crt') + if [ -n "$CA_CRT" ]; then + TELEMETRY_ARGS+=" --ca_crt $CA_CRT" + fi +else + TELEMETRY_ARGS+=" --noTLS" +fi + +if [ -z "$GNMI" ]; then + PORT=8080 +else + PORT=$(extract_field "$GNMI" '.port') + if ! [[ $PORT =~ ^[0-9]+$ ]]; then + echo "Incorrect port value ${PORT}, expecting positive integers" >&2 + exit $INCORRECT_TELEMETRY_VALUE + fi +fi +TELEMETRY_ARGS+=" --port $PORT" + +CLIENT_AUTH=$(extract_field "$GNMI" '.client_auth') +if [ -z "$CLIENT_AUTH" ] || [ "$CLIENT_AUTH" = "false" ]; then + TELEMETRY_ARGS+=" --allow_no_client_auth" +fi + +LOG_LEVEL=$(extract_field "$GNMI" '.log_level') +if [[ $LOG_LEVEL =~ ^[0-9]+$ ]]; then + TELEMETRY_ARGS+=" -v=$LOG_LEVEL" +else + TELEMETRY_ARGS+=" -v=2" +fi + +SAVE_ON_SET=$(echo "$GNMI" | jq -r '.save_on_set // empty') +if [ -n "$SAVE_ON_SET" ]; then + TELEMETRY_ARGS+=" --with-save-on-set=$SAVE_ON_SET" +fi + +THRESHOLD_CONNECTIONS=$(extract_field "$GNMI" '.threshold') +if [[ $THRESHOLD_CONNECTIONS =~ ^[0-9]+$ ]]; then + TELEMETRY_ARGS+=" --threshold $THRESHOLD_CONNECTIONS" +else + if [ -z "$GNMI" ] || [ "$THRESHOLD_CONNECTIONS" = "null" ]; then + TELEMETRY_ARGS+=" --threshold 100" + else + echo "Incorrect threshold value, expecting positive integers" >&2 + exit $INCORRECT_TELEMETRY_VALUE + fi +fi + +IDLE_CONN_DURATION=$(extract_field "$GNMI" '.idle_conn_duration') +if [[ $IDLE_CONN_DURATION =~ ^[0-9]+$ ]]; then + TELEMETRY_ARGS+=" --idle_conn_duration $IDLE_CONN_DURATION" +else + if [ -z "$GNMI" ] || [ "$IDLE_CONN_DURATION" = "null" ]; then + TELEMETRY_ARGS+=" --idle_conn_duration 5" + else + echo "Incorrect idle_conn_duration value, expecting positive integers" >&2 + exit $INCORRECT_TELEMETRY_VALUE + fi +fi + +TELEMETRY_ARGS+=" -gnmi_native_write=false" + +USER_AUTH=$(extract_field "$GNMI" '.user_auth') +if [ -n "$USER_AUTH" ] && [ "$USER_AUTH" != "null" ]; then + TELEMETRY_ARGS+=" --client_auth $USER_AUTH" + + if [ "$USER_AUTH" = "cert" ]; then + TELEMETRY_ARGS+=" --config_table_name GNMI_CLIENT_CERT" + + ENABLE_CRL=$(echo "$GNMI" | jq -r '.enable_crl') + if [ "$ENABLE_CRL" = "true" ]; then + TELEMETRY_ARGS+=" --enable_crl" + fi + + CRL_EXPIRE_DURATION=$(extract_field "$GNMI" '.crl_expire_duration') + if [ -n "$CRL_EXPIRE_DURATION" ] && [ "$CRL_EXPIRE_DURATION" != "null" ]; then + TELEMETRY_ARGS+=" --crl_expire_duration $CRL_EXPIRE_DURATION" + fi + fi +fi + +echo "telemetry args: $TELEMETRY_ARGS" +exec /usr/sbin/telemetry ${TELEMETRY_ARGS} diff --git a/docker-sonic-alpinevs/telemetry_vars.j2 b/docker-sonic-alpinevs/telemetry_vars.j2 new file mode 100644 index 0000000..83c4a1f --- /dev/null +++ b/docker-sonic-alpinevs/telemetry_vars.j2 @@ -0,0 +1,5 @@ +{ + "certs": {% if GNMI %}{% if "certs" in GNMI.keys() %}{{ GNMI["certs"] }}{% else %}""{% endif %}{% else %}""{% endif %}, + "gnmi" : {% if GNMI %}{% if "gnmi" in GNMI.keys() %}{{ GNMI["gnmi"] }}{% else %}""{% endif %}{% else %}""{% endif %}, + "x509" : {% if DEVICE_METADATA %}{% if "x509" in DEVICE_METADATA.keys() %}{{ DEVICE_METADATA["x509"] }}{% else %}""{% endif %}{% else %}""{% endif %} +} diff --git a/docker-sonic-alpinevs/uptime b/docker-sonic-alpinevs/uptime new file mode 100755 index 0000000..a9d813e --- /dev/null +++ b/docker-sonic-alpinevs/uptime @@ -0,0 +1,68 @@ +#!/bin/sh + +# Report container uptime based on PID 1 start time instead of host kernel uptime. + +set -eu + +real_uptime="/usr/bin/uptime" + +ticks_per_second="$(getconf CLK_TCK)" +boot_uptime_seconds="$(cut -d. -f1 /proc/uptime)" +pid1_start_ticks="$(awk '{print $22}' /proc/1/stat)" +pid1_elapsed_seconds=$((boot_uptime_seconds - (pid1_start_ticks / ticks_per_second))) + +if [ "$pid1_elapsed_seconds" -lt 0 ]; then + pid1_elapsed_seconds=0 +fi + +format_pretty() { + total="$1" + days=$((total / 86400)) + hours=$(((total % 86400) / 3600)) + mins=$(((total % 3600) / 60)) + + if [ "$days" -gt 0 ]; then + if [ "$hours" -gt 0 ]; then + echo "up ${days} day$( [ "$days" -ne 1 ] && echo s ), ${hours} hour$( [ "$hours" -ne 1 ] && echo s )" + else + echo "up ${days} day$( [ "$days" -ne 1 ] && echo s )" + fi + elif [ "$hours" -gt 0 ]; then + if [ "$mins" -gt 0 ]; then + echo "up ${hours} hour$( [ "$hours" -ne 1 ] && echo s ), ${mins} minute$( [ "$mins" -ne 1 ] && echo s )" + else + echo "up ${hours} hour$( [ "$hours" -ne 1 ] && echo s )" + fi + else + echo "up ${mins} minute$( [ "$mins" -ne 1 ] && echo s )" + fi +} + +format_clock_uptime() { + total="$1" + days=$((total / 86400)) + hours=$(((total % 86400) / 3600)) + mins=$(((total % 3600) / 60)) + + if [ "$days" -gt 0 ]; then + printf "%d day%s, %2d:%02d" "$days" "$( [ "$days" -ne 1 ] && echo s )" "$hours" "$mins" + elif [ "$hours" -gt 0 ]; then + printf "%2d:%02d" "$hours" "$mins" + else + printf "%d min" "$mins" + fi +} + +case "${1:-}" in + "") + now="$(date '+%H:%M:%S')" + loadavg="$(cut -d' ' -f1-3 /proc/loadavg | sed 's/ /, /g')" + echo " ${now} up $(format_clock_uptime "$pid1_elapsed_seconds"), load average: ${loadavg}" + ;; + -p) + format_pretty "$pid1_elapsed_seconds" + ;; + *) + exec "$real_uptime" "$@" + ;; +esac diff --git a/docker-sonic-alpinevs/zero_profiles.json b/docker-sonic-alpinevs/zero_profiles.json new file mode 100644 index 0000000..7648fec --- /dev/null +++ b/docker-sonic-alpinevs/zero_profiles.json @@ -0,0 +1,57 @@ +[ + { + "BUFFER_POOL_TABLE:ingress_zero_pool": { + "mode": "static", + "type": "ingress", + "size": "0" + }, + "OP": "SET" + }, + { + "BUFFER_PROFILE_TABLE:ingress_lossy_pg_zero_profile" : { + "pool":"ingress_zero_pool", + "size":"0", + "static_th":"0" + }, + "OP": "SET" + }, + { + "BUFFER_PROFILE_TABLE:ingress_lossy_zero_profile" : { + "pool":"ingress_lossless_pool", + "size":"0", + "dynamic_th":"-8" + }, + "OP": "SET" + }, + { + "BUFFER_PROFILE_TABLE:ingress_lossless_zero_profile" : { + "pool":"ingress_lossless_pool", + "size":"0", + "dynamic_th":"-8" + }, + "OP": "SET" + }, + { + "BUFFER_PROFILE_TABLE:egress_lossy_zero_profile" : { + "pool":"egress_lossy_pool", + "size":"0", + "dynamic_th":"-8" + }, + "OP": "SET" + }, + { + "BUFFER_PROFILE_TABLE:egress_lossless_zero_profile" : { + "pool":"egress_lossless_pool", + "size":"0", + "static_th":"0" + }, + "OP": "SET" + }, + { + "control_fields" : { + "pgs_to_apply_zero_profile":"0", + "ingress_zero_profile":"ingress_lossy_pg_zero_profile" + }, + "OP": "SET" + } +] diff --git a/rules.dep b/rules.dep index 35a4252..7087eff 100644 --- a/rules.dep +++ b/rules.dep @@ -1,6 +1,7 @@ include $(PLATFORM_PATH)/syncd-vs.dep include $(PLATFORM_PATH)/sonic-version.dep include $(PLATFORM_PATH)/docker-syncd-vs.dep +include $(PLATFORM_PATH)/docker-sonic-alpinevs.dep include $(PLATFORM_PATH)/one-image.dep include $(PLATFORM_PATH)/onie.dep include $(PLATFORM_PATH)/kvm-image.dep diff --git a/rules.mk b/rules.mk index c97f646..13a7ce7 100644 --- a/rules.mk +++ b/rules.mk @@ -1,6 +1,7 @@ include $(PLATFORM_PATH)/syncd-vs.mk include $(PLATFORM_PATH)/sonic-version.mk include $(PLATFORM_PATH)/docker-syncd-vs.mk +include $(PLATFORM_PATH)/docker-sonic-alpinevs.mk include $(PLATFORM_PATH)/lemmingsai.mk include $(PLATFORM_PATH)/pkt-handler.mk include $(PLATFORM_PATH)/alpine-init.mk @@ -27,4 +28,4 @@ $(SYNCD)_UNINSTALLS += $(LEMMINGSAI) $(ALPINE_INIT)_DEPENDS += $(SONIC_UTILITIES) $(ALPINE_CONFIG)_DEPENDS += $(SONIC_UTILITIES) -SONIC_ALL += $(SONIC_ONE_IMAGE) $(SONIC_KVM_IMAGE) $(SYNCD_VS) $(SONIC_RAW_IMAGE) +SONIC_ALL += $(SONIC_ONE_IMAGE) $(SONIC_KVM_IMAGE) $(SYNCD_VS) $(SONIC_RAW_IMAGE) $(DOCKER_SONIC_ALPINEVS)