[sonic-cfggen]: Fix minigraph DhcpRelays parsing issue (#2154)

* Check that we have dhcprelays text before using it

* Add additional variable to avoid extracting node again and again
This commit is contained in:
pavel-shirshov 2018-10-15 18:28:58 -07:00 committed by GitHub
parent e2ffb589ed
commit bcea4b3fa9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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