Skip to content

Changed DHCP table name to DHCP_RELAY #8476

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 20, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions src/sonic-config-engine/minigraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -577,11 +577,11 @@ def parse_dpg(dpg, hname):
vlan_attributes['alias'] = vintfname
vlans[sonic_vlan_name] = vlan_attributes

dhcp = child.find(str(QName(ns, "Dhcp")))
dhcp_table = {}
dhcp_relay = child.find(str(QName(ns, "DhcpRelay")))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I missed that earlier. There will no new node in the minigraph with DhcpRelay name. The server/helper IPs will be provided as follows:

<VlanInterfaces>
<VlanInterface>
<ElementType>VlanInterface</ElementType>
<Name>Vlan2</Name>
<AttachTo>Ethernet2/1;Ethernet2/3;Ethernet4/1;Ethernet4/3;Ethernet6/1;Ethernet6/3;Ethernet12/1;Ethernet12/3;Ethernet14/1;Ethernet14/3;Ethernet16/1;Ethernet16/3;Ethernet18/1;Ethernet18/3;Ethernet20/1;Ethernet20/3;Ethernet22/1;Ethernet22/3;Ethernet28/1;Ethernet28/3;Ethernet30/1;Ethernet30/3;Ethernet32/1;Ethernet32/3;Ethernet1/1;Ethernet3/1;Ethernet5/1;Ethernet11/1;Ethernet13/1;Ethernet15/1;Ethernet17/1;Ethernet19/1;Ethernet21/1;Ethernet27/1;Ethernet29/1;Ethernet31/1</AttachTo>
<FhrpProtoType i:nil="true"/>
<Type i:nil="true"/>
<DhcpRelays>13.107.194.100;13.107.194.101;13.107.194.102;13.107.194.103;10.254.32.207;10.254.32.223;10.254.32.95;10.254.32.127;10.254.32.191;10.254.32.159;10.254.45.31;10.254.45.63</DhcpRelays>
<Dhcpv6Relays>2603:10e1:0:1::;2603:10e1:0:1::1;2603:10e1:0:1::2;2603:10e1:0:1::3</Dhcpv6Relays>
<VlanID>2</VlanID>
<Tag>2</Tag>
<Subnets>25.99.157.0/26</Subnets>
<MacAddress i:nil="true"/>
<SecondarySubnets/>
</VlanInterface>
</VlanInterfaces>

dhcp_relay_table = {}

if dhcp is not None:
for vintf in dhcp.findall(str(QName(ns, "VlanInterface"))):
if dhcp_relay is not None:
for vintf in dhcp_relay.findall(str(QName(ns, "VlanInterface"))):
vintfname = vintf.find(str(QName(ns, "Name"))).text

dhcp_attributes = {}
Expand All @@ -598,7 +598,7 @@ def parse_dpg(dpg, hname):
elif option_linklayer_addr is not None and option_linklayer_addr.text == "false":
dhcp_attributes['dhcpv6_option|rfc6939_support'] = "false"

dhcp_table[vintfname] = dhcp_attributes
dhcp_relay_table[vintfname] = dhcp_attributes

acls = {}
for aclintf in aclintfs.findall(str(QName(ns, "AclInterface"))):
Expand Down Expand Up @@ -714,7 +714,7 @@ def parse_dpg(dpg, hname):
if mg_key in mg_tunnel.attrib:
tunnelintfs[tunnel_type][tunnel_name][table_key] = mg_tunnel.attrib[mg_key]

return intfs, lo_intfs, mvrf, mgmt_intf, voq_inband_intfs, vlans, vlan_members, dhcp_table, pcs, pc_members, acls, vni, tunnelintfs, dpg_ecmp_content
return intfs, lo_intfs, mvrf, mgmt_intf, voq_inband_intfs, vlans, vlan_members, dhcp_relay_table, pcs, pc_members, acls, vni, tunnelintfs, dpg_ecmp_content
return None, None, None, None, None, None, None, None, None, None, None, None, None

