Multi-ASIC implementation (#3888)
Changes made to support multi-asic platform. Added multi-instance support for swss, syncd, database, bgp, teamd and lldp.
This commit is contained in:
parent
2c97321545
commit
4b8067e913
@ -0,0 +1,32 @@
|
|||||||
|
eth1:25,26,27,28
|
||||||
|
eth2:29,30,31,32
|
||||||
|
eth3:33,34,35,36
|
||||||
|
eth4:37,38,39,40
|
||||||
|
eth5:45,46,47,48
|
||||||
|
eth6:41,42,43,44
|
||||||
|
eth7:1,2,3,4
|
||||||
|
eth8:5,6,7,8
|
||||||
|
eth9:13,14,15,16
|
||||||
|
eth10:9,10,11,12
|
||||||
|
eth11:17,18,19,20
|
||||||
|
eth12:21,22,23,24
|
||||||
|
eth13:53,54,55,56
|
||||||
|
eth14:49,50,51,52
|
||||||
|
eth15:57,58,59,60
|
||||||
|
eth16:61,62,63,64
|
||||||
|
eth17:69,70,71,72
|
||||||
|
eth18:65,66,67,68
|
||||||
|
eth19:73,74,75,76
|
||||||
|
eth20:77,78,79,80
|
||||||
|
eth21:109,110,111,112
|
||||||
|
eth22:105,106,107,108
|
||||||
|
eth23:113,114,115,116
|
||||||
|
eth24:117,118,119,120
|
||||||
|
eth25:125,126,127,128
|
||||||
|
eth26:121,122,123,124
|
||||||
|
eth27:81,82,83,84
|
||||||
|
eth28:85,86,87,88
|
||||||
|
eth29:93,94,95,96
|
||||||
|
eth30:89,90,91,92
|
||||||
|
eth31:101,102,103,104
|
||||||
|
eth32:97,98,99,100
|
@ -1,2 +1,5 @@
|
|||||||
SAI_INIT_CONFIG_FILE=/usr/share/sonic/hwsku/td2-s6000-32x40G.config.bcm
|
SAI_WARM_BOOT_READ_FILE=/var/cache/sai_warmboot.bin
|
||||||
SAI_NUM_ECMP_MEMBERS=32
|
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
|
||||||
|
SAI_VS_INTERFACE_LANE_MAP_FILE=/usr/share/sonic/hwsku/lanemap.ini
|
||||||
|
@ -0,0 +1,32 @@
|
|||||||
|
eth1:25,26,27,28
|
||||||
|
eth2:29,30,31,32
|
||||||
|
eth3:33,34,35,36
|
||||||
|
eth4:37,38,39,40
|
||||||
|
eth5:45,46,47,48
|
||||||
|
eth6:41,42,43,44
|
||||||
|
eth7:1,2,3,4
|
||||||
|
eth8:5,6,7,8
|
||||||
|
eth9:13,14,15,16
|
||||||
|
eth10:9,10,11,12
|
||||||
|
eth11:17,18,19,20
|
||||||
|
eth12:21,22,23,24
|
||||||
|
eth13:53,54,55,56
|
||||||
|
eth14:49,50,51,52
|
||||||
|
eth15:57,58,59,60
|
||||||
|
eth16:61,62,63,64
|
||||||
|
eth17:69,70,71,72
|
||||||
|
eth18:65,66,67,68
|
||||||
|
eth19:73,74,75,76
|
||||||
|
eth20:77,78,79,80
|
||||||
|
eth21:109,110,111,112
|
||||||
|
eth22:105,106,107,108
|
||||||
|
eth23:113,114,115,116
|
||||||
|
eth24:117,118,119,120
|
||||||
|
eth25:125,126,127,128
|
||||||
|
eth26:121,122,123,124
|
||||||
|
eth27:81,82,83,84
|
||||||
|
eth28:85,86,87,88
|
||||||
|
eth29:93,94,95,96
|
||||||
|
eth30:89,90,91,92
|
||||||
|
eth31:101,102,103,104
|
||||||
|
eth32:97,98,99,100
|
@ -1,2 +1,5 @@
|
|||||||
SAI_INIT_CONFIG_FILE=/usr/share/sonic/hwsku/td2-s6000-32x40G.config.bcm
|
SAI_WARM_BOOT_READ_FILE=/var/cache/sai_warmboot.bin
|
||||||
SAI_NUM_ECMP_MEMBERS=32
|
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
|
||||||
|
SAI_VS_INTERFACE_LANE_MAP_FILE=/usr/share/sonic/hwsku/lanemap.ini
|
||||||
|
@ -0,0 +1,32 @@
|
|||||||
|
eth1:25,26,27,28
|
||||||
|
eth2:29,30,31,32
|
||||||
|
eth3:33,34,35,36
|
||||||
|
eth4:37,38,39,40
|
||||||
|
eth5:45,46,47,48
|
||||||
|
eth6:41,42,43,44
|
||||||
|
eth7:1,2,3,4
|
||||||
|
eth8:5,6,7,8
|
||||||
|
eth9:13,14,15,16
|
||||||
|
eth10:9,10,11,12
|
||||||
|
eth11:17,18,19,20
|
||||||
|
eth12:21,22,23,24
|
||||||
|
eth13:53,54,55,56
|
||||||
|
eth14:49,50,51,52
|
||||||
|
eth15:57,58,59,60
|
||||||
|
eth16:61,62,63,64
|
||||||
|
eth17:69,70,71,72
|
||||||
|
eth18:65,66,67,68
|
||||||
|
eth19:73,74,75,76
|
||||||
|
eth20:77,78,79,80
|
||||||
|
eth21:109,110,111,112
|
||||||
|
eth22:105,106,107,108
|
||||||
|
eth23:113,114,115,116
|
||||||
|
eth24:117,118,119,120
|
||||||
|
eth25:125,126,127,128
|
||||||
|
eth26:121,122,123,124
|
||||||
|
eth27:81,82,83,84
|
||||||
|
eth28:85,86,87,88
|
||||||
|
eth29:93,94,95,96
|
||||||
|
eth30:89,90,91,92
|
||||||
|
eth31:101,102,103,104
|
||||||
|
eth32:97,98,99,100
|
@ -1,2 +1,5 @@
|
|||||||
SAI_INIT_CONFIG_FILE=/usr/share/sonic/hwsku/td2-s6000-32x40G.config.bcm
|
SAI_WARM_BOOT_READ_FILE=/var/cache/sai_warmboot.bin
|
||||||
SAI_NUM_ECMP_MEMBERS=32
|
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
|
||||||
|
SAI_VS_INTERFACE_LANE_MAP_FILE=/usr/share/sonic/hwsku/lanemap.ini
|
||||||
|
@ -0,0 +1,32 @@
|
|||||||
|
eth1:25,26,27,28
|
||||||
|
eth2:29,30,31,32
|
||||||
|
eth3:33,34,35,36
|
||||||
|
eth4:37,38,39,40
|
||||||
|
eth5:45,46,47,48
|
||||||
|
eth6:41,42,43,44
|
||||||
|
eth7:1,2,3,4
|
||||||
|
eth8:5,6,7,8
|
||||||
|
eth9:13,14,15,16
|
||||||
|
eth10:9,10,11,12
|
||||||
|
eth11:17,18,19,20
|
||||||
|
eth12:21,22,23,24
|
||||||
|
eth13:53,54,55,56
|
||||||
|
eth14:49,50,51,52
|
||||||
|
eth15:57,58,59,60
|
||||||
|
eth16:61,62,63,64
|
||||||
|
eth17:69,70,71,72
|
||||||
|
eth18:65,66,67,68
|
||||||
|
eth19:73,74,75,76
|
||||||
|
eth20:77,78,79,80
|
||||||
|
eth21:109,110,111,112
|
||||||
|
eth22:105,106,107,108
|
||||||
|
eth23:113,114,115,116
|
||||||
|
eth24:117,118,119,120
|
||||||
|
eth25:125,126,127,128
|
||||||
|
eth26:121,122,123,124
|
||||||
|
eth27:81,82,83,84
|
||||||
|
eth28:85,86,87,88
|
||||||
|
eth29:93,94,95,96
|
||||||
|
eth30:89,90,91,92
|
||||||
|
eth31:101,102,103,104
|
||||||
|
eth32:97,98,99,100
|
@ -1,2 +1,5 @@
|
|||||||
SAI_INIT_CONFIG_FILE=/usr/share/sonic/hwsku/td2-s6000-32x40G.config.bcm
|
SAI_WARM_BOOT_READ_FILE=/var/cache/sai_warmboot.bin
|
||||||
SAI_NUM_ECMP_MEMBERS=32
|
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
|
||||||
|
SAI_VS_INTERFACE_LANE_MAP_FILE=/usr/share/sonic/hwsku/lanemap.ini
|
||||||
|
@ -0,0 +1,32 @@
|
|||||||
|
eth1:25,26,27,28
|
||||||
|
eth2:29,30,31,32
|
||||||
|
eth3:33,34,35,36
|
||||||
|
eth4:37,38,39,40
|
||||||
|
eth5:45,46,47,48
|
||||||
|
eth6:41,42,43,44
|
||||||
|
eth7:1,2,3,4
|
||||||
|
eth8:5,6,7,8
|
||||||
|
eth9:13,14,15,16
|
||||||
|
eth10:9,10,11,12
|
||||||
|
eth11:17,18,19,20
|
||||||
|
eth12:21,22,23,24
|
||||||
|
eth13:53,54,55,56
|
||||||
|
eth14:49,50,51,52
|
||||||
|
eth15:57,58,59,60
|
||||||
|
eth16:61,62,63,64
|
||||||
|
eth17:69,70,71,72
|
||||||
|
eth18:65,66,67,68
|
||||||
|
eth19:73,74,75,76
|
||||||
|
eth20:77,78,79,80
|
||||||
|
eth21:109,110,111,112
|
||||||
|
eth22:105,106,107,108
|
||||||
|
eth23:113,114,115,116
|
||||||
|
eth24:117,118,119,120
|
||||||
|
eth25:125,126,127,128
|
||||||
|
eth26:121,122,123,124
|
||||||
|
eth27:81,82,83,84
|
||||||
|
eth28:85,86,87,88
|
||||||
|
eth29:93,94,95,96
|
||||||
|
eth30:89,90,91,92
|
||||||
|
eth31:101,102,103,104
|
||||||
|
eth32:97,98,99,100
|
@ -1,2 +1,5 @@
|
|||||||
SAI_INIT_CONFIG_FILE=/usr/share/sonic/hwsku/td2-s6000-32x40G.config.bcm
|
SAI_WARM_BOOT_READ_FILE=/var/cache/sai_warmboot.bin
|
||||||
SAI_NUM_ECMP_MEMBERS=32
|
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
|
||||||
|
SAI_VS_INTERFACE_LANE_MAP_FILE=/usr/share/sonic/hwsku/lanemap.ini
|
||||||
|
@ -0,0 +1,32 @@
|
|||||||
|
eth1:25,26,27,28
|
||||||
|
eth2:29,30,31,32
|
||||||
|
eth3:33,34,35,36
|
||||||
|
eth4:37,38,39,40
|
||||||
|
eth5:45,46,47,48
|
||||||
|
eth6:41,42,43,44
|
||||||
|
eth7:1,2,3,4
|
||||||
|
eth8:5,6,7,8
|
||||||
|
eth9:13,14,15,16
|
||||||
|
eth10:9,10,11,12
|
||||||
|
eth11:17,18,19,20
|
||||||
|
eth12:21,22,23,24
|
||||||
|
eth13:53,54,55,56
|
||||||
|
eth14:49,50,51,52
|
||||||
|
eth15:57,58,59,60
|
||||||
|
eth16:61,62,63,64
|
||||||
|
eth17:69,70,71,72
|
||||||
|
eth18:65,66,67,68
|
||||||
|
eth19:73,74,75,76
|
||||||
|
eth20:77,78,79,80
|
||||||
|
eth21:109,110,111,112
|
||||||
|
eth22:105,106,107,108
|
||||||
|
eth23:113,114,115,116
|
||||||
|
eth24:117,118,119,120
|
||||||
|
eth25:125,126,127,128
|
||||||
|
eth26:121,122,123,124
|
||||||
|
eth27:81,82,83,84
|
||||||
|
eth28:85,86,87,88
|
||||||
|
eth29:93,94,95,96
|
||||||
|
eth30:89,90,91,92
|
||||||
|
eth31:101,102,103,104
|
||||||
|
eth32:97,98,99,100
|
@ -1,2 +1,5 @@
|
|||||||
SAI_INIT_CONFIG_FILE=/usr/share/sonic/hwsku/td2-s6000-32x40G.config.bcm
|
SAI_WARM_BOOT_READ_FILE=/var/cache/sai_warmboot.bin
|
||||||
SAI_NUM_ECMP_MEMBERS=32
|
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
|
||||||
|
SAI_VS_INTERFACE_LANE_MAP_FILE=/usr/share/sonic/hwsku/lanemap.ini
|
||||||
|
@ -14,9 +14,10 @@ start () {
|
|||||||
# eth48 - eth63: asic5
|
# eth48 - eth63: asic5
|
||||||
for ASIC in `seq $FIRST_FRONTEND_ASIC $LAST_FRONTEND_ASIC`; do
|
for ASIC in `seq $FIRST_FRONTEND_ASIC $LAST_FRONTEND_ASIC`; do
|
||||||
for NUM in `seq 1 16`; do
|
for NUM in `seq 1 16`; do
|
||||||
ORIG="eth$((16 * $ASIC + $NUM - 1))"
|
ORIG="eth$((16 * $ASIC + $NUM))"
|
||||||
TEMP="ethTemp999"
|
TEMP="ethTemp999"
|
||||||
NEW="eth$(($NUM + 16))"
|
NEW="eth$(($NUM))"
|
||||||
|
echo "$ASIC : $NEW old $ORIG"
|
||||||
ip link set dev $ORIG down
|
ip link set dev $ORIG down
|
||||||
ip link set dev $ORIG name $TEMP # rename to prevent conflicts before renaming in new namespace
|
ip link set dev $ORIG name $TEMP # rename to prevent conflicts before renaming in new namespace
|
||||||
ip link set dev $TEMP netns asic$ASIC
|
ip link set dev $TEMP netns asic$ASIC
|
||||||
@ -29,8 +30,9 @@ start () {
|
|||||||
for BACKEND in `seq $FIRST_BACKEND_ASIC $LAST_BACKEND_ASIC`; do
|
for BACKEND in `seq $FIRST_BACKEND_ASIC $LAST_BACKEND_ASIC`; do
|
||||||
for FRONTEND in `seq $FIRST_FRONTEND_ASIC $LAST_FRONTEND_ASIC`; do
|
for FRONTEND in `seq $FIRST_FRONTEND_ASIC $LAST_FRONTEND_ASIC`; do
|
||||||
for LINK in `seq 1 8`; do
|
for LINK in `seq 1 8`; do
|
||||||
BACK_NAME="eth$((8 * $FRONTEND + $LINK))"
|
FRONT_NAME="eth$((8 * $(($BACKEND - $FIRST_BACKEND_ASIC)) + $LINK + 16))"
|
||||||
FRONT_NAME="eth$((8 * $(($LAST_BACKEND_ASIC - $BACKEND)) + $LINK))"
|
BACK_NAME="eth$((8 * $FRONTEND + $LINK))"
|
||||||
|
echo "$FRONTEND:$FRONT_NAME - $BACKEND:$BACK_NAME"
|
||||||
TEMP_BACK="ethBack999"
|
TEMP_BACK="ethBack999"
|
||||||
TEMP_FRONT="ethFront999"
|
TEMP_FRONT="ethFront999"
|
||||||
|
|
||||||
@ -52,7 +54,7 @@ stop() {
|
|||||||
for ASIC in `seq $FIRST_FRONTEND_ASIC $LAST_FRONTEND_ASIC`; do
|
for ASIC in `seq $FIRST_FRONTEND_ASIC $LAST_FRONTEND_ASIC`; do
|
||||||
for NUM in `seq 1 16`; do
|
for NUM in `seq 1 16`; do
|
||||||
TEMP="eth999"
|
TEMP="eth999"
|
||||||
OLD="eth$(($NUM + 16))"
|
OLD="eth$((16 * $ASIC + $NUM))"
|
||||||
NAME="eth$((16 * $ASIC + $NUM - 1))"
|
NAME="eth$((16 * $ASIC + $NUM - 1))"
|
||||||
sudo ip netns exec asic$ASIC ip link set dev $OLD down
|
sudo ip netns exec asic$ASIC ip link set dev $OLD down
|
||||||
sudo ip netns exec asic$ASIC ip link set dev $OLD name $TEMP
|
sudo ip netns exec asic$ASIC ip link set dev $OLD name $TEMP
|
||||||
@ -78,4 +80,3 @@ case "$1" in
|
|||||||
echo "Usage: $0 {start|stop}"
|
echo "Usage: $0 {start|stop}"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
@ -23,6 +23,20 @@ route-map TO_BGP_PEER_V4 permit 100
|
|||||||
!
|
!
|
||||||
route-map TO_BGP_PEER_V6 permit 100
|
route-map TO_BGP_PEER_V6 permit 100
|
||||||
!
|
!
|
||||||
|
{% if DEVICE_METADATA['localhost']['type'] == 'InternalFrontend' %}
|
||||||
|
route-map HIDE_INTERNAL permit 10
|
||||||
|
set community local-AS
|
||||||
|
!
|
||||||
|
{% endif %}
|
||||||
|
{% if DEVICE_METADATA['localhost']['type'] == 'InternalBackend' %}
|
||||||
|
route-map OVERRIDE_ORIGINATOR_ID permit 10
|
||||||
|
{% for (name, prefix) in LOOPBACK_INTERFACE|pfx_filter %}
|
||||||
|
{% if prefix | ipv4 and name == 'Loopback0' %}
|
||||||
|
set originator-id {{ prefix | ip }}
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
!
|
||||||
|
{% endif %}
|
||||||
{% if BGP_MONITORS is defined and BGP_MONITORS|length > 0 %}
|
{% if BGP_MONITORS is defined and BGP_MONITORS|length > 0 %}
|
||||||
route-map FROM_BGPMON deny 10
|
route-map FROM_BGPMON deny 10
|
||||||
!
|
!
|
||||||
@ -37,6 +51,9 @@ route-map set-next-hop-global-v6 permit 10
|
|||||||
set ipv6 next-hop prefer-global
|
set ipv6 next-hop prefer-global
|
||||||
!
|
!
|
||||||
router bgp {{ DEVICE_METADATA['localhost']['bgp_asn'] }}
|
router bgp {{ DEVICE_METADATA['localhost']['bgp_asn'] }}
|
||||||
|
{% if DEVICE_METADATA['localhost']['type'] == 'InternalFrontend' %}
|
||||||
|
redistribute connected route-map HIDE_INTERNAL
|
||||||
|
{% endif %}
|
||||||
bgp log-neighbor-changes
|
bgp log-neighbor-changes
|
||||||
bgp bestpath as-path multipath-relax
|
bgp bestpath as-path multipath-relax
|
||||||
no bgp default ipv4-unicast
|
no bgp default ipv4-unicast
|
||||||
@ -151,6 +168,9 @@ router bgp {{ DEVICE_METADATA['localhost']['bgp_asn'] }}
|
|||||||
neighbor {{ neighbor_addr }} peer-group BGPMON
|
neighbor {{ neighbor_addr }} peer-group BGPMON
|
||||||
neighbor {{ neighbor_addr }} description {{ bgp_session['name'] }}
|
neighbor {{ neighbor_addr }} description {{ bgp_session['name'] }}
|
||||||
neighbor {{ neighbor_addr }} activate
|
neighbor {{ neighbor_addr }} activate
|
||||||
|
{% if DEVICE_METADATA['localhost']['type'] == 'InternalBackend' %}
|
||||||
|
neighbor {{ neighbor_addr }} route-map OVERRIDE_ORIGINATOR_ID in
|
||||||
|
{% endif %}
|
||||||
address-family ipv6
|
address-family ipv6
|
||||||
neighbor {{ neighbor_addr }} activate
|
neighbor {{ neighbor_addr }} activate
|
||||||
exit-address-family
|
exit-address-family
|
||||||
|
1
files/build_templates/database.service.j2
Symbolic link
1
files/build_templates/database.service.j2
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
per_namespace/database.service.j2
|
@ -14,15 +14,16 @@ link_namespace() {
|
|||||||
mkdir -p /var/run/netns
|
mkdir -p /var/run/netns
|
||||||
PID="$(docker inspect -f {{"'{{.State.Pid}}'"}} "{{docker_container_name}}$DEV")"
|
PID="$(docker inspect -f {{"'{{.State.Pid}}'"}} "{{docker_container_name}}$DEV")"
|
||||||
|
|
||||||
if `ip netns | grep --quiet -w "{{docker_container_name}}$DEV"`; then # namespace exists
|
PIDS=`ip netns pids "$NET_NS" 2>/dev/null`
|
||||||
if [ $(readlink -f /var/run/netns/$NET_NS$DEV) = $(readlink -f /proc/$PID/ns/net) ]; then # namespace is correctly linked
|
if [ "$?" -eq "0" ]; then # namespace exists
|
||||||
|
if `echo $PIDS | grep --quiet -w $PID`; then # namespace is correctly linked
|
||||||
return 0
|
return 0
|
||||||
else # if it's incorrectly linked remove it
|
else # if it's incorrectly linked remove it
|
||||||
ip netns delete "{{docker_container_name}}$DEV"
|
ip netns delete $NET_NS
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ln -s /proc/$PID/ns/net /var/run/netns/$NET_NS$DEV
|
ln -s /proc/$PID/ns/net /var/run/netns/$NET_NS
|
||||||
}
|
}
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
|
||||||
@ -56,14 +57,14 @@ function preStartAction()
|
|||||||
WARM_DIR=/host/warmboot
|
WARM_DIR=/host/warmboot
|
||||||
if [[ ("$BOOT_TYPE" == "warm" || "$BOOT_TYPE" == "fastfast") && -f $WARM_DIR/dump.rdb ]]; then
|
if [[ ("$BOOT_TYPE" == "warm" || "$BOOT_TYPE" == "fastfast") && -f $WARM_DIR/dump.rdb ]]; then
|
||||||
# Load redis content from /host/warmboot/dump.rdb
|
# Load redis content from /host/warmboot/dump.rdb
|
||||||
docker cp $WARM_DIR/dump.rdb database:/var/lib/redis/dump.rdb
|
docker cp $WARM_DIR/dump.rdb database$DEV:/var/lib/redis/dump.rdb
|
||||||
else
|
else
|
||||||
# Create an emtpy file and overwrite any RDB if already there
|
# Create an emtpy file and overwrite any RDB if already there
|
||||||
echo -n > /tmp/dump.rdb
|
echo -n > /tmp/dump.rdb
|
||||||
docker cp /tmp/dump.rdb database:/var/lib/redis/
|
docker cp /tmp/dump.rdb database$DEV:/var/lib/redis/
|
||||||
fi
|
fi
|
||||||
{%- elif docker_container_name == "snmp" %}
|
{%- elif docker_container_name == "snmp" %}
|
||||||
sonic-db-cli STATE_DB HSET 'DEVICE_METADATA|localhost' chassis_serial_number $(decode-syseeprom -s)
|
sonic-netns-exec "$NET_NS" sonic-db-cli STATE_DB HSET 'DEVICE_METADATA|localhost' chassis_serial_number $(decode-syseeprom -s)
|
||||||
{%- else %}
|
{%- else %}
|
||||||
: # nothing
|
: # nothing
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
@ -76,25 +77,25 @@ function postStartAction()
|
|||||||
link_namespace $DEV
|
link_namespace $DEV
|
||||||
fi
|
fi
|
||||||
# Wait until redis starts
|
# Wait until redis starts
|
||||||
/usr/bin/docker exec database ping_pong_db_insts
|
/usr/bin/docker exec database$DEV ping_pong_db_insts
|
||||||
if [[ ("$BOOT_TYPE" == "warm" || "$BOOT_TYPE" == "fastfast") && -f $WARM_DIR/dump.rdb ]]; then
|
if [[ ("$BOOT_TYPE" == "warm" || "$BOOT_TYPE" == "fastfast") && -f $WARM_DIR/dump.rdb ]]; then
|
||||||
rm -f $WARM_DIR/dump.rdb
|
rm -f $WARM_DIR/dump.rdb
|
||||||
else
|
else
|
||||||
# If there is a config_db.json dump file, load it.
|
# If there is a config_db.json dump file, load it.
|
||||||
if [ -r /etc/sonic/config_db.json ]; then
|
if [ -r /etc/sonic/config_db$DEV.json ]; then
|
||||||
if [ -r /etc/sonic/init_cfg.json ]; then
|
if [ -r /etc/sonic/init_cfg.json ]; then
|
||||||
sonic-cfggen -j /etc/sonic/init_cfg.json -j /etc/sonic/config_db.json --write-to-db
|
sonic-netns-exec "$NET_NS" sonic-cfggen -j /etc/sonic/init_cfg.json -j /etc/sonic/config_db$DEV.json --write-to-db
|
||||||
else
|
else
|
||||||
sonic-cfggen -j /etc/sonic/config_db.json --write-to-db
|
sonic-netns-exec "$NET_NS" sonic-cfggen -j /etc/sonic/config_db$DEV.json --write-to-db
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$BOOT_TYPE" == "fast" ]]; then
|
if [[ "$BOOT_TYPE" == "fast" ]]; then
|
||||||
# set the key to expire in 3 minutes
|
# set the key to expire in 3 minutes
|
||||||
sonic-db-cli STATE_DB SET "FAST_REBOOT|system" "1" "EX" "180"
|
/usr/bin/sonic-netns-exec "$NET_NS" sonic-db-cli STATE_DB SET "FAST_REBOOT|system" "1" "EX" "180"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sonic-db-cli CONFIG_DB SET "CONFIG_DB_INITIALIZED" "1"
|
/usr/bin/sonic-netns-exec "$NET_NS" sonic-db-cli CONFIG_DB SET "CONFIG_DB_INITIALIZED" "1"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -x /usr/bin/db_migrator.py ]]; then
|
if [[ -x /usr/bin/db_migrator.py ]]; then
|
||||||
@ -102,14 +103,14 @@ function postStartAction()
|
|||||||
/usr/bin/db_migrator.py -o migrate
|
/usr/bin/db_migrator.py -o migrate
|
||||||
fi
|
fi
|
||||||
{%- elif docker_container_name == "swss" %}
|
{%- elif docker_container_name == "swss" %}
|
||||||
docker exec swss rm -f /ready # remove cruft
|
docker exec swss$DEV rm -f /ready # remove cruft
|
||||||
if [[ "$BOOT_TYPE" == "fast" ]] && [[ -d /host/fast-reboot ]]; then
|
if [[ "$BOOT_TYPE" == "fast" ]] && [[ -d /host/fast-reboot ]]; then
|
||||||
test -e /host/fast-reboot/fdb.json && docker cp /host/fast-reboot/fdb.json swss:/
|
test -e /host/fast-reboot/fdb.json && docker cp /host/fast-reboot/fdb.json swss$DEV:/
|
||||||
test -e /host/fast-reboot/arp.json && docker cp /host/fast-reboot/arp.json swss:/
|
test -e /host/fast-reboot/arp.json && docker cp /host/fast-reboot/arp.json swss$DEV:/
|
||||||
test -e /host/fast-reboot/default_routes.json && docker cp /host/fast-reboot/default_routes.json swss:/
|
test -e /host/fast-reboot/default_routes.json && docker cp /host/fast-reboot/default_routes.json swss$DEV:/
|
||||||
rm -fr /host/fast-reboot
|
rm -fr /host/fast-reboot
|
||||||
fi
|
fi
|
||||||
docker exec swss touch /ready # signal swssconfig.sh to go
|
docker exec swss$DEV touch /ready # signal swssconfig.sh to go
|
||||||
{%- elif docker_container_name == "pmon" %}
|
{%- elif docker_container_name == "pmon" %}
|
||||||
|
|
||||||
DEVPATH="/usr/share/sonic/device"
|
DEVPATH="/usr/share/sonic/device"
|
||||||
@ -131,14 +132,14 @@ start() {
|
|||||||
BOOT_TYPE=`getBootType`
|
BOOT_TYPE=`getBootType`
|
||||||
|
|
||||||
# Obtain our platform as we will mount directories with these names in each docker
|
# Obtain our platform as we will mount directories with these names in each docker
|
||||||
PLATFORM=`sonic-cfggen -H -v DEVICE_METADATA.localhost.platform`
|
PLATFORM=`sonic-netns-exec "$NET_NS" sonic-cfggen -H -v DEVICE_METADATA.localhost.platform`
|
||||||
|
|
||||||
{%- if docker_container_name == "database" %}
|
{%- if docker_container_name == "database" %}
|
||||||
# Don't mount HWSKU in {{docker_container_name}} container.
|
# Don't mount HWSKU in {{docker_container_name}} container.
|
||||||
HWSKU=""
|
HWSKU=""
|
||||||
{%- else %}
|
{%- else %}
|
||||||
# Obtain our HWSKU as we will mount directories with these names in each docker
|
# Obtain our HWSKU as we will mount directories with these names in each docker
|
||||||
HWSKU=`sonic-cfggen -d -v 'DEVICE_METADATA["localhost"]["hwsku"]'`
|
HWSKU=`sonic-netns-exec "$NET_NS" sonic-cfggen -d -v 'DEVICE_METADATA["localhost"]["hwsku"]'`
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
|
||||||
DOCKERCHECK=`docker inspect --type container {{docker_container_name}}$DEV 2>/dev/null`
|
DOCKERCHECK=`docker inspect --type container {{docker_container_name}}$DEV 2>/dev/null`
|
||||||
@ -185,7 +186,14 @@ start() {
|
|||||||
NET="container:database$DEV"
|
NET="container:database$DEV"
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
fi
|
fi
|
||||||
|
{%- if docker_container_name == "bgp" %}
|
||||||
|
if [ "$DEV" ]; then
|
||||||
|
if [ ! -d "/etc/sonic/frr/$DEV" ]; then
|
||||||
|
mkdir /etc/sonic/frr/$DEV
|
||||||
|
cp -r /etc/sonic/frr/*.conf /etc/sonic/frr/$DEV
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
{%- endif %}
|
||||||
{%- if sonic_asic_platform == "mellanox" %}
|
{%- if sonic_asic_platform == "mellanox" %}
|
||||||
# TODO: Mellanox will remove the --tmpfs exception after SDK socket path changed in new SDK version
|
# TODO: Mellanox will remove the --tmpfs exception after SDK socket path changed in new SDK version
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
@ -215,10 +223,13 @@ start() {
|
|||||||
--tmpfs /tmp \
|
--tmpfs /tmp \
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
-v /var/run/redis:/var/run/redis:rw \
|
{%- if docker_container_name == "bgp" %}
|
||||||
|
-v /etc/sonic/frr/$DEV:/etc/frr:rw \
|
||||||
|
{%- endif %}
|
||||||
|
-v /var/run/redis$DEV:/var/run/redis:rw \
|
||||||
-v /usr/share/sonic/device/$PLATFORM:/usr/share/sonic/platform:ro \
|
-v /usr/share/sonic/device/$PLATFORM:/usr/share/sonic/platform:ro \
|
||||||
{%- if docker_container_name != "database" %}
|
{%- if docker_container_name != "database" %}
|
||||||
-v /usr/share/sonic/device/$PLATFORM/$HWSKU:/usr/share/sonic/hwsku:ro \
|
-v /usr/share/sonic/device/$PLATFORM/$HWSKU/$DEV:/usr/share/sonic/hwsku:ro \
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
{%- if sonic_asic_platform != "mellanox" %}
|
{%- if sonic_asic_platform != "mellanox" %}
|
||||||
--tmpfs /tmp \
|
--tmpfs /tmp \
|
||||||
@ -230,7 +241,7 @@ start() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
preStartAction
|
preStartAction
|
||||||
docker start {{docker_container_name}}
|
docker start {{docker_container_name}}$DEV
|
||||||
postStartAction
|
postStartAction
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -241,13 +252,19 @@ wait() {
|
|||||||
stop() {
|
stop() {
|
||||||
docker stop {{docker_container_name}}$DEV
|
docker stop {{docker_container_name}}$DEV
|
||||||
{%- if docker_container_name == "database" %}
|
{%- if docker_container_name == "database" %}
|
||||||
ip netns delete "$NET_NS$DEV"
|
if [ "$DEV" ]; then
|
||||||
|
ip netns delete "$NET_NS"
|
||||||
|
fi
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
}
|
}
|
||||||
|
|
||||||
OP=$1
|
OP=$1
|
||||||
DEV=$2 # namespace/device number to operate on
|
DEV=$2 # namespace/device number to operate on
|
||||||
NET_NS="asic" #name of the network namespace
|
if [ "$DEV" ]; then
|
||||||
|
NET_NS="asic$DEV" #name of the network namespace
|
||||||
|
else
|
||||||
|
NET_NS=""
|
||||||
|
fi
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
start|wait|stop)
|
start|wait|stop)
|
||||||
|
@ -1,18 +0,0 @@
|
|||||||
[Unit]
|
|
||||||
Description=LLDP container
|
|
||||||
Requires=updategraph.service
|
|
||||||
After=updategraph.service swss.service syncd.service
|
|
||||||
Before=ntp-config.service
|
|
||||||
StartLimitIntervalSec=1200
|
|
||||||
StartLimitBurst=3
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
User={{ sonicadmin_user }}
|
|
||||||
ExecStartPre=/usr/bin/{{docker_container_name}}.sh start
|
|
||||||
ExecStart=/usr/bin/{{docker_container_name}}.sh wait
|
|
||||||
ExecStop=/usr/bin/{{docker_container_name}}.sh stop
|
|
||||||
Restart=always
|
|
||||||
RestartSec=30
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=multi-user.target
|
|
21
files/build_templates/per_namespace/bgp.service.j2
Normal file
21
files/build_templates/per_namespace/bgp.service.j2
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=BGP container
|
||||||
|
Requires=database{% if multi_instance == 'true' %}@%i{% endif %}.service
|
||||||
|
After=database{% if multi_instance == 'true' %}@%i{% endif %}.service
|
||||||
|
Requires=updategraph.service
|
||||||
|
After=updategraph.service
|
||||||
|
Before=ntp-config.service
|
||||||
|
StartLimitIntervalSec=1200
|
||||||
|
StartLimitBurst=3
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
User={{ sonicadmin_user }}
|
||||||
|
ExecStartPre=/usr/bin/{{docker_container_name}}.sh start{% if multi_instance == 'true' %} %i{% endif %}
|
||||||
|
ExecStart=/usr/bin/{{docker_container_name}}.sh wait{% if multi_instance == 'true' %} %i{% endif %}
|
||||||
|
ExecStop=/usr/bin/{{docker_container_name}}.sh stop{% if multi_instance == 'true' %} %i{% endif %}
|
||||||
|
|
||||||
|
Restart=always
|
||||||
|
RestartSec=30
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
22
files/build_templates/per_namespace/database.service.j2
Normal file
22
files/build_templates/per_namespace/database.service.j2
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Database container
|
||||||
|
{% if multi_instance == 'true' %}
|
||||||
|
Requires=database.service
|
||||||
|
After=database.service
|
||||||
|
{% endif %}
|
||||||
|
Requires=docker.service
|
||||||
|
After=docker.service
|
||||||
|
After=rc-local.service
|
||||||
|
StartLimitIntervalSec=1200
|
||||||
|
StartLimitBurst=3
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
User=root
|
||||||
|
ExecStartPre=/usr/bin/{{docker_container_name}}.sh start{% if multi_instance == 'true' %} %i{% endif %}
|
||||||
|
ExecStart=/usr/bin/{{docker_container_name}}.sh wait{% if multi_instance == 'true' %} %i{% endif %}
|
||||||
|
ExecStop=/usr/bin/{{docker_container_name}}.sh stop{% if multi_instance == 'true' %} %i{% endif %}
|
||||||
|
Restart=always
|
||||||
|
RestartSec=30
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
22
files/build_templates/per_namespace/lldp.service.j2
Normal file
22
files/build_templates/per_namespace/lldp.service.j2
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=LLDP container
|
||||||
|
Requires=database{% if multi_instance == 'true' %}@%i{% endif %}.service
|
||||||
|
After=database{% if multi_instance == 'true' %}@%i{% endif %}.service
|
||||||
|
After=swss{% if multi_instance == 'true' %}@%i{% endif %}.service
|
||||||
|
After=syncd{% if multi_instance == 'true' %}@%i{% endif %}.service
|
||||||
|
Requires=updategraph.service
|
||||||
|
After=updategraph.service
|
||||||
|
Before=ntp-config.service
|
||||||
|
StartLimitIntervalSec=1200
|
||||||
|
StartLimitBurst=3
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
User={{ sonicadmin_user }}
|
||||||
|
ExecStartPre=/usr/bin/{{docker_container_name}}.sh start{% if multi_instance == 'true' %} %i{% endif %}
|
||||||
|
ExecStart=/usr/bin/{{docker_container_name}}.sh wait{% if multi_instance == 'true' %} %i{% endif %}
|
||||||
|
ExecStop=/usr/bin/{{docker_container_name}}.sh stop{% if multi_instance == 'true' %} %i{% endif %}
|
||||||
|
Restart=always
|
||||||
|
RestartSec=30
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
31
files/build_templates/per_namespace/swss.service.j2
Normal file
31
files/build_templates/per_namespace/swss.service.j2
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=switch state service
|
||||||
|
Requires=database{% if multi_instance == 'true' %}@%i{% endif %}.service
|
||||||
|
After=database{% if multi_instance == 'true' %}@%i{% endif %}.service
|
||||||
|
{% if multi_instance == 'true' and sonic_asic_platform == 'vs' %}
|
||||||
|
Requires=topology.service
|
||||||
|
After=topology.service
|
||||||
|
{% endif %}
|
||||||
|
{% if sonic_asic_platform == 'broadcom' %}
|
||||||
|
Requires=opennsl-modules.service
|
||||||
|
{% elif sonic_asic_platform == 'nephos' %}
|
||||||
|
Requires=nps-modules-4.9.0-11-2-amd64.service
|
||||||
|
{% endif %}
|
||||||
|
Requires=updategraph.service
|
||||||
|
After=updategraph.service
|
||||||
|
After=interfaces-config.service
|
||||||
|
Before=ntp-config.service
|
||||||
|
StartLimitIntervalSec=1200
|
||||||
|
StartLimitBurst=3
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
User=root
|
||||||
|
Environment=sonic_asic_platform={{ sonic_asic_platform }}
|
||||||
|
ExecStartPre=/usr/local/bin/swss.sh start{% if multi_instance == 'true' %} %i{% endif %}
|
||||||
|
ExecStart=/usr/local/bin/swss.sh wait{% if multi_instance == 'true' %} %i{% endif %}
|
||||||
|
ExecStop=/usr/local/bin/swss.sh stop{% if multi_instance == 'true' %} %i{% endif %}
|
||||||
|
Restart=always
|
||||||
|
RestartSec=30
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
33
files/build_templates/per_namespace/syncd.service.j2
Normal file
33
files/build_templates/per_namespace/syncd.service.j2
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=syncd service
|
||||||
|
Requires=database{% if multi_instance == 'true' %}@%i{% endif %}.service
|
||||||
|
After=database{% if multi_instance == 'true' %}@%i{% endif %}.service
|
||||||
|
After=swss{% if multi_instance == 'true' %}@%i{% endif %}.service
|
||||||
|
{% if multi_instance == 'true' and sonic_asic_platform == 'vs' %}
|
||||||
|
Requires=topology.service
|
||||||
|
After=topology.service
|
||||||
|
{% endif %}
|
||||||
|
{% if sonic_asic_platform == 'broadcom' %}
|
||||||
|
Requires=opennsl-modules.service
|
||||||
|
After=opennsl-modules.service
|
||||||
|
{% elif sonic_asic_platform == 'nephos' %}
|
||||||
|
Requires=nps-modules-4.9.0-11-2-amd64.service
|
||||||
|
After=nps-modules-4.9.0-11-2-amd64.service
|
||||||
|
{% endif %}
|
||||||
|
Requires=updategraph.service
|
||||||
|
After=updategraph.service
|
||||||
|
After=interfaces-config.service
|
||||||
|
Before=ntp-config.service
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
User=root
|
||||||
|
Environment=sonic_asic_platform={{ sonic_asic_platform }}
|
||||||
|
ExecStartPre=/usr/local/bin/syncd.sh start{% if multi_instance == 'true' %} %i{% endif %}
|
||||||
|
ExecStart=/usr/local/bin/syncd.sh wait{% if multi_instance == 'true' %} %i{% endif %}
|
||||||
|
ExecStop=/usr/local/bin/syncd.sh stop{% if multi_instance == 'true' %} %i{% endif %}
|
||||||
|
{% if sonic_asic_platform == 'mellanox' %}
|
||||||
|
TimeoutStartSec=150
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
19
files/build_templates/per_namespace/teamd.service.j2
Normal file
19
files/build_templates/per_namespace/teamd.service.j2
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=TEAMD container
|
||||||
|
After=swss{% if multi_instance == 'true' %}@%i{% endif %}.service
|
||||||
|
Requires=updategraph.service
|
||||||
|
After=updategraph.service
|
||||||
|
Before=ntp-config.service
|
||||||
|
StartLimitIntervalSec=1200
|
||||||
|
StartLimitBurst=3
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
User={{ sonicadmin_user }}
|
||||||
|
ExecStartPre=/usr/bin/{{docker_container_name}}.sh start{% if multi_instance == 'true' %} %i{% endif %}
|
||||||
|
ExecStart=/usr/bin/{{docker_container_name}}.sh wait{% if multi_instance == 'true' %} %i{% endif %}
|
||||||
|
ExecStop=/usr/bin/{{docker_container_name}}.sh stop{% if multi_instance == 'true' %} %i{% endif %}
|
||||||
|
Restart=always
|
||||||
|
RestartSec=30
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
@ -1,18 +0,0 @@
|
|||||||
[Unit]
|
|
||||||
Description=BGP container
|
|
||||||
Requires=updategraph.service
|
|
||||||
After=updategraph.service
|
|
||||||
Before=ntp-config.service
|
|
||||||
StartLimitIntervalSec=1200
|
|
||||||
StartLimitBurst=3
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
User={{ sonicadmin_user }}
|
|
||||||
ExecStartPre=/usr/bin/{{docker_container_name}}.sh start
|
|
||||||
ExecStart=/usr/bin/{{docker_container_name}}.sh wait
|
|
||||||
ExecStop=/usr/bin/{{docker_container_name}}.sh stop
|
|
||||||
Restart=always
|
|
||||||
RestartSec=30
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=multi-user.target
|
|
@ -1,18 +0,0 @@
|
|||||||
[Unit]
|
|
||||||
Description=Database container
|
|
||||||
Requires=docker.service
|
|
||||||
After=docker.service
|
|
||||||
After=rc-local.service
|
|
||||||
StartLimitIntervalSec=1200
|
|
||||||
StartLimitBurst=3
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
User=root
|
|
||||||
ExecStartPre=/usr/bin/{{docker_container_name}}.sh start
|
|
||||||
ExecStart=/usr/bin/{{docker_container_name}}.sh wait
|
|
||||||
ExecStop=/usr/bin/{{docker_container_name}}.sh stop
|
|
||||||
Restart=always
|
|
||||||
RestartSec=30
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=multi-user.target
|
|
@ -1,25 +0,0 @@
|
|||||||
[Unit]
|
|
||||||
Description=switch state service
|
|
||||||
Requires=database.service updategraph.service
|
|
||||||
{% if sonic_asic_platform == 'broadcom' %}
|
|
||||||
Requires=opennsl-modules.service
|
|
||||||
{% elif sonic_asic_platform == 'nephos' %}
|
|
||||||
Requires=nps-modules-4.9.0-11-2-amd64.service
|
|
||||||
{% endif %}
|
|
||||||
After=database.service updategraph.service
|
|
||||||
After=interfaces-config.service
|
|
||||||
Before=ntp-config.service
|
|
||||||
StartLimitIntervalSec=1200
|
|
||||||
StartLimitBurst=3
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
User=root
|
|
||||||
Environment=sonic_asic_platform={{ sonic_asic_platform }}
|
|
||||||
ExecStartPre=/usr/local/bin/swss.sh start
|
|
||||||
ExecStart=/usr/local/bin/swss.sh wait
|
|
||||||
ExecStop=/usr/local/bin/swss.sh stop
|
|
||||||
Restart=always
|
|
||||||
RestartSec=30
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=multi-user.target
|
|
@ -1,30 +0,0 @@
|
|||||||
[Unit]
|
|
||||||
Description=syncd service
|
|
||||||
Requires=database.service updategraph.service
|
|
||||||
{% if sonic_asic_platform == 'broadcom' %}
|
|
||||||
Requires=opennsl-modules.service
|
|
||||||
{% elif sonic_asic_platform == 'nephos' %}
|
|
||||||
Requires=nps-modules-4.9.0-11-2-amd64.service
|
|
||||||
{% endif %}
|
|
||||||
After=database.service updategraph.service
|
|
||||||
After=interfaces-config.service
|
|
||||||
{% if sonic_asic_platform == 'broadcom' %}
|
|
||||||
After=opennsl-modules.service
|
|
||||||
{% elif sonic_asic_platform == 'nephos' %}
|
|
||||||
After=nps-modules-4.9.0-11-2-amd64.service
|
|
||||||
{% endif %}
|
|
||||||
After=swss.service
|
|
||||||
Before=ntp-config.service
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
User=root
|
|
||||||
Environment=sonic_asic_platform={{ sonic_asic_platform }}
|
|
||||||
ExecStartPre=/usr/local/bin/syncd.sh start
|
|
||||||
ExecStart=/usr/local/bin/syncd.sh wait
|
|
||||||
ExecStop=/usr/local/bin/syncd.sh stop
|
|
||||||
{% if sonic_asic_platform == 'mellanox' %}
|
|
||||||
TimeoutStartSec=150
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=multi-user.target
|
|
@ -1,18 +0,0 @@
|
|||||||
[Unit]
|
|
||||||
Description=TEAMD container
|
|
||||||
Requires=updategraph.service
|
|
||||||
After=updategraph.service swss.service
|
|
||||||
Before=ntp-config.service
|
|
||||||
StartLimitIntervalSec=1200
|
|
||||||
StartLimitBurst=3
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
User={{ sonicadmin_user }}
|
|
||||||
ExecStartPre=/usr/bin/{{docker_container_name}}.sh start
|
|
||||||
ExecStart=/usr/bin/{{docker_container_name}}.sh wait
|
|
||||||
ExecStop=/usr/bin/{{docker_container_name}}.sh stop
|
|
||||||
Restart=always
|
|
||||||
RestartSec=30
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=multi-user.target
|
|
@ -284,6 +284,7 @@ j2 files/build_templates/init_cfg.json.j2 | sudo tee $FILESYSTEM_ROOT/etc/sonic/
|
|||||||
# Copy config-setup script and service file
|
# Copy config-setup script and service file
|
||||||
j2 files/build_templates/config-setup.service.j2 | sudo tee $FILESYSTEM_ROOT/etc/systemd/system/config-setup.service
|
j2 files/build_templates/config-setup.service.j2 | sudo tee $FILESYSTEM_ROOT/etc/systemd/system/config-setup.service
|
||||||
sudo cp $IMAGE_CONFIGS/config-setup/config-setup $FILESYSTEM_ROOT/usr/bin/config-setup
|
sudo cp $IMAGE_CONFIGS/config-setup/config-setup $FILESYSTEM_ROOT/usr/bin/config-setup
|
||||||
|
echo "config-setup.service" | sudo tee -a $GENERATED_SERVICE_FILE
|
||||||
sudo LANG=C chroot $FILESYSTEM_ROOT systemctl enable config-setup.service
|
sudo LANG=C chroot $FILESYSTEM_ROOT systemctl enable config-setup.service
|
||||||
|
|
||||||
# Copy SNMP configuration files
|
# Copy SNMP configuration files
|
||||||
@ -434,6 +435,9 @@ sudo LANG=C chroot $FILESYSTEM_ROOT umount -lf /sys
|
|||||||
sudo LANG=C cp $SCRIPTS_DIR/swss.sh $FILESYSTEM_ROOT/usr/local/bin/swss.sh
|
sudo LANG=C cp $SCRIPTS_DIR/swss.sh $FILESYSTEM_ROOT/usr/local/bin/swss.sh
|
||||||
sudo LANG=C cp $SCRIPTS_DIR/syncd.sh $FILESYSTEM_ROOT/usr/local/bin/syncd.sh
|
sudo LANG=C cp $SCRIPTS_DIR/syncd.sh $FILESYSTEM_ROOT/usr/local/bin/syncd.sh
|
||||||
|
|
||||||
|
# Copy sonic-netns-exec script
|
||||||
|
sudo LANG=C cp $SCRIPTS_DIR/sonic-netns-exec $FILESYSTEM_ROOT/usr/bin/sonic-netns-exec
|
||||||
|
|
||||||
# Copy systemd timer configuration
|
# Copy systemd timer configuration
|
||||||
# It implements delayed start of services
|
# It implements delayed start of services
|
||||||
sudo cp $BUILD_TEMPLATES/snmp.timer $FILESYSTEM_ROOT/etc/systemd/system/
|
sudo cp $BUILD_TEMPLATES/snmp.timer $FILESYSTEM_ROOT/etc/systemd/system/
|
||||||
|
@ -6,18 +6,16 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
DB_FIRST_INSTANCE="/var/run/redis0/redis.sock"
|
TOPOLOGY_SCRIPT="topology.sh"
|
||||||
TOPOLOGY_SCRIPT="topology.sh"
|
PLATFORM=`sonic-cfggen -H -v DEVICE_METADATA.localhost.platform`
|
||||||
PLATFORM=`sonic-cfggen -H -v DEVICE_METADATA.localhost.platform -s $DB_FIRST_INSTANCE`
|
HWSKU=`sonic-cfggen -d -v 'DEVICE_METADATA["localhost"]["hwsku"]'`
|
||||||
HWSKU=`sonic-cfggen -d -v 'DEVICE_METADATA["localhost"]["hwsku"]' -s $DB_FIRST_INSTANCE`
|
/usr/share/sonic/device/$PLATFORM/$HWSKU/$TOPOLOGY_SCRIPT start
|
||||||
/usr/share/sonic/device/$PLATFORM/$HWSKU/$TOPOLOGY_SCRIPT start
|
|
||||||
}
|
}
|
||||||
stop() {
|
stop() {
|
||||||
DB_FIRST_INSTANCE="/var/run/redis0/redis.sock"
|
TOPOLOGY_SCRIPT="topology.sh"
|
||||||
TOPOLOGY_SCRIPT="topology.sh"
|
PLATFORM=`sonic-cfggen -H -v DEVICE_METADATA.localhost.platform`
|
||||||
PLATFORM=`sonic-cfggen -H -v DEVICE_METADATA.localhost.platform -s $DB_FIRST_INSTANCE`
|
HWSKU=`sonic-cfggen -d -v 'DEVICE_METADATA["localhost"]["hwsku"]'`
|
||||||
HWSKU=`sonic-cfggen -d -v 'DEVICE_METADATA["localhost"]["hwsku"]' -s $DB_FIRST_INSTANCE`
|
usr/share/sonic/device/$PLATFORM/$HWSKU/$TOPOLOGY_SCRIPT stop
|
||||||
/usr/share/sonic/device/$PLATFORM/$HWSKU/$TOPOLOGY_SCRIPT stop
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
|
12
files/scripts/sonic-netns-exec
Executable file
12
files/scripts/sonic-netns-exec
Executable file
@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Wrapper to execute any command in a specific
|
||||||
|
# network namespace.
|
||||||
|
# Usage:
|
||||||
|
# sonic-netns-exec <namespace name> <command to be executed>
|
||||||
|
NS="$1"
|
||||||
|
shift
|
||||||
|
if [ "$NS" != "" ]; then
|
||||||
|
ip netns exec $NS $@
|
||||||
|
else
|
||||||
|
$@
|
||||||
|
fi
|
@ -1,10 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
SERVICE="swss"
|
DEPENDENT="radv dhcp_relay"
|
||||||
PEER="syncd"
|
MULTI_INST_DEPENDENT="teamd"
|
||||||
DEPENDENT="teamd radv dhcp_relay"
|
|
||||||
DEBUGLOG="/tmp/swss-syncd-debug.log"
|
|
||||||
LOCKFILE="/tmp/swss-syncd-lock"
|
|
||||||
|
|
||||||
function debug()
|
function debug()
|
||||||
{
|
{
|
||||||
@ -14,25 +11,25 @@ function debug()
|
|||||||
|
|
||||||
function lock_service_state_change()
|
function lock_service_state_change()
|
||||||
{
|
{
|
||||||
debug "Locking ${LOCKFILE} from ${SERVICE} service"
|
debug "Locking ${LOCKFILE} from ${SERVICE}$DEV service"
|
||||||
|
|
||||||
exec {LOCKFD}>${LOCKFILE}
|
exec {LOCKFD}>${LOCKFILE}
|
||||||
/usr/bin/flock -x ${LOCKFD}
|
/usr/bin/flock -x ${LOCKFD}
|
||||||
trap "/usr/bin/flock -u ${LOCKFD}" 0 2 3 15
|
trap "/usr/bin/flock -u ${LOCKFD}" 0 2 3 15
|
||||||
|
|
||||||
debug "Locked ${LOCKFILE} (${LOCKFD}) from ${SERVICE} service"
|
debug "Locked ${LOCKFILE} (${LOCKFD}) from ${SERVICE}$DEV service"
|
||||||
}
|
}
|
||||||
|
|
||||||
function unlock_service_state_change()
|
function unlock_service_state_change()
|
||||||
{
|
{
|
||||||
debug "Unlocking ${LOCKFILE} (${LOCKFD}) from ${SERVICE} service"
|
debug "Unlocking ${LOCKFILE} (${LOCKFD}) from ${SERVICE}$DEV service"
|
||||||
/usr/bin/flock -u ${LOCKFD}
|
/usr/bin/flock -u ${LOCKFD}
|
||||||
}
|
}
|
||||||
|
|
||||||
function check_warm_boot()
|
function check_warm_boot()
|
||||||
{
|
{
|
||||||
SYSTEM_WARM_START=`sonic-db-cli STATE_DB hget "WARM_RESTART_ENABLE_TABLE|system" enable`
|
SYSTEM_WARM_START=`sonic-netns-exec "$NET_NS" sonic-db-cli STATE_DB hget "WARM_RESTART_ENABLE_TABLE|system" enable`
|
||||||
SERVICE_WARM_START=`sonic-db-cli STATE_DB hget "WARM_RESTART_ENABLE_TABLE|${SERVICE}" enable`
|
SERVICE_WARM_START=`sonic-netns-exec "$NET_NS" sonic-db-cli STATE_DB hget "WARM_RESTART_ENABLE_TABLE|${SERVICE}" enable`
|
||||||
if [[ x"$SYSTEM_WARM_START" == x"true" ]] || [[ x"$SERVICE_WARM_START" == x"true" ]]; then
|
if [[ x"$SYSTEM_WARM_START" == x"true" ]] || [[ x"$SERVICE_WARM_START" == x"true" ]]; then
|
||||||
WARM_BOOT="true"
|
WARM_BOOT="true"
|
||||||
else
|
else
|
||||||
@ -43,7 +40,7 @@ function check_warm_boot()
|
|||||||
function validate_restore_count()
|
function validate_restore_count()
|
||||||
{
|
{
|
||||||
if [[ x"$WARM_BOOT" == x"true" ]]; then
|
if [[ x"$WARM_BOOT" == x"true" ]]; then
|
||||||
RESTORE_COUNT=`sonic-db-cli STATE_DB hget "WARM_RESTART_TABLE|orchagent" restore_count`
|
RESTORE_COUNT=`sonic-netns-exec "$NET_NS" sonic-db-cli STATE_DB hget "WARM_RESTART_TABLE|orchagent" restore_count`
|
||||||
# We have to make sure db data has not been flushed.
|
# We have to make sure db data has not been flushed.
|
||||||
if [[ -z "$RESTORE_COUNT" ]]; then
|
if [[ -z "$RESTORE_COUNT" ]]; then
|
||||||
WARM_BOOT="false"
|
WARM_BOOT="false"
|
||||||
@ -54,10 +51,10 @@ function validate_restore_count()
|
|||||||
function wait_for_database_service()
|
function wait_for_database_service()
|
||||||
{
|
{
|
||||||
# Wait for redis server start before database clean
|
# Wait for redis server start before database clean
|
||||||
/usr/bin/docker exec database ping_pong_db_insts
|
/usr/bin/docker exec database$DEV ping_pong_db_insts
|
||||||
|
|
||||||
# Wait for configDB initialization
|
# Wait for configDB initialization
|
||||||
until [[ $(sonic-db-cli CONFIG_DB GET "CONFIG_DB_INITIALIZED") ]];
|
until [[ $(sonic-netns-exec "$NET_NS" sonic-db-cli CONFIG_DB GET "CONFIG_DB_INITIALIZED") ]];
|
||||||
do sleep 1;
|
do sleep 1;
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
@ -67,7 +64,7 @@ function wait_for_database_service()
|
|||||||
# $2 the string of a list of table prefixes
|
# $2 the string of a list of table prefixes
|
||||||
function clean_up_tables()
|
function clean_up_tables()
|
||||||
{
|
{
|
||||||
sonic-db-cli $1 EVAL "
|
sonic-netns-exec "$NET_NS" sonic-db-cli $1 EVAL "
|
||||||
local tables = {$2}
|
local tables = {$2}
|
||||||
for i = 1, table.getn(tables) do
|
for i = 1, table.getn(tables) do
|
||||||
local matches = redis.call('KEYS', tables[i])
|
local matches = redis.call('KEYS', tables[i])
|
||||||
@ -81,25 +78,48 @@ start_peer_and_dependent_services() {
|
|||||||
check_warm_boot
|
check_warm_boot
|
||||||
|
|
||||||
if [[ x"$WARM_BOOT" != x"true" ]]; then
|
if [[ x"$WARM_BOOT" != x"true" ]]; then
|
||||||
/bin/systemctl start ${PEER}
|
if [[ ! -z $DEV ]]; then
|
||||||
|
/bin/systemctl start ${PEER}@$DEV
|
||||||
|
else
|
||||||
|
/bin/systemctl start ${PEER}
|
||||||
|
fi
|
||||||
for dep in ${DEPENDENT}; do
|
for dep in ${DEPENDENT}; do
|
||||||
/bin/systemctl start ${dep}
|
/bin/systemctl start ${dep}
|
||||||
done
|
done
|
||||||
|
for dep in ${MULTI_INST_DEPENDENT}; do
|
||||||
|
if [[ ! -z $DEV ]]; then
|
||||||
|
/bin/systemctl start ${dep}@$DEV
|
||||||
|
else
|
||||||
|
/bin/systemctl start ${dep}
|
||||||
|
fi
|
||||||
|
done
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
stop_peer_and_dependent_services() {
|
stop_peer_and_dependent_services() {
|
||||||
# if warm start enabled or peer lock exists, don't stop peer service docker
|
# if warm start enabled or peer lock exists, don't stop peer service docker
|
||||||
if [[ x"$WARM_BOOT" != x"true" ]]; then
|
if [[ x"$WARM_BOOT" != x"true" ]]; then
|
||||||
/bin/systemctl stop ${PEER}
|
if [[ ! -z $DEV ]]; then
|
||||||
|
/bin/systemctl stop ${PEER}@$DEV
|
||||||
|
else
|
||||||
|
/bin/systemctl stop ${PEER}
|
||||||
|
fi
|
||||||
for dep in ${DEPENDENT}; do
|
for dep in ${DEPENDENT}; do
|
||||||
/bin/systemctl stop ${dep}
|
/bin/systemctl stop ${dep}
|
||||||
done
|
done
|
||||||
|
for dep in ${MULTI_INST_DEPENDENT}; do
|
||||||
|
if [[ ! -z $DEV ]]; then
|
||||||
|
/bin/systemctl stop ${dep}@$DEV
|
||||||
|
else
|
||||||
|
/bin/systemctl stop ${dep}
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
debug "Starting ${SERVICE} service..."
|
debug "Starting ${SERVICE}$DEV service..."
|
||||||
|
|
||||||
lock_service_state_change
|
lock_service_state_change
|
||||||
|
|
||||||
@ -107,21 +127,21 @@ start() {
|
|||||||
check_warm_boot
|
check_warm_boot
|
||||||
validate_restore_count
|
validate_restore_count
|
||||||
|
|
||||||
debug "Warm boot flag: ${SERVICE} ${WARM_BOOT}."
|
debug "Warm boot flag: ${SERVICE}$DEV ${WARM_BOOT}."
|
||||||
|
|
||||||
# Don't flush DB during warm boot
|
# Don't flush DB during warm boot
|
||||||
if [[ x"$WARM_BOOT" != x"true" ]]; then
|
if [[ x"$WARM_BOOT" != x"true" ]]; then
|
||||||
debug "Flushing APP, ASIC, COUNTER, CONFIG, and partial STATE databases ..."
|
debug "Flushing APP, ASIC, COUNTER, CONFIG, and partial STATE databases ..."
|
||||||
sonic-db-cli APPL_DB FLUSHDB
|
sonic-netns-exec "$NET_NS" sonic-db-cli APPL_DB FLUSHDB
|
||||||
sonic-db-cli ASIC_DB FLUSHDB
|
sonic-netns-exec "$NET_NS" sonic-db-cli ASIC_DB FLUSHDB
|
||||||
sonic-db-cli COUNTERS_DB FLUSHDB
|
sonic-netns-exec "$NET_NS" sonic-db-cli COUNTERS_DB FLUSHDB
|
||||||
sonic-db-cli FLEX_COUNTER_DB FLUSHDB
|
sonic-netns-exec "$NET_NS" sonic-db-cli FLEX_COUNTER_DB FLUSHDB
|
||||||
clean_up_tables STATE_DB "'PORT_TABLE*', 'MGMT_PORT_TABLE*', 'VLAN_TABLE*', 'VLAN_MEMBER_TABLE*', 'LAG_TABLE*', 'LAG_MEMBER_TABLE*', 'INTERFACE_TABLE*', 'MIRROR_SESSION*', 'VRF_TABLE*', 'FDB_TABLE*'"
|
clean_up_tables STATE_DB "'PORT_TABLE*', 'MGMT_PORT_TABLE*', 'VLAN_TABLE*', 'VLAN_MEMBER_TABLE*', 'LAG_TABLE*', 'LAG_MEMBER_TABLE*', 'INTERFACE_TABLE*', 'MIRROR_SESSION*', 'VRF_TABLE*', 'FDB_TABLE*'"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# start service docker
|
# start service docker
|
||||||
/usr/bin/${SERVICE}.sh start
|
/usr/bin/${SERVICE}.sh start $DEV
|
||||||
debug "Started ${SERVICE} service..."
|
debug "Started ${SERVICE}$DEV service..."
|
||||||
|
|
||||||
# Unlock has to happen before reaching out to peer service
|
# Unlock has to happen before reaching out to peer service
|
||||||
unlock_service_state_change
|
unlock_service_state_change
|
||||||
@ -134,7 +154,11 @@ wait() {
|
|||||||
# NOTE: This assumes Docker containers share the same names as their
|
# NOTE: This assumes Docker containers share the same names as their
|
||||||
# corresponding services
|
# corresponding services
|
||||||
for SECS in {1..60}; do
|
for SECS in {1..60}; do
|
||||||
RUNNING=$(docker inspect -f '{{.State.Running}}' ${PEER})
|
if [[ ! -z $DEV ]]; then
|
||||||
|
RUNNING=$(docker inspect -f '{{.State.Running}}' ${PEER}$DEV)
|
||||||
|
else
|
||||||
|
RUNNING=$(docker inspect -f '{{.State.Running}}' ${PEER})
|
||||||
|
fi
|
||||||
if [[ x"$RUNNING" == x"true" ]]; then
|
if [[ x"$RUNNING" == x"true" ]]; then
|
||||||
break
|
break
|
||||||
else
|
else
|
||||||
@ -144,20 +168,24 @@ wait() {
|
|||||||
|
|
||||||
# NOTE: This assumes Docker containers share the same names as their
|
# NOTE: This assumes Docker containers share the same names as their
|
||||||
# corresponding services
|
# corresponding services
|
||||||
/usr/bin/docker-wait-any ${SERVICE} ${PEER}
|
if [[ ! -z $DEV ]]; then
|
||||||
|
/usr/bin/docker-wait-any ${SERVICE}$DEV ${PEER}$DEV
|
||||||
|
else
|
||||||
|
/usr/bin/docker-wait-any ${SERVICE} ${PEER}
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
stop() {
|
stop() {
|
||||||
debug "Stopping ${SERVICE} service..."
|
debug "Stopping ${SERVICE}$DEV service..."
|
||||||
|
|
||||||
[[ -f ${LOCKFILE} ]] || /usr/bin/touch ${LOCKFILE}
|
[[ -f ${LOCKFILE} ]] || /usr/bin/touch ${LOCKFILE}
|
||||||
|
|
||||||
lock_service_state_change
|
lock_service_state_change
|
||||||
check_warm_boot
|
check_warm_boot
|
||||||
debug "Warm boot flag: ${SERVICE} ${WARM_BOOT}."
|
debug "Warm boot flag: ${SERVICE}$DEV ${WARM_BOOT}."
|
||||||
|
|
||||||
/usr/bin/${SERVICE}.sh stop
|
/usr/bin/${SERVICE}.sh stop $DEV
|
||||||
debug "Stopped ${SERVICE} service..."
|
debug "Stopped ${SERVICE}$DEV service..."
|
||||||
|
|
||||||
# Flush FAST_REBOOT table when swss needs to stop. The only
|
# Flush FAST_REBOOT table when swss needs to stop. The only
|
||||||
# time when this would take effect is when fast-reboot
|
# time when this would take effect is when fast-reboot
|
||||||
@ -172,6 +200,18 @@ stop() {
|
|||||||
stop_peer_and_dependent_services
|
stop_peer_and_dependent_services
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DEV=$2
|
||||||
|
|
||||||
|
SERVICE="swss"
|
||||||
|
PEER="syncd"
|
||||||
|
DEBUGLOG="/tmp/swss-syncd-debug$DEV.log"
|
||||||
|
LOCKFILE="/tmp/swss-syncd-lock$DEV"
|
||||||
|
if [ "$DEV" ]; then
|
||||||
|
NET_NS="asic$DEV" #name of the network namespace
|
||||||
|
else
|
||||||
|
NET_NS=""
|
||||||
|
fi
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
start|wait|stop)
|
start|wait|stop)
|
||||||
$1
|
$1
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
SERVICE="syncd"
|
|
||||||
PEER="swss"
|
|
||||||
DEBUGLOG="/tmp/swss-syncd-debug.log"
|
|
||||||
LOCKFILE="/tmp/swss-syncd-lock"
|
|
||||||
|
|
||||||
function debug()
|
function debug()
|
||||||
{
|
{
|
||||||
@ -13,25 +9,25 @@ function debug()
|
|||||||
|
|
||||||
function lock_service_state_change()
|
function lock_service_state_change()
|
||||||
{
|
{
|
||||||
debug "Locking ${LOCKFILE} from ${SERVICE} service"
|
debug "Locking ${LOCKFILE} from ${SERVICE}$DEV service"
|
||||||
|
|
||||||
exec {LOCKFD}>${LOCKFILE}
|
exec {LOCKFD}>${LOCKFILE}
|
||||||
/usr/bin/flock -x ${LOCKFD}
|
/usr/bin/flock -x ${LOCKFD}
|
||||||
trap "/usr/bin/flock -u ${LOCKFD}" 0 2 3 15
|
trap "/usr/bin/flock -u ${LOCKFD}" 0 2 3 15
|
||||||
|
|
||||||
debug "Locked ${LOCKFILE} (${LOCKFD}) from ${SERVICE} service"
|
debug "Locked ${LOCKFILE} (${LOCKFD}) from ${SERVICE}$DEV service"
|
||||||
}
|
}
|
||||||
|
|
||||||
function unlock_service_state_change()
|
function unlock_service_state_change()
|
||||||
{
|
{
|
||||||
debug "Unlocking ${LOCKFILE} (${LOCKFD}) from ${SERVICE} service"
|
debug "Unlocking ${LOCKFILE} (${LOCKFD}) from ${SERVICE}$DEV service"
|
||||||
/usr/bin/flock -u ${LOCKFD}
|
/usr/bin/flock -u ${LOCKFD}
|
||||||
}
|
}
|
||||||
|
|
||||||
function check_warm_boot()
|
function check_warm_boot()
|
||||||
{
|
{
|
||||||
SYSTEM_WARM_START=`sonic-db-cli STATE_DB hget "WARM_RESTART_ENABLE_TABLE|system" enable`
|
SYSTEM_WARM_START=`sonic-netns-exec "$NET_NS" sonic-db-cli STATE_DB hget "WARM_RESTART_ENABLE_TABLE|system" enable`
|
||||||
SERVICE_WARM_START=`sonic-db-cli STATE_DB hget "WARM_RESTART_ENABLE_TABLE|${SERVICE}" enable`
|
SERVICE_WARM_START=`sonic-netns-exec "$NET_NS" sonic-db-cli STATE_DB hget "WARM_RESTART_ENABLE_TABLE|${SERVICE}" enable`
|
||||||
# SYSTEM_WARM_START could be empty, always make WARM_BOOT meaningful.
|
# SYSTEM_WARM_START could be empty, always make WARM_BOOT meaningful.
|
||||||
if [[ x"$SYSTEM_WARM_START" == x"true" ]] || [[ x"$SERVICE_WARM_START" == x"true" ]]; then
|
if [[ x"$SYSTEM_WARM_START" == x"true" ]] || [[ x"$SERVICE_WARM_START" == x"true" ]]; then
|
||||||
WARM_BOOT="true"
|
WARM_BOOT="true"
|
||||||
@ -43,10 +39,10 @@ function check_warm_boot()
|
|||||||
function wait_for_database_service()
|
function wait_for_database_service()
|
||||||
{
|
{
|
||||||
# Wait for redis server start before database clean
|
# Wait for redis server start before database clean
|
||||||
/usr/bin/docker exec database ping_pong_db_insts
|
/usr/bin/docker exec database$DEV ping_pong_db_insts
|
||||||
|
|
||||||
# Wait for configDB initialization
|
# Wait for configDB initialization
|
||||||
until [[ $(sonic-db-cli CONFIG_DB GET "CONFIG_DB_INITIALIZED") ]];
|
until [[ $(sonic-netns-exec "$NET_NS" sonic-db-cli CONFIG_DB GET "CONFIG_DB_INITIALIZED") ]];
|
||||||
do sleep 1;
|
do sleep 1;
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
@ -63,7 +59,7 @@ function getBootType()
|
|||||||
;;
|
;;
|
||||||
*SONIC_BOOT_TYPE=fast*|*fast-reboot*)
|
*SONIC_BOOT_TYPE=fast*|*fast-reboot*)
|
||||||
# check that the key exists
|
# check that the key exists
|
||||||
if [[ $(sonic-db-cli STATE_DB GET "FAST_REBOOT|system") == "1" ]]; then
|
if [[ $(sonic-netns-exec "$NET_NS" sonic-db-cli STATE_DB GET "FAST_REBOOT|system") == "1" ]]; then
|
||||||
TYPE='fast'
|
TYPE='fast'
|
||||||
else
|
else
|
||||||
TYPE='cold'
|
TYPE='cold'
|
||||||
@ -76,7 +72,7 @@ function getBootType()
|
|||||||
}
|
}
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
debug "Starting ${SERVICE} service..."
|
debug "Starting ${SERVICE}$DEV service..."
|
||||||
|
|
||||||
lock_service_state_change
|
lock_service_state_change
|
||||||
|
|
||||||
@ -85,7 +81,7 @@ start() {
|
|||||||
wait_for_database_service
|
wait_for_database_service
|
||||||
check_warm_boot
|
check_warm_boot
|
||||||
|
|
||||||
debug "Warm boot flag: ${SERVICE} ${WARM_BOOT}."
|
debug "Warm boot flag: ${SERVICE}$DEV ${WARM_BOOT}."
|
||||||
|
|
||||||
if [[ x"$WARM_BOOT" == x"true" ]]; then
|
if [[ x"$WARM_BOOT" == x"true" ]]; then
|
||||||
# Leave a mark for syncd scripts running inside docker.
|
# Leave a mark for syncd scripts running inside docker.
|
||||||
@ -127,7 +123,7 @@ start() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# start service docker
|
# start service docker
|
||||||
/usr/bin/${SERVICE}.sh start
|
/usr/bin/${SERVICE}.sh start $DEV
|
||||||
debug "Started ${SERVICE} service..."
|
debug "Started ${SERVICE} service..."
|
||||||
|
|
||||||
unlock_service_state_change
|
unlock_service_state_change
|
||||||
@ -139,15 +135,15 @@ wait() {
|
|||||||
/bin/systemctl start pmon
|
/bin/systemctl start pmon
|
||||||
debug "Started pmon service"
|
debug "Started pmon service"
|
||||||
fi
|
fi
|
||||||
/usr/bin/${SERVICE}.sh wait
|
/usr/bin/${SERVICE}.sh wait $DEV
|
||||||
}
|
}
|
||||||
|
|
||||||
stop() {
|
stop() {
|
||||||
debug "Stopping ${SERVICE} service..."
|
debug "Stopping ${SERVICE}$DEV service..."
|
||||||
|
|
||||||
lock_service_state_change
|
lock_service_state_change
|
||||||
check_warm_boot
|
check_warm_boot
|
||||||
debug "Warm boot flag: ${SERVICE} ${WARM_BOOT}."
|
debug "Warm boot flag: ${SERVICE}$DEV ${WARM_BOOT}."
|
||||||
|
|
||||||
if [[ x"$WARM_BOOT" == x"true" ]]; then
|
if [[ x"$WARM_BOOT" == x"true" ]]; then
|
||||||
TYPE=warm
|
TYPE=warm
|
||||||
@ -163,19 +159,19 @@ stop() {
|
|||||||
|
|
||||||
if [[ x$sonic_asic_platform != x"mellanox" ]] || [[ x$TYPE != x"cold" ]]; then
|
if [[ x$sonic_asic_platform != x"mellanox" ]] || [[ x$TYPE != x"cold" ]]; then
|
||||||
debug "${TYPE} shutdown syncd process ..."
|
debug "${TYPE} shutdown syncd process ..."
|
||||||
/usr/bin/docker exec -i syncd /usr/bin/syncd_request_shutdown --${TYPE}
|
/usr/bin/docker exec -i syncd$DEV /usr/bin/syncd_request_shutdown --${TYPE}
|
||||||
|
|
||||||
# wait until syncd quits gracefully
|
# wait until syncd quits gracefully
|
||||||
while docker top syncd | grep -q /usr/bin/syncd; do
|
while docker top syncd$DEV | grep -q /usr/bin/syncd; do
|
||||||
sleep 0.1
|
sleep 0.1
|
||||||
done
|
done
|
||||||
|
|
||||||
/usr/bin/docker exec -i syncd /bin/sync
|
/usr/bin/docker exec -i syncd$DEV /bin/sync
|
||||||
debug "Finished ${TYPE} shutdown syncd process ..."
|
debug "Finished ${TYPE} shutdown syncd process ..."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
/usr/bin/${SERVICE}.sh stop
|
/usr/bin/${SERVICE}.sh stop $DEV
|
||||||
debug "Stopped ${SERVICE} service..."
|
debug "Stopped ${SERVICE}$DEV service..."
|
||||||
|
|
||||||
# platform specific tasks
|
# platform specific tasks
|
||||||
|
|
||||||
@ -192,6 +188,19 @@ stop() {
|
|||||||
unlock_service_state_change
|
unlock_service_state_change
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OP=$1
|
||||||
|
DEV=$2
|
||||||
|
|
||||||
|
SERVICE="syncd"
|
||||||
|
PEER="swss"
|
||||||
|
DEBUGLOG="/tmp/swss-syncd-debug$DEV.log"
|
||||||
|
LOCKFILE="/tmp/swss-syncd-lock$DEV"
|
||||||
|
if [ "$DEV" ]; then
|
||||||
|
NET_NS="asic$DEV" #name of the network namespace
|
||||||
|
else
|
||||||
|
NET_NS=""
|
||||||
|
fi
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
start|wait|stop)
|
start|wait|stop)
|
||||||
$1
|
$1
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
|
<domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
|
||||||
<name>sonic</name>
|
<name>sonic</name>
|
||||||
<memory unit='GB'>8</memory>
|
<memory unit='GB'>8</memory>
|
||||||
<vcpu placement='static'>2</vcpu>
|
<vcpu placement='static'>8</vcpu>
|
||||||
<resource>
|
<resource>
|
||||||
<partition>/machine</partition>
|
<partition>/machine</partition>
|
||||||
</resource>
|
</resource>
|
||||||
|
@ -24,7 +24,6 @@ SONIC_STRETCH_DBG_DOCKERS += $(DOCKER_FPM_FRR_DBG)
|
|||||||
$(DOCKER_FPM_FRR)_CONTAINER_NAME = bgp
|
$(DOCKER_FPM_FRR)_CONTAINER_NAME = bgp
|
||||||
$(DOCKER_FPM_FRR)_RUN_OPT += --privileged -t
|
$(DOCKER_FPM_FRR)_RUN_OPT += --privileged -t
|
||||||
$(DOCKER_FPM_FRR)_RUN_OPT += -v /etc/sonic:/etc/sonic:ro
|
$(DOCKER_FPM_FRR)_RUN_OPT += -v /etc/sonic:/etc/sonic:ro
|
||||||
$(DOCKER_FPM_FRR)_RUN_OPT += -v /etc/sonic/frr:/etc/frr:rw
|
|
||||||
|
|
||||||
$(DOCKER_FPM_FRR)_FILES += $(SUPERVISOR_PROC_EXIT_LISTENER_SCRIPT)
|
$(DOCKER_FPM_FRR)_FILES += $(SUPERVISOR_PROC_EXIT_LISTENER_SCRIPT)
|
||||||
|
|
||||||
|
28
slave.mk
28
slave.mk
@ -778,6 +778,7 @@ $(addprefix $(TARGET_PATH)/, $(SONIC_INSTALLERS)) : $(TARGET_PATH)/% : \
|
|||||||
export platform_common_py2_wheel_path="$(addprefix $(PYTHON_WHEELS_PATH)/,$(SONIC_PLATFORM_COMMON_PY2))"
|
export platform_common_py2_wheel_path="$(addprefix $(PYTHON_WHEELS_PATH)/,$(SONIC_PLATFORM_COMMON_PY2))"
|
||||||
export redis_dump_load_py2_wheel_path="$(addprefix $(PYTHON_WHEELS_PATH)/,$(REDIS_DUMP_LOAD_PY2))"
|
export redis_dump_load_py2_wheel_path="$(addprefix $(PYTHON_WHEELS_PATH)/,$(REDIS_DUMP_LOAD_PY2))"
|
||||||
export install_debug_image="$(INSTALL_DEBUG_TOOLS)"
|
export install_debug_image="$(INSTALL_DEBUG_TOOLS)"
|
||||||
|
export multi_instance="false"
|
||||||
|
|
||||||
$(foreach docker, $($*_DOCKERS),\
|
$(foreach docker, $($*_DOCKERS),\
|
||||||
export docker_image="$(docker)"
|
export docker_image="$(docker)"
|
||||||
@ -788,18 +789,21 @@ $(addprefix $(TARGET_PATH)/, $(SONIC_INSTALLERS)) : $(TARGET_PATH)/% : \
|
|||||||
|
|
||||||
if [ -f files/build_templates/$($(docker:-dbg.gz=.gz)_CONTAINER_NAME).service.j2 ]; then
|
if [ -f files/build_templates/$($(docker:-dbg.gz=.gz)_CONTAINER_NAME).service.j2 ]; then
|
||||||
j2 files/build_templates/$($(docker:-dbg.gz=.gz)_CONTAINER_NAME).service.j2 > $($(docker:-dbg.gz=.gz)_CONTAINER_NAME).service
|
j2 files/build_templates/$($(docker:-dbg.gz=.gz)_CONTAINER_NAME).service.j2 > $($(docker:-dbg.gz=.gz)_CONTAINER_NAME).service
|
||||||
|
|
||||||
|
# Set the flag GLOBAL for all the global system-wide dockers.
|
||||||
|
$(if $(shell ls files/build_templates/$($(docker:-dbg.gz=.gz)_CONTAINER_NAME).service.j2 2>/dev/null),\
|
||||||
|
$(eval $(docker:-dbg.gz=.gz)_GLOBAL = yes)
|
||||||
|
)
|
||||||
fi
|
fi
|
||||||
|
# Any service template, inside instance directory, will be used to generate .service and @.service file.
|
||||||
if [ -f files/build_templates/multi_instance/$($(docker:-dbg.gz=.gz)_CONTAINER_NAME)@.service.j2 ]; then
|
if [ -f files/build_templates/per_namespace/$($(docker:-dbg.gz=.gz)_CONTAINER_NAME).service.j2 ]; then
|
||||||
j2 files/build_templates/multi_instance/$($(docker:-dbg.gz=.gz)_CONTAINER_NAME)@.service.j2 > $($(docker:-dbg.gz=.gz)_CONTAINER_NAME)@.service
|
export multi_instance="true"
|
||||||
|
j2 files/build_templates/per_namespace/$($(docker:-dbg.gz=.gz)_CONTAINER_NAME).service.j2 > $($(docker:-dbg.gz=.gz)_CONTAINER_NAME)@.service
|
||||||
# performs the same check as the elif above, except with make commands so eval behaves properly
|
$(if $(shell ls files/build_templates/per_namespace/$($(docker:-dbg.gz=.gz)_CONTAINER_NAME).service.j2 2>/dev/null),\
|
||||||
$(if $(shell ls files/build_templates/multi_instance/$($(docker:-dbg.gz=.gz)_CONTAINER_NAME)@.service.j2 2>/dev/null),\
|
|
||||||
$(eval $(docker:-dbg.gz=.gz)_TEMPLATE = yes)
|
$(eval $(docker:-dbg.gz=.gz)_TEMPLATE = yes)
|
||||||
)
|
)
|
||||||
fi
|
export multi_instance="false"
|
||||||
if [ -f files/build_templates/single_instance/$($(docker:-dbg.gz=.gz)_CONTAINER_NAME).service.j2 ]; then
|
j2 files/build_templates/per_namespace/$($(docker:-dbg.gz=.gz)_CONTAINER_NAME).service.j2 > $($(docker:-dbg.gz=.gz)_CONTAINER_NAME).service
|
||||||
j2 files/build_templates/single_instance/$($(docker:-dbg.gz=.gz)_CONTAINER_NAME).service.j2 > $($(docker:-dbg.gz=.gz)_CONTAINER_NAME).service
|
|
||||||
fi
|
fi
|
||||||
j2 files/build_templates/docker_image_ctl.j2 > $($(docker:-dbg.gz=.gz)_CONTAINER_NAME).sh
|
j2 files/build_templates/docker_image_ctl.j2 > $($(docker:-dbg.gz=.gz)_CONTAINER_NAME).sh
|
||||||
chmod +x $($(docker:-dbg.gz=.gz)_CONTAINER_NAME).sh
|
chmod +x $($(docker:-dbg.gz=.gz)_CONTAINER_NAME).sh
|
||||||
@ -810,8 +814,12 @@ $(addprefix $(TARGET_PATH)/, $(SONIC_INSTALLERS)) : $(TARGET_PATH)/% : \
|
|||||||
|
|
||||||
# Marks template services with an "@" according to systemd convention
|
# Marks template services with an "@" according to systemd convention
|
||||||
# If the $($docker)_TEMPLATE) variable is set, the service will be treated as a template
|
# If the $($docker)_TEMPLATE) variable is set, the service will be treated as a template
|
||||||
|
# If the $($docker)_GLOBAL) and $($docker)_TEMPLATE) variables are set the service will be added both as a global and template service.
|
||||||
$(foreach docker, $($*_DOCKERS),\
|
$(foreach docker, $($*_DOCKERS),\
|
||||||
$(if $($(docker:-dbg.gz=.gz)_TEMPLATE),\
|
$(if $($(docker:-dbg.gz=.gz)_TEMPLATE),\
|
||||||
|
$(if $($(docker:-dbg.gz=.gz)_GLOBAL),\
|
||||||
|
$(eval SERVICES += "$(addsuffix .service, $($(docker:-dbg.gz=.gz)_CONTAINER_NAME))")\
|
||||||
|
)\
|
||||||
$(eval SERVICES += "$(addsuffix @.service, $($(docker:-dbg.gz=.gz)_CONTAINER_NAME))"),\
|
$(eval SERVICES += "$(addsuffix @.service, $($(docker:-dbg.gz=.gz)_CONTAINER_NAME))"),\
|
||||||
$(eval SERVICES += "$(addsuffix .service, $($(docker:-dbg.gz=.gz)_CONTAINER_NAME))")
|
$(eval SERVICES += "$(addsuffix .service, $($(docker:-dbg.gz=.gz)_CONTAINER_NAME))")
|
||||||
)
|
)
|
||||||
|
Reference in New Issue
Block a user