|
3 | 3 | UPLINK='eth' |
4 | 4 |
|
5 | 5 | # TMODE is expected to be set via the containerlab topology file prior to deployment |
6 | | -# Expected values are "lacp" and "static" which will bond eth1 and eth2 |
| 6 | +# Expected values are "lacp" or "static" or "active-backup" which will bond eth1 and eth2 |
7 | 7 | if [ -z "$TMODE" ]; then |
8 | 8 | TMODE='none' |
9 | 9 | fi |
10 | 10 |
|
| 11 | +# TACTIVE and TBACKUP to be set via the containerlab topology file for active-backup runner |
| 12 | +# expected values are "eth1" or "eth2" default is "eth1" active and "eth2" backup |
| 13 | +if [ -z "$TACTIVE" ]; then |
| 14 | + TACTIVE='eth1' |
| 15 | + TBACKUP='eth2' |
| 16 | +elif [ "$TACTIVE" == 'eth1' ]; then |
| 17 | + TBACKUP='eth2' |
| 18 | +elif [ "$TACTIVE" == 'eth2' ]; then |
| 19 | + TBACKUP='eth1' |
| 20 | +fi |
| 21 | + |
11 | 22 | echo "teaming mode is " $TMODE |
12 | 23 |
|
13 | 24 | ####################### |
14 | 25 | # Re-run script as sudo |
15 | 26 | ####################### |
16 | 27 |
|
17 | 28 | if [ "$(id -u)" != "0" ]; then |
18 | | - exec sudo --preserve-env=TMODE "$0" "$@" |
| 29 | + exec sudo --preserve-env=TMODE,TACTIVE,TBACKUP "$0" "$@" |
19 | 30 | fi |
20 | 31 |
|
21 | 32 | ########################## |
@@ -78,13 +89,31 @@ cat << EOF > /home/alpine/teamd-static.conf |
78 | 89 | } |
79 | 90 | EOF |
80 | 91 |
|
| 92 | +cat << EOF > /home/alpine/teamd-active-backup.conf |
| 93 | +{ |
| 94 | + "device": "team0", |
| 95 | + "runner": {"name": "activebackup"}, |
| 96 | + "link_watch": {"name": "ethtool"}, |
| 97 | + "ports": { |
| 98 | + "$TACTIVE": { |
| 99 | + "prio": 100 |
| 100 | + }, |
| 101 | + "$TBACKUP": { |
| 102 | + "prio": -10 |
| 103 | + } |
| 104 | + } |
| 105 | +} |
| 106 | +EOF |
| 107 | + |
81 | 108 | if [ "$TMODE" == 'lacp' ]; then |
82 | 109 | TARG='/home/alpine/teamd-lacp.conf' |
83 | 110 | elif [ "$TMODE" == 'static' ]; then |
84 | 111 | TARG='/home/alpine/teamd-static.conf' |
| 112 | +elif [ "$TMODE" == 'active-backup' ]; then |
| 113 | + TARG='/home/alpine/teamd-active-backup.conf' |
85 | 114 | fi |
86 | 115 |
|
87 | | -if [ "$TMODE" == 'lacp' ] || [ "$TMODE" == 'static' ]; then |
| 116 | +if [ "$TMODE" == 'lacp' ] || [ "$TMODE" == 'static' ] || [ "$TMODE" == 'active-backup' ]; then |
88 | 117 | teamd -v |
89 | 118 | teamd -k -f $TARG |
90 | 119 | ip link set eth1 down |
|
0 commit comments