def parse_host_loopback(dpg, hname):
Expand Down Expand Up @@ -1182,7 +1182,7 @@ def parse_xml(filename, platform=None, port_config_file=None, asic_name=None, hw
tunnel_intfs = None
vlans = None
vlan_members = None
dhcp_table = None
dhcp_relay_table = None
pcs = None
mgmt_intf = None
voq_inband_intfs = None
Expand Down Expand Up @@ -1241,7 +1241,7 @@ def parse_xml(filename, platform=None, port_config_file=None, asic_name=None, hw
for child in root:
if asic_name is None:
if child.tag == str(QName(ns, "DpgDec")):
(intfs, lo_intfs, mvrf, mgmt_intf, voq_inband_intfs, vlans, vlan_members, dhcp_table, pcs, pc_members, acls, vni, tunnel_intfs, dpg_ecmp_content) = parse_dpg(child, hostname)
(intfs, lo_intfs, mvrf, mgmt_intf, voq_inband_intfs, vlans, vlan_members, dhcp_relay_table, pcs, pc_members, acls, vni, tunnel_intfs, dpg_ecmp_content) = parse_dpg(child, hostname)
elif child.tag == str(QName(ns, "CpgDec")):
(bgp_sessions, bgp_internal_sessions, bgp_voq_chassis_sessions, bgp_asn, bgp_peers_with_range, bgp_monitors) = parse_cpg(child, hostname)
elif child.tag == str(QName(ns, "PngDec")):
Expand All @@ -1256,7 +1256,7 @@ def parse_xml(filename, platform=None, port_config_file=None, asic_name=None, hw
(port_speeds_default, port_descriptions, sys_ports) = parse_deviceinfo(child, hwsku)
else:
if child.tag == str(QName(ns, "DpgDec")):
(intfs, lo_intfs, mvrf, mgmt_intf, voq_inband_intfs, vlans, vlan_members, dhcp_table, pcs, pc_members, acls, vni, tunnel_intfs, dpg_ecmp_content) = parse_dpg(child, asic_name)
(intfs, lo_intfs, mvrf, mgmt_intf, voq_inband_intfs, vlans, vlan_members, dhcp_relay_table, pcs, pc_members, acls, vni, tunnel_intfs, dpg_ecmp_content) = parse_dpg(child, asic_name)
host_lo_intfs = parse_host_loopback(child, hostname)
elif child.tag == str(QName(ns, "CpgDec")):
(bgp_sessions, bgp_internal_sessions, bgp_voq_chassis_sessions, bgp_asn, bgp_peers_with_range, bgp_monitors) = parse_cpg(child, asic_name, local_devices)
Expand Down Expand Up @@ -1604,7 +1604,7 @@ def parse_xml(filename, platform=None, port_config_file=None, asic_name=None, hw
results['DEVICE_NEIGHBOR_METADATA'] = { key:devices[key] for key in devices if key in {device['name'] for device in neighbors.values()} }
results['SYSLOG_SERVER'] = dict((item, {}) for item in syslog_servers)
results['DHCP_SERVER'] = dict((item, {}) for item in dhcp_servers)
results['DHCP'] = dhcp_table
results['DHCP_RELAY'] = dhcp_relay_table
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)
results['ACL_TABLE'] = filter_acl_table_bindings(acls, neighbors, pcs, sub_role)
Expand Down
4 changes: 2 additions & 2 deletions src/sonic-config-engine/tests/simple-sample-graph-case.xml
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@
<MacAddress i:nil="true"/>
</VlanInterface>
</VlanInterfaces>
<Dhcp>
<DhcpRelay>
<VlanInterface>
<Name>Vlan1000</Name>
<Dhcpv6Relays>fc02:2000::1;fc02:2000::2</Dhcpv6Relays>
Expand All @@ -159,7 +159,7 @@
<Dhcpv6Relays>fc02:2000::3;fc02:2000::4</Dhcpv6Relays>
<Dhcpv6OptionRfc6939>false</Dhcpv6OptionRfc6939>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the Dhcpv6OptionRfc6939 is not in the minigraph, however it will be in the config and is always on.

</VlanInterface>
</Dhcp>
</DhcpRelay>
<IPInterfaces>
<IPInterface>
<Name i:nil="true"/>
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 @@ -822,7 +822,7 @@ def test_minigraph_voq_inband_port(self):
)

def test_minigraph_dhcp(self):
argument = '-m "' + self.sample_graph_simple_case + '" -p "' + self.port_config + '" -v DHCP'
argument = '-m "' + self.sample_graph_simple_case + '" -p "' + self.port_config + '" -v DHCP_RELAY'
output = self.run_script(argument)
self.assertEqual(
utils.to_dict(output.strip()),
Expand Down
2 changes: 1 addition & 1 deletion src/sonic-config-engine/tests/test_minigraph_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ def test_minigraph_mux_cable_table(self):
)

def test_dhcp_table(self):
argument = '-m "' + self.sample_graph + '" -p "' + self.port_config + '" -v "DHCP"'
argument = '-m "' + self.sample_graph + '" -p "' + self.port_config + '" -v "DHCP_RELAY"'
expected = {
'Vlan1000': {
'dhcpv6_servers': [
Expand Down