Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additions to vs docker to support teamd, bgp and configuring interfaces. #1962

Closed
wants to merge 18 commits into from
Closed
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions files/scripts/configdb-load.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,8 @@ if [ -r /etc/sonic/config_db.json ]; then
sonic-cfggen -j /etc/sonic/config_db.json --write-to-db
fi

if [ -r /etc/sonic/minigraph.xml ]; then
sonic-cfggen -m -H --write-to-db
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[](start = 0, length = 3)

4 spaces

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to move this to vs start.sh before configdb-load.sh, the basic idea is to use minigraph to generate configdb, then here we can do configdb-load.sh

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved.

fi

redis-cli -n 4 SET "CONFIG_DB_INITIALIZED" "1"
7 changes: 7 additions & 0 deletions platform/vs/docker-sonic-vs/Dockerfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,13 @@ COPY ["supervisord.conf", "/etc/supervisor/conf.d/"]
COPY ["files/configdb-load.sh", "/usr/bin/"]
COPY ["files/arp_update", "/usr/bin"]

COPY ["files/image_config/interfaces/interfaces.j2", "/usr/share/sonic/templates/"]
COPY ["files/image_config/asn/deployment_id_asn_map.yml", "/etc/sonic/"]
COPY ["../../../dockers/docker-teamd/teamd.sh", "/usr/bin/"]
COPY ["../../../dockers/docker-teamd/teamd.j2", "/usr/share/sonic/templates/"]
COPY ["../../../dockers/docker-fpm-quagga/bgpcfgd", "/usr/bin/"]
COPY ["../../../dockers/docker-fpm-quagga/*.j2", "/usr/share/sonic/templates/"]

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copied files. Keep them in sync with the latest by adding it to the makefile/rules.mk

RUN echo "docker-sonic-vs" > /etc/hostname
RUN touch /etc/quagga/zebra.conf

Expand Down
100 changes: 98 additions & 2 deletions platform/vs/docker-sonic-vs/start.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
#!/bin/bash -e

# Set correct platform string

HWSKU=$(sonic-cfggen -m -v DEVICE_METADATA.localhost.hwsku)
platform=$(find /usr/share/sonic/device -name $HWSKU | sed 's/.*\(x86.*\)\/.*/\1/')

mkdir -p /host
echo "onie_platform=$platform" > /host/machine.conf

# generate configuration

[ -d /etc/sonic ] || mkdir -p /etc/sonic
Expand Down Expand Up @@ -28,6 +36,17 @@ supervisorctl start redis-server

/usr/bin/configdb-load.sh

# from interfaces-config.sh
# not adding usb0 interface for bfn platform
# to add support for ipv6
sysctl -w net.ipv6.conf.all.disable_ipv6=0
ifdown --force eth0
sonic-cfggen -d -t /usr/share/sonic/templates/interfaces.j2 > /etc/network/interfaces
[ -f /var/run/dhclient.eth0.pid ] && kill `cat /var/run/dhclient.eth0.pid` && rm -f /var/run/dhclient.eth0.pid
service networking restart
ifdown lo && ifup lo
#

supervisorctl start syncd

supervisorctl start orchagent
Expand All @@ -40,13 +59,15 @@ supervisorctl start neighsyncd

supervisorctl start teamsyncd

supervisorctl start fpmsyncd
# started by quagga below
# supervisorctl start fpmsyncd

supervisorctl start intfmgrd

supervisorctl start vlanmgrd

supervisorctl start zebra
# started by quagga below
# supervisorctl start zebra

supervisorctl start buffermgrd

Expand All @@ -55,3 +76,78 @@ VLAN=`sonic-cfggen -d -v 'VLAN.keys() | join(" ") if VLAN'`
if [ "$VLAN" != "" ]; then
supervisorctl start arp_update
fi


# from teamd start.sh

TEAMD_CONF_PATH=/etc/teamd

rm -rf $TEAMD_CONF_PATH
mkdir -p $TEAMD_CONF_PATH

SONIC_ASIC_TYPE=$(sonic-cfggen -y /etc/sonic/sonic_version.yml -v asic_type)

if [ "$SONIC_ASIC_TYPE" == "mellanox" ]; then
MAC_ADDRESS=$(sonic-cfggen -d -v DEVICE_METADATA.localhost.mac)
else
MAC_ADDRESS=$(ip link show eth0 | grep ether | awk '{print $2}')
fi

# Align last byte
if [ "$SONIC_ASIC_TYPE" == "mellanox" -o "$SONIC_ASIC_TYPE" == "centec" ]; then
last_byte=$(python -c "print '$MAC_ADDRESS'[-2:]")
aligned_last_byte=$(python -c "print format(int(int('$last_byte', 16) & 0b11000000), '02x')") # put mask and take away the 0x prefix
MAC_ADDRESS=$(python -c "print '$MAC_ADDRESS'[:-2] + '$aligned_last_byte'") # put aligned byte into the end of MAC
fi

for pc in `sonic-cfggen -d -v "PORTCHANNEL.keys() | join(' ') if PORTCHANNEL"`; do
sonic-cfggen -d -a '{"pc":"'$pc'","hwaddr":"'$MAC_ADDRESS'"}' -t /usr/share/sonic/templates/teamd.j2 > $TEAMD_CONF_PATH/$pc.conf
# bring down all member ports before starting teamd
for member in $(sonic-cfggen -d -v "PORTCHANNEL['$pc']['members'] | join(' ')" ); do
if [ -L /sys/class/net/$member ]; then
ip link set $member down
fi
done
done

mkdir -p /var/sonic
echo "# Config files managed by sonic-config-engine" > /var/sonic/config_status

#rsyslog already included above
#rm -f /var/run/rsyslogd.pid
#supervisorctl start rsyslogd

supervisorctl start teamd
#

# from quagga start.sh
mkdir -p /etc/quagga
sonic-cfggen -d -y /etc/sonic/deployment_id_asn_map.yml -t /usr/share/sonic/templates/bgpd.conf.j2 > /etc/quagga/bgpd.conf
sonic-cfggen -d -t /usr/share/sonic/templates/zebra.conf.j2 > /etc/quagga/zebra.conf

sonic-cfggen -d -t /usr/share/sonic/templates/isolate.j2 > /usr/sbin/bgp-isolate
chown root:root /usr/sbin/bgp-isolate
chmod 0755 /usr/sbin/bgp-isolate

sonic-cfggen -d -t /usr/share/sonic/templates/unisolate.j2 > /usr/sbin/bgp-unisolate
chown root:root /usr/sbin/bgp-unisolate
chmod 0755 /usr/sbin/bgp-unisolate

mkdir -p /var/sonic
echo "# Config files managed by sonic-config-engine" > /var/sonic/config_status

# rm -f /var/run/rsyslogd.pid

supervisorctl start bgpcfgd

# started already
# supervisorctl start rsyslogd

# Start Quagga processes

supervisorctl start zebra

supervisorctl start bgpd

supervisorctl start fpmsyncd

17 changes: 17 additions & 0 deletions platform/vs/docker-sonic-vs/supervisord.conf
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,20 @@ autostart=false
autorestart=false
stdout_logfile=syslog
stderr_logfile=syslog

[program:bgpcfgd]
command=/usr/bin/bgpcfgd
priority=2
autostart=false
autorestart=false
startsecs=0
stdout_logfile=syslog
stderr_logfile=syslog

[program:teamd]
command=/usr/bin/teamd.sh
priority=3
autostart=false
autorestart=false
stdout_logfile=syslog
stderr_logfile=syslog