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

[teamd]: Add teammgrd in docker-teamd #2064

Merged
merged 1 commit into from
Oct 19, 2018
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 1 addition & 2 deletions dockers/docker-teamd/Dockerfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
38 changes: 4 additions & 34 deletions dockers/docker-teamd/start.sh
Original file line number Diff line number Diff line change
@@ -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
12 changes: 10 additions & 2 deletions dockers/docker-teamd/supervisord.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 0 additions & 25 deletions dockers/docker-teamd/teamd.j2

This file was deleted.

28 changes: 0 additions & 28 deletions dockers/docker-teamd/teamd.sh

This file was deleted.

16 changes: 0 additions & 16 deletions files/image_config/interfaces/interfaces.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
2 changes: 2 additions & 0 deletions platform/vs/docker-sonic-vs/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ supervisorctl start teamsyncd

supervisorctl start fpmsyncd

supervisorctl start teammgrd

supervisorctl start portmgrd

supervisorctl start intfmgrd
Expand Down
8 changes: 8 additions & 0 deletions platform/vs/docker-sonic-vs/supervisord.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 0 additions & 26 deletions src/sonic-config-engine/tests/sample_output/interfaces
Original file line number Diff line number Diff line change
Expand Up @@ -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
#

This file was deleted.

29 changes: 0 additions & 29 deletions src/sonic-config-engine/tests/test_j2files.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,35 +75,6 @@ def test_config_frr(self):
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
Expand Down
2 changes: 1 addition & 1 deletion src/sonic-swss