Changed DHCP table name to DHCP_RELAY
This commit is contained in:
parent
aa8eecb5ed
commit
e5b7b8c05e
@ -204,6 +204,7 @@ def parse_dpg(dpg, hname):
|
||||
vlan_intfs = []
|
||||
vlans = {}
|
||||
vlan_members = {}
|
||||
dhcp_relay_table = {}
|
||||
for vintf in vlanintfs.findall(str(QName(ns, "VlanInterface"))):
|
||||
vintfname = vintf.find(str(QName(ns, "Name"))).text
|
||||
vlanid = vintf.find(str(QName(ns, "VlanID"))).text
|
||||
@ -215,6 +216,7 @@ def parse_dpg(dpg, hname):
|
||||
vlan_members[(sonic_vlan_member_name, vmbr_list[i])] = {'tagging_mode': 'untagged'}
|
||||
|
||||
vlan_attributes = {'vlanid': vlanid}
|
||||
dhcp_attributes = {}
|
||||
|
||||
# If this VLAN requires a DHCP relay agent, it will contain a <DhcpRelays> element
|
||||
# containing a list of DHCP server IPs
|
||||
@ -229,34 +231,14 @@ def parse_dpg(dpg, hname):
|
||||
vintfdhcpservers = vintf_node.text
|
||||
vdhcpserver_list = vintfdhcpservers.split(';')
|
||||
vlan_attributes['dhcpv6_servers'] = vdhcpserver_list
|
||||
dhcp_attributes['dhcpv6_servers'] = vdhcpserver_list
|
||||
sonic_vlan_member_name = "Vlan%s" % (vlanid)
|
||||
dhcp_relay_table[sonic_vlan_member_name] = dhcp_attributes
|
||||
|
||||
sonic_vlan_name = "Vlan%s" % vlanid
|
||||
if sonic_vlan_name != vintfname:
|
||||
vlan_attributes['alias'] = vintfname
|
||||
vlans[sonic_vlan_name] = vlan_attributes
|
||||
|
||||
dhcp = child.find(str(QName(ns, "Dhcp")))
|
||||
dhcp_table = {}
|
||||
|
||||
if dhcp is not None:
|
||||
for vintf in dhcp.findall(str(QName(ns, "VlanInterface"))):
|
||||
vintfname = vintf.find(str(QName(ns, "Name"))).text
|
||||
|
||||
dhcp_attributes = {}
|
||||
|
||||
dhcp_node = vintf.find(str(QName(ns, "Dhcpv6Relays")))
|
||||
if dhcp_node is not None and dhcp_node.text is not None:
|
||||
dhcpservers = dhcp_node.text
|
||||
vdhcpserver_list = dhcpservers.split(';')
|
||||
dhcp_attributes['dhcpv6_servers'] = vdhcpserver_list
|
||||
|
||||
option_linklayer_addr = vintf.find(str(QName(ns, "Dhcpv6OptionRfc6939")))
|
||||
if option_linklayer_addr is not None and option_linklayer_addr.text == "true":
|
||||
dhcp_attributes['dhcpv6_option|rfc6939_support'] = "true"
|
||||
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
|
||||
|
||||
aclintfs = child.find(str(QName(ns, "AclInterfaces")))
|
||||
acls = {}
|
||||
@ -343,7 +325,7 @@ def parse_dpg(dpg, hname):
|
||||
except:
|
||||
print >> sys.stderr, "Warning: Ignoring Control Plane ACL %s without type" % aclname
|
||||
|
||||
return intfs, lo_intfs, mgmt_intf, vlans, vlan_members, dhcp_table, pcs, pc_members, acls
|
||||
return intfs, lo_intfs, mgmt_intf, vlans, vlan_members, dhcp_relay_table, pcs, pc_members, acls
|
||||
return None, None, None, None, None, None, None
|
||||
|
||||
|
||||
@ -555,7 +537,7 @@ def parse_xml(filename, platform=None, port_config_file=None):
|
||||
pc_intfs = None
|
||||
vlans = None
|
||||
vlan_members = None
|
||||
dhcp_table = None
|
||||
dhcp_relay_table = None
|
||||
pcs = None
|
||||
mgmt_intf = None
|
||||
lo_intf = None
|
||||
@ -593,7 +575,7 @@ def parse_xml(filename, platform=None, port_config_file=None):
|
||||
port_alias_map.update(alias_map)
|
||||
for child in root:
|
||||
if child.tag == str(QName(ns, "DpgDec")):
|
||||
(intfs, lo_intfs, mgmt_intf, vlans, vlan_members, dhcp_table, pcs, pc_members, acls) = parse_dpg(child, hostname)
|
||||
(intfs, lo_intfs, mgmt_intf, vlans, vlan_members, dhcp_relay_table, pcs, pc_members, acls) = parse_dpg(child, hostname)
|
||||
elif child.tag == str(QName(ns, "CpgDec")):
|
||||
(bgp_sessions, bgp_asn, bgp_peers_with_range, bgp_monitors) = parse_cpg(child, hostname)
|
||||
elif child.tag == str(QName(ns, "PngDec")):
|
||||
@ -767,7 +749,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['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)
|
||||
|
||||
|
@ -131,23 +131,12 @@
|
||||
<Name>ab1</Name>
|
||||
<AttachTo>fortyGigE0/8</AttachTo>
|
||||
<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>
|
||||
</VlanInterface>
|
||||
</VlanInterfaces>
|
||||
<Dhcp>
|
||||
<VlanInterface>
|
||||
<Name>Vlan1000</Name>
|
||||
<Dhcpv6Relays>fc02:2000::1;fc02:2000::2</Dhcpv6Relays>
|
||||
<Dhcpv6OptionRfc6939>true</Dhcpv6OptionRfc6939>
|
||||
</VlanInterface>
|
||||
<VlanInterface>
|
||||
<Name>Vlan2000</Name>
|
||||
<Dhcpv6Relays>fc02:2000::3;fc02:2000::4</Dhcpv6Relays>
|
||||
<Dhcpv6OptionRfc6939>false</Dhcpv6OptionRfc6939>
|
||||
</VlanInterface>
|
||||
</Dhcp>
|
||||
<IPInterfaces>
|
||||
<IPInterface>
|
||||
<Name i:nil="true"/>
|
||||
|
@ -336,10 +336,10 @@ class TestCfgGen(TestCase):
|
||||
self.assertEqual(output.strip(), "{'10.20.30.40': {'rrclient': 0, 'name': 'BGPMonitor', 'local_addr': '10.1.0.32', 'nhopself': 0, 'holdtime': '10', 'asn': '0', 'keepalive': '3'}}")
|
||||
|
||||
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(
|
||||
output.strip(),
|
||||
"{'Vlan1000': {'dhcpv6_option|rfc6939_support': 'true', 'dhcpv6_servers': ['fc02:2000::1', 'fc02:2000::2']}, 'Vlan2000': {'dhcpv6_option|rfc6939_support': 'false', 'dhcpv6_servers': ['fc02:2000::3', 'fc02:2000::4']}}"
|
||||
"{'Vlan1000': {'dhcpv6_servers': ['fc02:2000::1', 'fc02:2000::2']}}"
|
||||
)
|
||||
|
@ -73,7 +73,7 @@ class TestCfgGenCaseInsensitive(TestCase):
|
||||
def test_minigraph_vlans(self):
|
||||
argument = '-m "' + self.sample_graph + '" -p "' + self.port_config + '" -v VLAN'
|
||||
output = self.run_script(argument)
|
||||
self.assertEqual(output.strip(), "{'Vlan1000': {'alias': 'ab1', 'dhcp_servers': ['192.0.0.1', '192.0.0.2'], 'vlanid': '1000'}}")
|
||||
self.assertEqual(output.strip(), "{'Vlan1000': {'alias': 'ab1', 'dhcp_servers': ['192.0.0.1', '192.0.0.2'], 'vlanid': '1000', 'dhcpv6_servers': ['fc02:2000::1', 'fc02:2000::2']}}")
|
||||
|
||||
def test_minigraph_vlan_members(self):
|
||||
argument = '-m "' + self.sample_graph + '" -p "' + self.port_config + '" -v VLAN_MEMBER'
|
||||
@ -140,27 +140,11 @@ class TestCfgGenCaseInsensitive(TestCase):
|
||||
)
|
||||
|
||||
def test_dhcp_table(self):
|
||||
argument = '-m "' + self.sample_graph + '" -p "' + self.port_config + '" -v "DHCP"'
|
||||
expected = {
|
||||
'Vlan1000': {
|
||||
'dhcpv6_servers': [
|
||||
"fc02:2000::1",
|
||||
"fc02:2000::2"
|
||||
],
|
||||
'dhcpv6_option|rfc6939_support': 'true'
|
||||
},
|
||||
'Vlan2000': {
|
||||
'dhcpv6_servers': [
|
||||
"fc02:2000::3",
|
||||
"fc02:2000::4"
|
||||
],
|
||||
'dhcpv6_option|rfc6939_support': 'false'
|
||||
}
|
||||
}
|
||||
argument = '-m "' + self.sample_graph + '" -p "' + self.port_config + '" -v "DHCP_RELAY"'
|
||||
output = self.run_script(argument)
|
||||
self.assertEqual(
|
||||
output.strip(),
|
||||
"{'Vlan1000': {'dhcpv6_option|rfc6939_support': 'true', 'dhcpv6_servers': ['fc02:2000::1', 'fc02:2000::2']}, 'Vlan2000': {'dhcpv6_option|rfc6939_support': 'false', 'dhcpv6_servers': ['fc02:2000::3', 'fc02:2000::4']}}"
|
||||
"{'Vlan1000': {'dhcpv6_servers': ['fc02:2000::1', 'fc02:2000::2']}}"
|
||||
)
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user