[virtualswitch]: build docker-sonic-vs docker based on SAI virtual switch (#1065)

This commit is contained in:
lguohan 2017-10-23 22:01:42 -07:00 committed by GitHub
parent a49ac2d211
commit f073d8c654
16 changed files with 404 additions and 3 deletions

17
platform/vs/README.md Normal file
View File

@ -0,0 +1,17 @@
HOWTO Use Virtual Switch
1. Create a docker with 32 front panel port
```
docker run -id --name sw debian bash
sudo ./create_vnet.sh sw
```
2. Create sonic virtual switch docker
```
docker run --privileged --network container:sw -d docker-sonic-vs
```
3. Run test in virtual switch docker (TBD)

38
platform/vs/create_vnet.sh Executable file
View File

@ -0,0 +1,38 @@
#!/bin/bash
SWNAME=$1
pid=$(docker inspect --format '{{.State.Pid}}' $SWNAME)
echo Seting up servers
SERVERS=31
for srv in `seq 0 $SERVERS`; do
SRV="$SWNAME-srv$srv"
NSS="ip netns exec $SRV"
ip netns add $SRV
$NSS ip addr add 127.0.0.1/8 dev lo
$NSS ip addr add ::1/128 dev lo
$NSS ip link set dev lo up
# add virtual link between neighbor and the virtual switch docker
IF="vEthernet$((srv*4))"
ip link add ${SRV}eth0 type veth peer name $IF
ip link set ${SRV}eth0 netns $SRV
ip link set $IF netns ${pid}
echo "Bring ${SRV}eth0 up"
$NSS ip link set dev ${SRV}eth0 name eth0
$NSS ip link set dev eth0 up
echo "Bring $IF up in the virtual switch docker"
nsenter -t $pid -n ip link set dev $IF up
done

View File

@ -0,0 +1,16 @@
# docker image for virtual switch based sonic docker image
DOCKER_SONIC_VS = docker-sonic-vs.gz
$(DOCKER_SONIC_VS)_PATH = $(PLATFORM_PATH)/docker-sonic-vs
$(DOCKER_SONIC_VS)_DEPENDS += $(SWSS) $(SYNCD_VS) $(REDIS_SERVER) $(REDIS_TOOLS) $(LIBTEAMDCT) $(LIBTEAM_UTILS) $(SONIC_DEVICE_DATA)
ifeq ($(SONIC_ROUTING_STACK), quagga)
$(DOCKER_SONIC_VS)_DEPENDS += $(QUAGGA)
else ifeq ($(SONIC_ROUTING_STACK), frr)
$(DOCKER_SONIC_VS)_DEPENDS += $(FRR)
else
$(DOCKER_SONIC_VS)_DEPENDS += $(GOBGP)
endif
$(DOCKER_SONIC_VS)_LOAD_DOCKERS += $(DOCKER_CONFIG_ENGINE)
SONIC_DOCKER_IMAGES += $(DOCKER_SONIC_VS)

View File

@ -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

View File

@ -0,0 +1,51 @@
FROM docker-config-engine
## Make apt-get non-interactive
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update
RUN apt-get install -y net-tools \
ethtool \
tcpdump \
ifupdown \
bridge-utils \
python-ply \
libqt5core5a \
libqt5network5 \
libboost-program-options1.55.0 \
libboost-system1.55.0 \
libboost-thread1.55.0 \
libgmp10 \
libjudydebian1 \
libnanomsg0 \
libdaemon0 \
libjansson4 \
libjemalloc1 \
openssh-client \
openssh-server \
libc-ares2 \
iproute
COPY \
debs/libnl-route-3-200_3.2.27-1_amd64.deb debs/libnl-genl-3-200_3.2.27-1_amd64.deb debs/libnl-nf-3-200_3.2.27-1_amd64.deb debs/libhiredis0.13_0.13.3-2_amd64.deb debs/libnl-3-200_3.2.27-1_amd64.deb debs/libnl-cli-3-200_3.2.27-1_amd64.deb debs/libswsscommon_1.0.0_amd64.deb debs/libsairedis_1.0.0_amd64.deb debs/libsaimetadata_1.0.0_amd64.deb debs/libteam5_1.26-1_amd64.deb debs/libsaivs_1.0.0_amd64.deb debs/swss_1.0.0_amd64.deb debs/syncd-vs_1.0.0_amd64.deb debs/redis-server_3.2.4-1~bpo8+1_amd64.deb debs/redis-tools_3.2.4-1~bpo8+1_amd64.deb debs/libteamdctl0_1.26-1_amd64.deb debs/libteam-utils_1.26-1_amd64.deb debs/sonic-device-data_1.0-1_all.deb debs/quagga_0.99.24.1-2.1_amd64.deb debs/
RUN dpkg -i \
debs/libnl-route-3-200_3.2.27-1_amd64.deb debs/libnl-genl-3-200_3.2.27-1_amd64.deb debs/libnl-nf-3-200_3.2.27-1_amd64.deb debs/libhiredis0.13_0.13.3-2_amd64.deb debs/libnl-3-200_3.2.27-1_amd64.deb debs/libnl-cli-3-200_3.2.27-1_amd64.deb debs/libswsscommon_1.0.0_amd64.deb debs/libsairedis_1.0.0_amd64.deb debs/libsaimetadata_1.0.0_amd64.deb debs/libteam5_1.26-1_amd64.deb debs/libsaivs_1.0.0_amd64.deb debs/swss_1.0.0_amd64.deb debs/syncd-vs_1.0.0_amd64.deb debs/redis-server_3.2.4-1~bpo8+1_amd64.deb debs/redis-tools_3.2.4-1~bpo8+1_amd64.deb debs/libteamdctl0_1.26-1_amd64.deb debs/libteam-utils_1.26-1_amd64.deb debs/sonic-device-data_1.0-1_all.deb debs/quagga_0.99.24.1-2.1_amd64.deb
## Clean up
RUN apt-get clean -y; apt-get autoclean -y; apt-get autoremove -y
RUN rm -rf /debs
RUN sed -ri 's/^daemonize yes$/daemonize no/; \
s/^logfile .*$/logfile ""/; \
s/^# syslog-enabled no$/syslog-enabled no/; \
s/^# unixsocket/unixsocket/ \
' /etc/redis/redis.conf
COPY ["50-default.conf", "/etc/rsyslog.d/"]
COPY ["start.sh", "orchagent.sh", "/usr/bin/"]
COPY ["brcm.profile.ini", "/usr/share/sonic/device/vswitch/"]
COPY ["supervisord.conf", "/etc/supervisor/conf.d/"]
ENTRYPOINT ["/usr/bin/supervisord"]

View File

@ -0,0 +1,56 @@
FROM docker-config-engine
## Make apt-get non-interactive
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update
RUN apt-get install -y net-tools \
ethtool \
tcpdump \
ifupdown \
bridge-utils \
python-ply \
libqt5core5a \
libqt5network5 \
libboost-program-options1.55.0 \
libboost-system1.55.0 \
libboost-thread1.55.0 \
libgmp10 \
libjudydebian1 \
libnanomsg0 \
libdaemon0 \
libjansson4 \
libjemalloc1 \
openssh-client \
openssh-server \
libc-ares2 \
iproute
COPY \
{% for deb in docker_sonic_vs_debs.split(' ') -%}
debs/{{ deb }}{{' '}}
{%- endfor -%}
debs/
RUN dpkg -i \
{% for deb in docker_sonic_vs_debs.split(' ') -%}
debs/{{ deb }}{{' '}}
{%- endfor %}
## Clean up
RUN apt-get clean -y; apt-get autoclean -y; apt-get autoremove -y
RUN rm -rf /debs
RUN sed -ri 's/^daemonize yes$/daemonize no/; \
s/^logfile .*$/logfile ""/; \
s/^# syslog-enabled no$/syslog-enabled no/; \
s/^# unixsocket/unixsocket/ \
' /etc/redis/redis.conf
COPY ["50-default.conf", "/etc/rsyslog.d/"]
COPY ["start.sh", "orchagent.sh", "/usr/bin/"]
COPY ["brcm.profile.ini", "/usr/share/sonic/device/vswitch/"]
COPY ["supervisord.conf", "/etc/supervisor/conf.d/"]
ENTRYPOINT ["/usr/bin/supervisord"]

View File

@ -0,0 +1,4 @@
SAI_WARM_BOOT_READ_FILE=/var/cache/sai_warmboot.bin
SAI_WARM_BOOT_WRITE_FILE=/var/cache/sai_warmboot.bin
SAI_VS_SWITCH_TYPE=SAI_VS_SWITCH_TYPE_BCM56850
SAI_VS_HOSTIF_USE_TAP_DEVICE=true

View File

@ -0,0 +1,15 @@
#!/usr/bin/env bash
MAC_ADDRESS=`ip link show eth0 | grep ether | awk '{print $2}'`
# Create a folder for SsWW record files
mkdir -p /var/log/swss
ORCHAGENT_ARGS="-d /var/log/swss "
# Set orchagent pop batch size to 8192
ORCHAGENT_ARGS+="-b 8192 "
# Set mac address
ORCHAGENT_ARGS+="-m $MAC_ADDRESS"
exec /usr/bin/orchagent ${ORCHAGENT_ARGS}

View File

@ -0,0 +1,33 @@
#!/usr/bin/env bash
mkdir -p /etc/swss/config.d/
# sonic-cfggen -m /etc/sonic/minigraph.xml -d -t /usr/share/sonic/templates/ipinip.json.j2 > /etc/swss/config.d/ipinip.json
# sonic-cfggen -m /etc/sonic/minigraph.xml -d -t /usr/share/sonic/templates/mirror.json.j2 > /etc/swss/config.d/mirror.json
# sonic-cfggen -m /etc/sonic/minigraph.xml -d -t /usr/share/sonic/templates/ports.json.j2 > /etc/swss/config.d/ports.json
# export platform=`sonic-cfggen -v platform`
rm -f /var/run/rsyslogd.pid
supervisorctl start rsyslogd
mkdir -p /var/run/redis
supervisorctl start redis-server
supervisorctl start syncd
supervisorctl start orchagent
supervisorctl start portsyncd
supervisorctl start intfsyncd
supervisorctl start neighsyncd
# Start arp_update when VLAN exists
# VLAN=`sonic-cfggen -d -v 'VLAN.keys() | join(" ") if VLAN'`
# if [ "$VLAN" != "" ]; then
# supervisorctl start arp_update
# fi

View File

@ -0,0 +1,68 @@
[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=syslog
stderr_logfile=syslog
[program:rsyslogd]
command=/usr/sbin/rsyslogd -n
priority=2
autostart=false
autorestart=false
stdout_logfile=syslog
stderr_logfile=syslog
[program:redis-server]
command=/usr/bin/redis-server /etc/redis/redis.conf
priority=3
autostart=false
autorestart=false
stdout_logfile=syslog
stderr_logfile=syslog
[program:syncd]
command=/usr/bin/syncd -uN -p /usr/share/sonic/device/vswitch/brcm.profile.ini
priority=4
autostart=false
autorestart=false
stdout_logfile=syslog
stderr_logfile=syslog
[program:orchagent]
command=/usr/bin/orchagent.sh
priority=5
autostart=false
autorestart=false
stdout_logfile=syslog
stderr_logfile=syslog
[program:portsyncd]
command=/usr/bin/portsyncd -p /usr/share/sonic/device/x86_64-dell_s6000_s1220-r0/Force10-S6000/port_config.ini
priority=6
autostart=false
autorestart=false
stdout_logfile=syslog
stderr_logfile=syslog
[program:intfsyncd]
command=/usr/bin/intfsyncd
priority=7
autostart=false
autorestart=false
stdout_logfile=syslog
stderr_logfile=syslog
[program:neighsyncd]
command=/usr/bin/neighsyncd
priority=8
autostart=false
autorestart=false
stdout_logfile=syslog
stderr_logfile=syslog

4
platform/vs/rules.mk Normal file
View File

@ -0,0 +1,4 @@
include $(PLATFORM_PATH)/syncd-vs.mk
include $(PLATFORM_PATH)/docker-sonic-vs.mk
SONIC_ALL += $(DOCKER_SONIC_VS)

13
platform/vs/syncd-vs.mk Normal file
View File

@ -0,0 +1,13 @@
$(LIBSAIREDIS)_DPKG_TARGET = binary-syncd-vs
# inject libsaivs and libsaivs_dev to swss build dependency
$(SWSS)_DEPENDS += $(LIBSAIVS) $(LIBSAIVS_DEV)
SYNCD_VS = syncd-vs_1.0.0_amd64.deb
$(SYNCD_VS)_RDEPENDS += $(LIBSAIREDIS) $(LIBSAIMETADATA) $(LIBSAIVS)
$(eval $(call add_derived_package,$(LIBSAIREDIS),$(SYNCD_VS)))
SYNCD_VS_DBG = syncd-vs-dbg_1.0.0_amd64.deb
$(SYNCD_VS_DBG)_DEPENDS += $(SYNCD_VS)
$(SYNCD_VS_DBG)_RDEPENDS += $(SYNCD_VS)
$(eval $(call add_derived_package,$(LIBSAIREDIS),$(SYNCD_VS_DBG)))

View File

@ -9,6 +9,13 @@ SONIC_DPKG_DEBS += $(LIBSAIREDIS)
LIBSAIREDIS_DEV = libsairedis-dev_1.0.0_amd64.deb LIBSAIREDIS_DEV = libsairedis-dev_1.0.0_amd64.deb
$(eval $(call add_derived_package,$(LIBSAIREDIS),$(LIBSAIREDIS_DEV))) $(eval $(call add_derived_package,$(LIBSAIREDIS),$(LIBSAIREDIS_DEV)))
LIBSAIVS = libsaivs_1.0.0_amd64.deb
$(eval $(call add_derived_package,$(LIBSAIREDIS),$(LIBSAIVS)))
LIBSAIVS_DEV = libsaivs-dev_1.0.0_amd64.deb
$(eval $(call add_derived_package,$(LIBSAIREDIS),$(LIBSAIVS_DEV)))
ifneq ($(CONFIGURED_PLATFORM),vs)
SYNCD = syncd_1.0.0_amd64.deb SYNCD = syncd_1.0.0_amd64.deb
$(SYNCD)_RDEPENDS += $(LIBSAIREDIS) $(LIBSAIMETADATA) $(SYNCD)_RDEPENDS += $(LIBSAIREDIS) $(LIBSAIMETADATA)
$(eval $(call add_derived_package,$(LIBSAIREDIS),$(SYNCD))) $(eval $(call add_derived_package,$(LIBSAIREDIS),$(SYNCD)))
@ -16,6 +23,7 @@ $(eval $(call add_derived_package,$(LIBSAIREDIS),$(SYNCD)))
SYNCD_RPC = syncd-rpc_1.0.0_amd64.deb SYNCD_RPC = syncd-rpc_1.0.0_amd64.deb
$(SYNCD_RPC)_RDEPENDS += $(LIBSAIREDIS) $(LIBSAIMETADATA) $(SYNCD_RPC)_RDEPENDS += $(LIBSAIREDIS) $(LIBSAIMETADATA)
$(eval $(call add_derived_package,$(LIBSAIREDIS),$(SYNCD_RPC))) $(eval $(call add_derived_package,$(LIBSAIREDIS),$(SYNCD_RPC)))
endif
LIBSAIMETADATA = libsaimetadata_1.0.0_amd64.deb LIBSAIMETADATA = libsaimetadata_1.0.0_amd64.deb
$(eval $(call add_derived_package,$(LIBSAIREDIS),$(LIBSAIMETADATA))) $(eval $(call add_derived_package,$(LIBSAIREDIS),$(LIBSAIMETADATA)))
@ -29,6 +37,12 @@ $(LIBSAIREDIS_DBG)_DEPENDS += $(LIBSAIREDIS)
$(LIBSAIREDIS_DBG)_RDEPENDS += $(LIBSAIREDIS) $(LIBSAIREDIS_DBG)_RDEPENDS += $(LIBSAIREDIS)
$(eval $(call add_derived_package,$(LIBSAIREDIS),$(LIBSAIREDIS_DBG))) $(eval $(call add_derived_package,$(LIBSAIREDIS),$(LIBSAIREDIS_DBG)))
LIBSAIVS_DBG = libsaivs-dbg_1.0.0_amd64.deb
$(LIBSAIVS_DBG)_DEPENDS += $(LIBSAIVS)
$(LIBSAIVS_DBG)_RDEPENDS += $(LIBSAIVS)
$(eval $(call add_derived_package,$(LIBSAIREDIS),$(LIBSAIVS_DBG)))
ifneq ($(CONFIGURED_PLATFORM),vs)
SYNCD_DBG = syncd-dbg_1.0.0_amd64.deb SYNCD_DBG = syncd-dbg_1.0.0_amd64.deb
$(SYNCD_DBG)_DEPENDS += $(SYNCD) $(SYNCD_DBG)_DEPENDS += $(SYNCD)
$(SYNCD_DBG)_RDEPENDS += $(SYNCD) $(SYNCD_DBG)_RDEPENDS += $(SYNCD)
@ -38,6 +52,7 @@ SYNCD_RPC_DBG = syncd-rpc-dbg_1.0.0_amd64.deb
$(SYNCD_RPC_DBG)_DEPENDS += $(SYNCD_RPC) $(SYNCD_RPC_DBG)_DEPENDS += $(SYNCD_RPC)
$(SYNCD_RPC_DBG)_RDEPENDS += $(SYNCD_RPC) $(SYNCD_RPC_DBG)_RDEPENDS += $(SYNCD_RPC)
$(eval $(call add_derived_package,$(LIBSAIREDIS),$(SYNCD_RPC_DBG))) $(eval $(call add_derived_package,$(LIBSAIREDIS),$(SYNCD_RPC_DBG)))
endif
LIBSAIMETADATA_DBG = libsaimetadata-dbg_1.0.0_amd64.deb LIBSAIMETADATA_DBG = libsaimetadata-dbg_1.0.0_amd64.deb
$(LIBSAIMETADATA_DBG)_DEPENDS += $(LIBSAIMETADATA) $(LIBSAIMETADATA_DBG)_DEPENDS += $(LIBSAIMETADATA)

View File

@ -203,7 +203,10 @@ $(addprefix $(DEBS_PATH)/, $(SONIC_DPKG_DEBS)) : $(DEBS_PATH)/% : .platform $$(a
# Build project # Build project
pushd $($*_SRC_PATH) $(LOG) pushd $($*_SRC_PATH) $(LOG)
[ ! -f ./autogen.sh ] || ./autogen.sh $(LOG) [ ! -f ./autogen.sh ] || ./autogen.sh $(LOG)
$(if $($*_DPKG_TARGET),
dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) --as-root -T$($*_DPKG_TARGET) $(LOG),
dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) $(LOG) dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) $(LOG)
)
popd $(LOG) popd $(LOG)
# Clean up # Clean up
if [ -f $($*_SRC_PATH).patch/series ]; then pushd $($*_SRC_PATH) && quilt pop -a -f; popd; fi if [ -f $($*_SRC_PATH).patch/series ]; then pushd $($*_SRC_PATH) && quilt pop -a -f; popd; fi

@ -1 +1 @@
Subproject commit e4d24276cb6fc7122f756c637f30ddea27487c70 Subproject commit f5d9c8364f5fbcc487a5f1a3e3e6203ab2293a83

@ -1 +1 @@
Subproject commit bcdea1323e70c73fa0a85c6df55eaed886bded81 Subproject commit e07d86b100ccefe8b51e2c41b543cc93f33a0f13