From 3b27afe377f8708174247796ce0f471b76d0c60f Mon Sep 17 00:00:00 2001 From: Lawrence Lee Date: Fri, 20 Nov 2020 17:04:01 -0800 Subject: [PATCH] [minigraph.py]: Add VLAN_INTERFACE attributes for dual ToR devices (#5951) * If a device has subtype = 'DualToR', then enable proxy ARP and gratuitous ARP. --- src/sonic-config-engine/minigraph.py | 18 ++++++++++++++++-- .../tests/test_minigraph_case.py | 14 +++++++++++++- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/src/sonic-config-engine/minigraph.py b/src/sonic-config-engine/minigraph.py index 7aa51304d2ea..caf687ac7e8d 100644 --- a/src/sonic-config-engine/minigraph.py +++ b/src/sonic-config-engine/minigraph.py @@ -1092,10 +1092,24 @@ def parse_xml(filename, platform=None, port_config_file=None, asic_name=None, hw for intf in intfs: if intf[0][0:4] == 'Vlan': vlan_intfs[intf] = {} - vlan_intfs[intf[0]] = {} + + if bool(results['PEER_SWITCH']): + vlan_intfs[intf[0]] = { + 'proxy_arp': 'enabled', + 'grat_arp': 'enabled' + } + else: + vlan_intfs[intf[0]] = {} elif intf[0] in vlan_invert_mapping: vlan_intfs[(vlan_invert_mapping[intf[0]], intf[1])] = {} - vlan_intfs[vlan_invert_mapping[intf[0]]] = {} + + if bool(results['PEER_SWITCH']): + vlan_intfs[vlan_invert_mapping[intf[0]]] = { + 'proxy_arp': 'enabled', + 'grat_arp': 'enabled' + } + else: + vlan_intfs[vlan_invert_mapping[intf[0]]] = {} elif intf[0][0:11] == 'PortChannel': pc_intfs[intf] = {} pc_intfs[intf[0]] = {} diff --git a/src/sonic-config-engine/tests/test_minigraph_case.py b/src/sonic-config-engine/tests/test_minigraph_case.py index 586ded0ebec9..d24ec501bba6 100644 --- a/src/sonic-config-engine/tests/test_minigraph_case.py +++ b/src/sonic-config-engine/tests/test_minigraph_case.py @@ -96,11 +96,23 @@ def test_minigraph_vlan_members(self): output = self.run_script(argument) self.assertEqual(output.strip(), "{('Vlan1000', 'Ethernet8'): {'tagging_mode': 'untagged'}}") - def test_minigraph_vlan_interfaces(self): + def test_minigraph_vlan_interfaces_keys(self): argument = '-m "' + self.sample_graph + '" -p "' + self.port_config + '" -v "VLAN_INTERFACE.keys()|list"' output = self.run_script(argument) self.assertEqual(output.strip(), "[('Vlan1000', '192.168.0.1/27'), 'Vlan1000']") + def test_minigraph_vlan_interfaces(self): + argument = '-m "' + self.sample_graph + '" -p "' + self.port_config + '" -v "VLAN_INTERFACE"' + output = self.run_script(argument) + expected_table = { + 'Vlan1000|192.168.0.1/27': {}, + 'Vlan1000': { + 'proxy_arp': 'enabled', + 'grat_arp': 'enabled' + } + } + self.assertEqual(utils.to_dict(output.strip()), expected_table) + def test_minigraph_portchannels(self): argument = '-m "' + self.sample_graph + '" -p "' + self.port_config + '" -v PORTCHANNEL' output = self.run_script(argument)