Skip to content

Commit

Permalink
Fix VLAN_INTERFACE attach issue upon vlan id-name mismatch (#1367)
Browse files Browse the repository at this point in the history
  • Loading branch information
taoyl-ms authored and lguohan committed Feb 7, 2018
1 parent d0dd80c commit 4925d48
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
6 changes: 6 additions & 0 deletions src/sonic-config-engine/minigraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ def parse_dpg(dpg, hname):
vlan_attributes['dhcp_servers'] = vdhcpserver_list

sonic_vlan_name = "Vlan%s" % vlanid
if sonic_vlan_name != vintfname:
vlan_attributes['alias'] = vintfname
vlans[sonic_vlan_name] = vlan_attributes

aclintfs = child.find(str(QName(ns, "AclInterfaces")))
Expand Down Expand Up @@ -398,9 +400,13 @@ def parse_xml(filename, platform=None, port_config_file=None):
phyport_intfs = {}
vlan_intfs = {}
pc_intfs = {}
vlan_invert_mapping = { v['alias']:k for k,v in vlans.items() if v.has_key('alias') }

for intf in intfs:
if intf[0][0:4] == 'Vlan':
vlan_intfs[intf] = {}
elif vlan_invert_mapping.has_key(intf[0]):
vlan_intfs[(vlan_invert_mapping[intf[0]], intf[1])] = {}
elif intf[0][0:11] == 'PortChannel':
pc_intfs[intf] = {}
else:
Expand Down
4 changes: 2 additions & 2 deletions src/sonic-config-engine/tests/simple-sample-graph.xml
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
</PortChannelInterfaces>
<VlanInterfaces>
<VlanInterface>
<Name>Vlan1000</Name>
<Name>ab1</Name>
<AttachTo>fortyGigE0/8</AttachTo>
<DhcpRelays>192.0.0.1;192.0.0.2</DhcpRelays>
<VlanID>1000</VlanID>
Expand Down Expand Up @@ -159,7 +159,7 @@
</IPInterface>
<IPInterface>
<Name i:nil="true"/>
<AttachTo>Vlan1000</AttachTo>
<AttachTo>ab1</AttachTo>
<Prefix>192.168.0.1/27</Prefix>
</IPInterface>
</IPInterfaces>
Expand Down
2 changes: 1 addition & 1 deletion src/sonic-config-engine/tests/test_cfggen.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def test_minigraph_interfaces(self):
def test_minigraph_vlans(self):
argument = '-m "' + self.sample_graph_simple + '" -p "' + self.port_config + '" -v VLAN'
output = self.run_script(argument)
self.assertEqual(output.strip(), "{'Vlan1000': {'dhcp_servers': ['192.0.0.1', '192.0.0.2'], 'vlanid': '1000'}}")
self.assertEqual(output.strip(), "{'Vlan1000': {'alias': 'ab1', 'dhcp_servers': ['192.0.0.1', '192.0.0.2'], 'vlanid': '1000'}}")

def test_minigraph_vlan_members(self):
argument = '-m "' + self.sample_graph_simple + '" -p "' + self.port_config + '" -v VLAN_MEMBER'
Expand Down

0 comments on commit 4925d48

Please sign in to comment.