[config]: Fix the device type and internal bgp session status for multi NPU platforms (#4600)
* The following changes for multi-npu platforms are done - Set the type in device_metadata for asic configuration to be same as host - Set the admin-status of internal bgp sessions as up Signed-off-by: Arvindsrinivasan Lakshmi Narasimhan <arlakshm@microsoft.com>
This commit is contained in:
parent
bce42a7595
commit
eb97dccb88
@ -749,6 +749,21 @@ def filter_acl_table_bindings(acls, neighbors, port_channels, sub_role):
|
|||||||
|
|
||||||
return filter_acls
|
return filter_acls
|
||||||
|
|
||||||
|
def enable_internal_bgp_session(bgp_sessions, filename, asic_name):
|
||||||
|
'''
|
||||||
|
In Multi-NPU session the internal sessions will always be up.
|
||||||
|
So adding the admin-status 'up' configuration to bgp sessions
|
||||||
|
BGP session between FrontEnd and BackEnd Asics are internal bgp sessions
|
||||||
|
'''
|
||||||
|
local_sub_role = parse_asic_sub_role(filename, asic_name)
|
||||||
|
|
||||||
|
for peer_ip in bgp_sessions.keys():
|
||||||
|
peer_name = bgp_sessions[peer_ip]['name']
|
||||||
|
peer_sub_role = parse_asic_sub_role(filename, peer_name)
|
||||||
|
if ((local_sub_role == FRONTEND_ASIC_SUB_ROLE and peer_sub_role == BACKEND_ASIC_SUB_ROLE) or
|
||||||
|
(local_sub_role == BACKEND_ASIC_SUB_ROLE and peer_sub_role == FRONTEND_ASIC_SUB_ROLE)):
|
||||||
|
bgp_sessions[peer_ip].update({'admin_status': 'up'})
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
#
|
#
|
||||||
# Main functions
|
# Main functions
|
||||||
@ -842,6 +857,7 @@ def parse_xml(filename, platform=None, port_config_file=None, asic_name=None):
|
|||||||
(intfs, lo_intfs, mvrf, mgmt_intf, vlans, vlan_members, pcs, pc_members, acls, vni) = parse_dpg(child, asic_name)
|
(intfs, lo_intfs, mvrf, mgmt_intf, vlans, vlan_members, pcs, pc_members, acls, vni) = parse_dpg(child, asic_name)
|
||||||
elif child.tag == str(QName(ns, "CpgDec")):
|
elif child.tag == str(QName(ns, "CpgDec")):
|
||||||
(bgp_sessions, bgp_asn, bgp_peers_with_range, bgp_monitors) = parse_cpg(child, asic_name)
|
(bgp_sessions, bgp_asn, bgp_peers_with_range, bgp_monitors) = parse_cpg(child, asic_name)
|
||||||
|
enable_internal_bgp_session(bgp_sessions, filename, asic_name)
|
||||||
elif child.tag == str(QName(ns, "PngDec")):
|
elif child.tag == str(QName(ns, "PngDec")):
|
||||||
(neighbors, devices, port_speed_png) = parse_asic_png(child, asic_name, hostname)
|
(neighbors, devices, port_speed_png) = parse_asic_png(child, asic_name, hostname)
|
||||||
elif child.tag == str(QName(ns, "MetadataDeclaration")):
|
elif child.tag == str(QName(ns, "MetadataDeclaration")):
|
||||||
@ -851,6 +867,8 @@ def parse_xml(filename, platform=None, port_config_file=None, asic_name=None):
|
|||||||
elif child.tag == str(QName(ns, "DeviceInfos")):
|
elif child.tag == str(QName(ns, "DeviceInfos")):
|
||||||
(port_speeds_default, port_descriptions) = parse_deviceinfo(child, hwsku)
|
(port_speeds_default, port_descriptions) = parse_deviceinfo(child, hwsku)
|
||||||
|
|
||||||
|
# set the host device type in asic metadata also
|
||||||
|
device_type = [devices[key]['type'] for key in devices if key.lower() == hostname.lower()][0]
|
||||||
if asic_name is None:
|
if asic_name is None:
|
||||||
current_device = [devices[key] for key in devices if key.lower() == hostname.lower()][0]
|
current_device = [devices[key] for key in devices if key.lower() == hostname.lower()][0]
|
||||||
else:
|
else:
|
||||||
@ -864,7 +882,7 @@ def parse_xml(filename, platform=None, port_config_file=None, asic_name=None):
|
|||||||
'docker_routing_config_mode': docker_routing_config_mode,
|
'docker_routing_config_mode': docker_routing_config_mode,
|
||||||
'hostname': hostname,
|
'hostname': hostname,
|
||||||
'hwsku': hwsku,
|
'hwsku': hwsku,
|
||||||
'type': current_device['type']
|
'type': device_type
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
# for this hostname, if sub_role is defined, add sub_role in
|
# for this hostname, if sub_role is defined, add sub_role in
|
||||||
|
@ -9,7 +9,7 @@ SKU = 'multi-npu-01'
|
|||||||
ASIC_SKU = 'multi-npu-asic'
|
ASIC_SKU = 'multi-npu-asic'
|
||||||
NUM_ASIC = 4
|
NUM_ASIC = 4
|
||||||
HOSTNAME = 'multi_npu_platform_01'
|
HOSTNAME = 'multi_npu_platform_01'
|
||||||
|
DEVICE_TYPE = 'LeafRouter'
|
||||||
|
|
||||||
class TestMultiNpuCfgGen(TestCase):
|
class TestMultiNpuCfgGen(TestCase):
|
||||||
|
|
||||||
@ -197,16 +197,16 @@ class TestMultiNpuCfgGen(TestCase):
|
|||||||
output = json.loads(self.run_script(argument))
|
output = json.loads(self.run_script(argument))
|
||||||
self.assertDictEqual(output, \
|
self.assertDictEqual(output, \
|
||||||
{'10.0.0.1': {'rrclient': 0, 'name': '01T2', 'local_addr': '10.0.0.0', 'nhopself': 0, 'holdtime': '10', 'asn': '65200', 'keepalive': '3'},
|
{'10.0.0.1': {'rrclient': 0, 'name': '01T2', 'local_addr': '10.0.0.0', 'nhopself': 0, 'holdtime': '10', 'asn': '65200', 'keepalive': '3'},
|
||||||
'10.1.0.0': {'rrclient': 0, 'name': 'ASIC2', 'local_addr': '10.1.0.1', 'nhopself': 0, 'holdtime': '0', 'asn': '65100', 'keepalive': '0'},
|
'10.1.0.0': {'rrclient': 0, 'name': 'ASIC2', 'local_addr': '10.1.0.1', 'nhopself': 0, 'holdtime': '0', 'asn': '65100', 'keepalive': '0', 'admin_status': 'up'},
|
||||||
'fc00::2': {'rrclient': 0, 'name': '01T2', 'local_addr': 'fc00::1', 'nhopself': 0, 'holdtime': '10', 'asn': '65200', 'keepalive': '3'},
|
'fc00::2': {'rrclient': 0, 'name': '01T2', 'local_addr': 'fc00::1', 'nhopself': 0, 'holdtime': '10', 'asn': '65200', 'keepalive': '3'},
|
||||||
'10.1.0.2': {'rrclient': 0, 'name': 'ASIC3', 'local_addr': '10.1.0.3', 'nhopself': 0, 'holdtime': '0', 'asn': '65100', 'keepalive': '0'}})
|
'10.1.0.2': {'rrclient': 0, 'name': 'ASIC3', 'local_addr': '10.1.0.3', 'nhopself': 0, 'holdtime': '0', 'asn': '65100', 'keepalive': '0', 'admin_status': 'up'}})
|
||||||
|
|
||||||
def test_backend_asic_bgp_neighbor(self):
|
def test_backend_asic_bgp_neighbor(self):
|
||||||
argument = "-m {} -p {} -n asic3 --var-json \"BGP_NEIGHBOR\"".format(self.sample_graph, self.port_config[3])
|
argument = "-m {} -p {} -n asic3 --var-json \"BGP_NEIGHBOR\"".format(self.sample_graph, self.port_config[3])
|
||||||
output = json.loads(self.run_script(argument))
|
output = json.loads(self.run_script(argument))
|
||||||
self.assertDictEqual(output, \
|
self.assertDictEqual(output, \
|
||||||
{'10.1.0.7': {'rrclient': 0, 'name': 'ASIC1', 'local_addr': '10.1.0.6', 'nhopself': 0, 'holdtime': '0', 'asn': '65100', 'keepalive': '0'},
|
{'10.1.0.7': {'rrclient': 0, 'name': 'ASIC1', 'local_addr': '10.1.0.6', 'nhopself': 0, 'holdtime': '0', 'asn': '65100', 'keepalive': '0', 'admin_status': 'up'},
|
||||||
'10.1.0.3': {'rrclient': 0, 'name': 'ASIC0', 'local_addr': '10.1.0.2', 'nhopself': 0, 'holdtime': '0', 'asn': '65100', 'keepalive': '0'}})
|
'10.1.0.3': {'rrclient': 0, 'name': 'ASIC0', 'local_addr': '10.1.0.2', 'nhopself': 0, 'holdtime': '0', 'asn': '65100', 'keepalive': '0', 'admin_status': 'up'}})
|
||||||
|
|
||||||
def test_device_asic_metadata(self):
|
def test_device_asic_metadata(self):
|
||||||
argument = "-m {} --var-json DEVICE_METADATA".format(self.sample_graph)
|
argument = "-m {} --var-json DEVICE_METADATA".format(self.sample_graph)
|
||||||
@ -215,7 +215,7 @@ class TestMultiNpuCfgGen(TestCase):
|
|||||||
asic_name = "asic{}".format(asic)
|
asic_name = "asic{}".format(asic)
|
||||||
self.assertEqual(output['localhost']['hostname'], 'multi_npu_platform_01')
|
self.assertEqual(output['localhost']['hostname'], 'multi_npu_platform_01')
|
||||||
self.assertEqual(output['localhost']['asic_name'], asic_name)
|
self.assertEqual(output['localhost']['asic_name'], asic_name)
|
||||||
self.assertEqual(output['localhost']['type'], 'Asic')
|
self.assertEqual(output['localhost']['type'], DEVICE_TYPE)
|
||||||
if asic == 0 or asic == 1:
|
if asic == 0 or asic == 1:
|
||||||
self.assertEqual(output['localhost']['sub_role'], 'FrontEnd')
|
self.assertEqual(output['localhost']['sub_role'], 'FrontEnd')
|
||||||
else:
|
else:
|
||||||
|
Reference in New Issue
Block a user