Skip to content

Commit

Permalink
[sonic-cfggen]: Fix minigraph.py when port_alias_map absent (#738)
Browse files Browse the repository at this point in the history
  • Loading branch information
Shuotian Cheng authored Jun 22, 2017
1 parent a8e3d97 commit 5c85270
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/sonic-config-engine/minigraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,7 @@ def parse_dpg(dpg, hname):
intfs = []
for ipintf in ipintfs.findall(str(QName(ns, "IPInterface"))):
intfalias = ipintf.find(str(QName(ns, "AttachTo"))).text
if port_alias_map.has_key(intfalias):
intfname = port_alias_map[intfalias]
else:
intfname = intfalias
intfname = port_alias_map.get(intfalias, intfalias)
ipprefix = ipintf.find(str(QName(ns, "Prefix"))).text
ipn = ipaddress.IPNetwork(ipprefix)
ipaddr = ipn.ip
Expand Down Expand Up @@ -198,7 +195,7 @@ def parse_dpg(dpg, hname):
pcintfmbr = pcintf.find(str(QName(ns, "AttachTo"))).text
pcmbr_list = pcintfmbr.split(';')
for i, member in enumerate(pcmbr_list):
pcmbr_list[i] = port_alias_map[member]
pcmbr_list[i] = port_alias_map.get(member, member)
pcs[pcintfname] = {'name': pcintfname, 'members': pcmbr_list}

vlanintfs = child.find(str(QName(ns, "VlanInterfaces")))
Expand All @@ -210,7 +207,7 @@ def parse_dpg(dpg, hname):
vintfmbr = vintf.find(str(QName(ns, "AttachTo"))).text
vmbr_list = vintfmbr.split(';')
for i, member in enumerate(vmbr_list):
vmbr_list[i] = port_alias_map[member]
vmbr_list[i] = port_alias_map.get(member, member)
vlan_attributes = {'name': vintfname, 'members': vmbr_list, 'vlanid': vlanid}
sonic_vlan_name = "Vlan%s" % vlanid
vlans[sonic_vlan_name] = vlan_attributes
Expand Down

0 comments on commit 5c85270

Please sign in to comment.