Skip to content

Commit

Permalink
[sonic-cfggen]: Fix minigraph DhcpRelays parsing issue (#2154)
Browse files Browse the repository at this point in the history
* Check that we have dhcprelays text before using it

* Add additional variable to avoid extracting node again and again
  • Loading branch information
pavel-shirshov authored Oct 16, 2018
1 parent e2ffb58 commit bcea4b3
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/sonic-config-engine/minigraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,9 @@ def parse_dpg(dpg, hname):

# If this VLAN requires a DHCP relay agent, it will contain a <DhcpRelays> element
# containing a list of DHCP server IPs
if vintf.find(str(QName(ns, "DhcpRelays"))) is not None:
vintfdhcpservers = vintf.find(str(QName(ns, "DhcpRelays"))).text
vintf_node = vintf.find(str(QName(ns, "DhcpRelays")))
if vintf_node is not None and vintf_node.text is not None:
vintfdhcpservers = vintf_node.text
vdhcpserver_list = vintfdhcpservers.split(';')
vlan_attributes['dhcp_servers'] = vdhcpserver_list

Expand Down

0 comments on commit bcea4b3

Please sign in to comment.