Skip to content

Commit

Permalink
[201811] Add DHCPv6 minigraph parsing support (#8970)
Browse files Browse the repository at this point in the history
* Add DHCPv6 minigraph parsing support

Co-authored-by: shlomibitton <60430976+shlomibitton@users.noreply.github.com>
  • Loading branch information
kellyyeh and shlomibitton authored Oct 14, 2021
1 parent 1823b85 commit 9ca2674
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/sonic-config-engine/minigraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,12 @@ def parse_dpg(dpg, hname):
vdhcpserver_list = vintfdhcpservers.split(';')
vlan_attributes['dhcp_servers'] = vdhcpserver_list

vintf_node = vintf.find(str(QName(ns, "Dhcpv6Relays")))
if vintf_node is not None and vintf_node.text is not None:
vintfdhcpservers = vintf_node.text
vdhcpserver_list = vintfdhcpservers.split(';')
vlan_attributes['dhcpv6_servers'] = vdhcpserver_list

sonic_vlan_name = "Vlan%s" % vlanid
if sonic_vlan_name != vintfname:
vlan_attributes['alias'] = vintfname
Expand Down Expand Up @@ -393,6 +399,7 @@ def parse_cpg(cpg, hname):
def parse_meta(meta, hname):
syslog_servers = []
dhcp_servers = []
dhcpv6_servers = []
ntp_servers = []
tacacs_servers = []
mgmt_routes = []
Expand Down Expand Up @@ -420,7 +427,7 @@ def parse_meta(meta, hname):
erspan_dst = value_group
elif name == "DeploymentId":
deployment_id = value
return syslog_servers, dhcp_servers, ntp_servers, tacacs_servers, mgmt_routes, erspan_dst, deployment_id
return syslog_servers, dhcp_servers, dhcpv6_servers, ntp_servers, tacacs_servers, mgmt_routes, erspan_dst, deployment_id


def parse_linkmeta(meta, hname):
Expand Down Expand Up @@ -538,6 +545,7 @@ def parse_xml(filename, platform=None, port_config_file=None):
console_ports = {}
syslog_servers = []
dhcp_servers = []
dhcpv6_servers = []
ntp_servers = []
tacacs_servers = []
mgmt_routes = []
Expand Down Expand Up @@ -569,7 +577,7 @@ def parse_xml(filename, platform=None, port_config_file=None):
elif child.tag == str(QName(ns, "UngDec")):
(u_neighbors, u_devices, _, _, _, _, _, _) = parse_png(child, hostname)
elif child.tag == str(QName(ns, "MetadataDeclaration")):
(syslog_servers, dhcp_servers, ntp_servers, tacacs_servers, mgmt_routes, erspan_dst, deployment_id) = parse_meta(child, hostname)
(syslog_servers, dhcp_servers, dhcpv6_servers, ntp_servers, tacacs_servers, mgmt_routes, erspan_dst, deployment_id) = parse_meta(child, hostname)
elif child.tag == str(QName(ns, "LinkMetadataDeclaration")):
linkmetas = parse_linkmeta(child, hostname)
elif child.tag == str(QName(ns, "DeviceInfos")):
Expand Down Expand Up @@ -735,6 +743,7 @@ def parse_xml(filename, platform=None, port_config_file=None):
results['DEVICE_NEIGHBOR_METADATA'] = { key:devices[key] for key in devices if key.lower() != hostname.lower() }
results['SYSLOG_SERVER'] = dict((item, {}) for item in syslog_servers)
results['DHCP_SERVER'] = dict((item, {}) for item in dhcp_servers)
results['DHCPv6_SERVER'] = dict((item, {}) for item in dhcpv6_servers)
results['NTP_SERVER'] = dict((item, {}) for item in ntp_servers)
results['TACPLUS_SERVER'] = dict((item, {'priority': '1', 'tcp_port': '49'}) for item in tacacs_servers)

Expand Down
1 change: 1 addition & 0 deletions src/sonic-config-engine/tests/t0-sample-graph.xml
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@
<FhrpProtoType i:nil="true"/>
<Type i:nil="true"/>
<DhcpRelays>192.0.0.1;192.0.0.2</DhcpRelays>
<Dhcpv6Relays>fc02:2000::1;fc02:2000::2</Dhcpv6Relays>
<VlanID>1000</VlanID>
<Tag>1000</Tag>
<Subnets>192.168.0.0/27</Subnets>
Expand Down

0 comments on commit 9ca2674

Please sign in to comment.