Skip to content

Commit

Permalink
[minigraph.py]: Add VLAN_INTERFACE attributes for dual ToR devices (#…
Browse files Browse the repository at this point in the history
…5951)

* If a device has subtype = 'DualToR', then enable proxy ARP and gratuitous ARP.
  • Loading branch information
theasianpianist authored Nov 21, 2020
1 parent 31404dc commit 3b27afe
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
18 changes: 16 additions & 2 deletions src/sonic-config-engine/minigraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]] = {}
Expand Down
14 changes: 13 additions & 1 deletion src/sonic-config-engine/tests/test_minigraph_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 3b27afe

Please sign in to comment.