[docker-teamd]: Explicitly set LAG hwaddr (#664)

* [docker-teamd]: Explicitly set LAG hwaddr

Team device is initially created without any members and has a random HW
address, which is later changed to port's address. This configuration
sets team device's address explicitly to base MAC to avoid reassignment.

Signed-off-by: marian-pritsak <marianp@mellanox.com>

* Update teamd config tests with hwaddr

Signed-off-by: marian-pritsak <marianp@mellanox.com>

* Align HW addr byte for Centec and Mellanox

Signed-off-by: marian-pritsak <marianp@mellanox.com>

* Change HW addr to unicast in config tests

Signed-off-by: marian-pritsak <marianp@mellanox.com>
This commit is contained in:
Marian Pritsak 2017-06-07 02:13:38 +03:00 committed by lguohan
parent b968cf73a1
commit 820e7aafd0
7 changed files with 17 additions and 2 deletions

View File

@ -5,8 +5,18 @@ 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)
MAC_ADDRESS=$(ip link show eth0 | grep ether | awk '{print $2}')
# 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 -m /etc/sonic/minigraph.xml -v "minigraph_portchannels.keys() | join(' ')"`; do
sonic-cfggen -m /etc/sonic/minigraph.xml -a '{"pc":"'$pc'"}' -t /usr/share/sonic/templates/teamd.j2 > $TEAMD_CONF_PATH/$pc.conf
sonic-cfggen -m /etc/sonic/minigraph.xml -a '{"pc":"'$pc'","hwaddr":"'$MAC_ADDRESS'"}' -t /usr/share/sonic/templates/teamd.j2 > $TEAMD_CONF_PATH/$pc.conf
done
mkdir -p /var/sonic

View File

@ -1,5 +1,6 @@
{
"device": "{{ pc }}",
"hwaddr": "{{ hwaddr }}",
"runner": {
"name": "lacp",
"active": true,

View File

@ -1,5 +1,6 @@
{
"device": "PortChannel01",
"hwaddr": "e4:1d:2d:a5:f3:ad",
"runner": {
"name": "lacp",
"active": true,

View File

@ -1,5 +1,6 @@
{
"device": "PortChannel02",
"hwaddr": "e4:1d:2d:a5:f3:ad",
"runner": {
"name": "lacp",
"active": true,

View File

@ -1,5 +1,6 @@
{
"device": "PortChannel03",
"hwaddr": "e4:1d:2d:a5:f3:ad",
"runner": {
"name": "lacp",
"active": true,

View File

@ -1,5 +1,6 @@
{
"device": "PortChannel04",
"hwaddr": "e4:1d:2d:a5:f3:ad",
"runner": {
"name": "lacp",
"active": true,

View File

@ -37,7 +37,7 @@ class TestJ2Files(TestCase):
def test_render_teamd(self, pc):
teamd_file = os.path.join(self.test_dir, '..', '..', '..', 'dockers', 'docker-teamd', 'teamd.j2')
sample_output_file = os.path.join(self.test_dir, 'sample_output',pc + '.conf')
argument = '-m ' + self.t0_minigraph + ' -p ' + self.t0_port_config + ' -a \'{\"pc\":\"' + pc + '\"}\' -t ' + teamd_file + ' > ' + self.output_file
argument = '-m ' + self.t0_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)
assert filecmp.cmp(sample_output_file, self.output_file)