diff --git a/dockers/docker-teamd/Dockerfile.j2 b/dockers/docker-teamd/Dockerfile.j2 index 1c3d9eea46..f18ff9eabb 100644 --- a/dockers/docker-teamd/Dockerfile.j2 +++ b/dockers/docker-teamd/Dockerfile.j2 @@ -25,9 +25,8 @@ RUN dpkg -i \ debs/{{ deb }}{{' '}} {%- endfor %} -COPY ["start.sh", "teamd.sh", "/usr/bin/"] +COPY ["start.sh", "/usr/bin/"] COPY ["supervisord.conf", "/etc/supervisor/conf.d/"] -COPY ["teamd.j2", "/usr/share/sonic/templates/"] RUN apt-get clean -y; apt-get autoclean -y; apt-get autoremove -y RUN rm -rf /debs diff --git a/dockers/docker-teamd/start.sh b/dockers/docker-teamd/start.sh index fb3b7c3dad..cfa2bdc2cb 100755 --- a/dockers/docker-teamd/start.sh +++ b/dockers/docker-teamd/start.sh @@ -1,40 +1,10 @@ #!/usr/bin/env bash -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 - rm -f /var/run/rsyslogd.pid +rm -f /var/run/teamd/* supervisorctl start rsyslogd -supervisorctl start teamd +supervisorctl start teammgrd + +supervisorctl start teamsyncd diff --git a/dockers/docker-teamd/supervisord.conf b/dockers/docker-teamd/supervisord.conf index 48ef0ca9f2..738751d0a5 100644 --- a/dockers/docker-teamd/supervisord.conf +++ b/dockers/docker-teamd/supervisord.conf @@ -19,8 +19,16 @@ autorestart=false stdout_logfile=syslog stderr_logfile=syslog -[program:teamd] -command=/usr/bin/teamd.sh +[program:teammgrd] +command=/usr/bin/teammgrd +priority=3 +autostart=false +autorestart=false +stdout_logfile=syslog +stderr_logfile=syslog + +[program:teamsyncd] +command=/usr/bin/teamsyncd priority=3 autostart=false autorestart=false diff --git a/dockers/docker-teamd/teamd.j2 b/dockers/docker-teamd/teamd.j2 deleted file mode 100644 index 9f53534a80..0000000000 --- a/dockers/docker-teamd/teamd.j2 +++ /dev/null @@ -1,25 +0,0 @@ -{ - "device": "{{ pc }}", - "hwaddr": "{{ hwaddr }}", - "runner": { - "name": "lacp", - "active": true, -{% if PORTCHANNEL[pc]['fallback'] and ((PORTCHANNEL[pc]['members'] | length) == 1) %} - "fallback": {{ PORTCHANNEL[pc]['fallback'] }}, -{% else %} -{# Use 75% links upperbound as min-links #} - "min_ports": {{ (PORTCHANNEL[pc]['members'] | length * 0.75) | round(0, 'ceil') | int }}, -{% endif %} - "tx_hash": ["eth", "ipv4", "ipv6"] - }, - "link_watch": { - "name": "ethtool" - }, - "ports": { -{% for member in PORTCHANNEL[pc]['members'] %} - "{{ member }}": {}{% if not loop.last %},{% endif %} - -{% endfor %} - } -} - diff --git a/dockers/docker-teamd/teamd.sh b/dockers/docker-teamd/teamd.sh deleted file mode 100755 index 1c080d24bb..0000000000 --- a/dockers/docker-teamd/teamd.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env bash - -TEAMD_CONF_PATH=/etc/teamd - -function start_app { - rm -f /var/run/teamd/* - if [ "$(ls -A $TEAMD_CONF_PATH)" ]; then - for f in $TEAMD_CONF_PATH/*; do - teamd -f $f -d -r - done - fi - teamsyncd & -} - -function clean_up { - if [ "$(ls -A $TEAMD_CONF_PATH)" ]; then - for f in $TEAMD_CONF_PATH/*; do - teamd -f $f -k - done - fi - pkill -9 teamsyncd - exit -} - -trap clean_up SIGTERM SIGKILL - -start_app -read diff --git a/files/image_config/interfaces/interfaces.j2 b/files/image_config/interfaces/interfaces.j2 index da2499ee50..e2ee58e9c3 100644 --- a/files/image_config/interfaces/interfaces.j2 +++ b/files/image_config/interfaces/interfaces.j2 @@ -48,19 +48,3 @@ iface eth0 inet dhcp {% endif %} # {% endblock mgmt_interface %} -{% block front_panel_interfaces %} -{% if PORTCHANNEL %} -# "|| true" is added to suppress the error when interface is already a member of LAG -# "ip link show | grep -q master" is added to ensure interface is enslaved -{% for pc in PORTCHANNEL.keys()|sort %} -{% for member in PORTCHANNEL[pc]['members'] %} -allow-hotplug {{ member }} -iface {{ member }} inet manual - pre-up teamdctl {{ pc }} port add {{ member }} || true - post-up ip link show {{ member }} | grep -q master && ifconfig {{ member }} up - post-down ifconfig {{ member }} down -# -{% endfor %} -{% endfor %} -{% endif %} -{% endblock front_panel_interfaces %} diff --git a/platform/vs/docker-sonic-vs/start.sh b/platform/vs/docker-sonic-vs/start.sh index f08888d8d7..83e818fe08 100755 --- a/platform/vs/docker-sonic-vs/start.sh +++ b/platform/vs/docker-sonic-vs/start.sh @@ -43,6 +43,8 @@ supervisorctl start teamsyncd supervisorctl start fpmsyncd +supervisorctl start teammgrd + supervisorctl start portmgrd supervisorctl start intfmgrd diff --git a/platform/vs/docker-sonic-vs/supervisord.conf b/platform/vs/docker-sonic-vs/supervisord.conf index 29283c7102..088684293c 100644 --- a/platform/vs/docker-sonic-vs/supervisord.conf +++ b/platform/vs/docker-sonic-vs/supervisord.conf @@ -99,6 +99,14 @@ autorestart=false stdout_logfile=syslog stderr_logfile=syslog +[program:teammgrd] +command=/usr/bin/teammgrd +priority=12 +autostart=false +autorestart=false +stdout_logfile=syslog +stderr_logfile=syslog + [program:zebra] command=/usr/lib/quagga/zebra -A 127.0.0.1 priority=13 diff --git a/src/sonic-config-engine/tests/sample_output/interfaces b/src/sonic-config-engine/tests/sample_output/interfaces index c471c0aa8d..4e53e2a518 100644 --- a/src/sonic-config-engine/tests/sample_output/interfaces +++ b/src/sonic-config-engine/tests/sample_output/interfaces @@ -47,30 +47,4 @@ iface eth0 inet6 static down ip -6 route delete 2603:10e2:0:2902::/64 dev eth0 table default down ip -6 rule delete from 2603:10e2:0:2902::8/128 table default # -# "|| true" is added to suppress the error when interface is already a member of LAG -# "ip link show | grep -q master" is added to ensure interface is enslaved -allow-hotplug fortyGigE0/112 -iface fortyGigE0/112 inet manual - pre-up teamdctl PortChannel01 port add fortyGigE0/112 || true - post-up ip link show fortyGigE0/112 | grep -q master && ifconfig fortyGigE0/112 up - post-down ifconfig fortyGigE0/112 down -# -allow-hotplug fortyGigE0/116 -iface fortyGigE0/116 inet manual - pre-up teamdctl PortChannel02 port add fortyGigE0/116 || true - post-up ip link show fortyGigE0/116 | grep -q master && ifconfig fortyGigE0/116 up - post-down ifconfig fortyGigE0/116 down -# -allow-hotplug fortyGigE0/120 -iface fortyGigE0/120 inet manual - pre-up teamdctl PortChannel03 port add fortyGigE0/120 || true - post-up ip link show fortyGigE0/120 | grep -q master && ifconfig fortyGigE0/120 up - post-down ifconfig fortyGigE0/120 down -# -allow-hotplug fortyGigE0/124 -iface fortyGigE0/124 inet manual - pre-up teamdctl PortChannel04 port add fortyGigE0/124 || true - post-up ip link show fortyGigE0/124 | grep -q master && ifconfig fortyGigE0/124 up - post-down ifconfig fortyGigE0/124 down -# diff --git a/src/sonic-config-engine/tests/sample_output/pc_sample_output/PortChannel01.conf b/src/sonic-config-engine/tests/sample_output/pc_sample_output/PortChannel01.conf deleted file mode 100644 index 618e9baad6..0000000000 --- a/src/sonic-config-engine/tests/sample_output/pc_sample_output/PortChannel01.conf +++ /dev/null @@ -1,20 +0,0 @@ -{ - "device": "PortChannel01", - "hwaddr": "e4:1d:2d:a5:f3:ad", - "runner": { - "name": "lacp", - "active": true, - "min_ports": 3, - "tx_hash": ["eth", "ipv4", "ipv6"] - }, - "link_watch": { - "name": "ethtool" - }, - "ports": { - "Ethernet112": {}, - "Ethernet116": {}, - "Ethernet120": {}, - "Ethernet124": {} - } -} - diff --git a/src/sonic-config-engine/tests/test_j2files.py b/src/sonic-config-engine/tests/test_j2files.py index 74e419e0c7..d6066b628e 100644 --- a/src/sonic-config-engine/tests/test_j2files.py +++ b/src/sonic-config-engine/tests/test_j2files.py @@ -75,35 +75,6 @@ class TestJ2Files(TestCase): self.run_script(argument) self.assertTrue(filecmp.cmp(os.path.join(self.test_dir, 'sample_output', 'frr.conf'), self.output_file)) - def test_teamd(self): - - def test_render_teamd(self, pc, minigraph, sample_output): - teamd_file = os.path.join(self.test_dir, '..', '..', '..', 'dockers', 'docker-teamd', 'teamd.j2') - argument = '-m ' + minigraph + ' -p ' + self.t0_port_config + ' -a \'{\"pc\":\"' + pc + '\",\"hwaddr\":\"e4:1d:2d:a5:f3:ad\"}\' -t ' + teamd_file + ' > ' + self.output_file - self.run_script(argument) - self.assertTrue(filecmp.cmp(sample_output, self.output_file)) - - # Test T0 minigraph - argument = '-m ' + self.t0_minigraph + ' -p ' + self.t0_port_config + ' -v "PORTCHANNEL.keys() | join(\' \') if PORTCHANNEL"' - output = self.run_script(argument) # Mock the output via config.sh in docker-teamd - pc_list = output.split() - - for i in range(1, 5): - pc_name = 'PortChannel0' + str(i) - self.assertTrue(pc_name in pc_list) - sample_output = os.path.join(self.test_dir, 'sample_output', 't0_sample_output', pc_name + '.conf') - test_render_teamd(self, pc_name, self.t0_minigraph, sample_output) - - # Test port channel test minigraph - argument = '-m ' + self.pc_minigraph + ' -p ' + self.t0_port_config + ' -v "PORTCHANNEL.keys() | join(\' \') if PORTCHANNEL"' - output = self.run_script(argument) # Mock the output via config.sh in docker-teamd - pc_list = output.split() - - pc_name = 'PortChannel01' - self.assertTrue(pc_name in pc_list) - sample_output = os.path.join(self.test_dir, 'sample_output', 'pc_sample_output', pc_name + '.conf') - test_render_teamd(self, pc_name, self.pc_minigraph, sample_output) - def test_ipinip(self): ipinip_file = os.path.join(self.test_dir, '..', '..', '..', 'dockers', 'docker-orchagent', 'ipinip.json.j2') argument = '-m ' + self.t0_minigraph + ' -p ' + self.t0_port_config + ' -t ' + ipinip_file + ' > ' + self.output_file diff --git a/src/sonic-swss b/src/sonic-swss index e1cc0de615..68a962903a 160000 --- a/src/sonic-swss +++ b/src/sonic-swss @@ -1 +1 @@ -Subproject commit e1cc0de6159d03bd3def4d4715ae1c93cd12a1e8 +Subproject commit 68a962903ae227d76c5367a7a3cacd4063893922