Added Support for deployment_id parsing for Device Asic metadata (#11454)
What I did: Added Support for deployment_id parsing for Device Asic metadata. Why I did:- Deployment Id is used in BGP docker for FRR template generation. For multi-asic platforms running in namespace without deployment id as key in DEVICE_METADATA FRR template generation fails. This change is needed after this #10154 where if deployment_id is none we don't update DEVICE_METADA dictionary. How I verify:- Added unit-test.
This commit is contained in:
parent
d7101963f1
commit
1e387f1189
@ -1041,6 +1041,7 @@ def parse_asic_meta(meta, hname):
|
|||||||
switch_id = None
|
switch_id = None
|
||||||
switch_type = None
|
switch_type = None
|
||||||
max_cores = None
|
max_cores = None
|
||||||
|
deployment_id = None
|
||||||
macsec_profile = {}
|
macsec_profile = {}
|
||||||
device_metas = meta.find(str(QName(ns, "Devices")))
|
device_metas = meta.find(str(QName(ns, "Devices")))
|
||||||
for device in device_metas.findall(str(QName(ns1, "DeviceMetadata"))):
|
for device in device_metas.findall(str(QName(ns1, "DeviceMetadata"))):
|
||||||
@ -1057,10 +1058,12 @@ def parse_asic_meta(meta, hname):
|
|||||||
switch_type = value
|
switch_type = value
|
||||||
elif name == "MaxCores":
|
elif name == "MaxCores":
|
||||||
max_cores = value
|
max_cores = value
|
||||||
|
elif name == "DeploymentId":
|
||||||
|
deployment_id = value
|
||||||
elif name == 'MacSecProfile':
|
elif name == 'MacSecProfile':
|
||||||
macsec_profile = parse_macsec_profile(value)
|
macsec_profile = parse_macsec_profile(value)
|
||||||
|
|
||||||
return sub_role, switch_id, switch_type, max_cores, macsec_profile
|
return sub_role, switch_id, switch_type, max_cores, deployment_id, macsec_profile
|
||||||
|
|
||||||
def parse_deviceinfo(meta, hwsku):
|
def parse_deviceinfo(meta, hwsku):
|
||||||
port_speeds = {}
|
port_speeds = {}
|
||||||
@ -1414,7 +1417,7 @@ def parse_xml(filename, platform=None, port_config_file=None, asic_name=None, hw
|
|||||||
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")):
|
||||||
(sub_role, switch_id, switch_type, max_cores, macsec_profile) = parse_asic_meta(child, asic_name)
|
(sub_role, switch_id, switch_type, max_cores, deployment_id, macsec_profile) = parse_asic_meta(child, asic_name)
|
||||||
elif child.tag == str(QName(ns, "LinkMetadataDeclaration")):
|
elif child.tag == str(QName(ns, "LinkMetadataDeclaration")):
|
||||||
linkmetas = parse_linkmeta(child, hostname)
|
linkmetas = parse_linkmeta(child, hostname)
|
||||||
elif child.tag == str(QName(ns, "DeviceInfos")):
|
elif child.tag == str(QName(ns, "DeviceInfos")):
|
||||||
@ -1989,7 +1992,7 @@ def parse_asic_sub_role(filename, asic_name):
|
|||||||
root = ET.parse(filename).getroot()
|
root = ET.parse(filename).getroot()
|
||||||
for child in root:
|
for child in root:
|
||||||
if child.tag == str(QName(ns, "MetadataDeclaration")):
|
if child.tag == str(QName(ns, "MetadataDeclaration")):
|
||||||
sub_role, _, _, _, _= parse_asic_meta(child, asic_name)
|
sub_role, _, _, _, _, _= parse_asic_meta(child, asic_name)
|
||||||
return sub_role
|
return sub_role
|
||||||
|
|
||||||
def parse_asic_switch_type(filename, asic_name):
|
def parse_asic_switch_type(filename, asic_name):
|
||||||
@ -1997,7 +2000,7 @@ def parse_asic_switch_type(filename, asic_name):
|
|||||||
root = ET.parse(filename).getroot()
|
root = ET.parse(filename).getroot()
|
||||||
for child in root:
|
for child in root:
|
||||||
if child.tag == str(QName(ns, "MetadataDeclaration")):
|
if child.tag == str(QName(ns, "MetadataDeclaration")):
|
||||||
_, _, switch_type, _, _ = parse_asic_meta(child, asic_name)
|
_, _, switch_type, _, _, _ = parse_asic_meta(child, asic_name)
|
||||||
return switch_type
|
return switch_type
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@ -1465,6 +1465,11 @@
|
|||||||
<a:Reference i:nil="true"/>
|
<a:Reference i:nil="true"/>
|
||||||
<a:Value>FrontEnd</a:Value>
|
<a:Value>FrontEnd</a:Value>
|
||||||
</a:DeviceProperty>
|
</a:DeviceProperty>
|
||||||
|
<a:DeviceProperty>
|
||||||
|
<a:Name>DeploymentId</a:Name>
|
||||||
|
<a:Reference i:nil="true"/>
|
||||||
|
<a:Value>1</a:Value>
|
||||||
|
</a:DeviceProperty>
|
||||||
</a:Properties>
|
</a:Properties>
|
||||||
</a:DeviceMetadata>
|
</a:DeviceMetadata>
|
||||||
<a:DeviceMetadata>
|
<a:DeviceMetadata>
|
||||||
@ -1475,6 +1480,11 @@
|
|||||||
<a:Reference i:nil="true"/>
|
<a:Reference i:nil="true"/>
|
||||||
<a:Value>FrontEnd</a:Value>
|
<a:Value>FrontEnd</a:Value>
|
||||||
</a:DeviceProperty>
|
</a:DeviceProperty>
|
||||||
|
<a:DeviceProperty>
|
||||||
|
<a:Name>DeploymentId</a:Name>
|
||||||
|
<a:Reference i:nil="true"/>
|
||||||
|
<a:Value>1</a:Value>
|
||||||
|
</a:DeviceProperty>
|
||||||
</a:Properties>
|
</a:Properties>
|
||||||
</a:DeviceMetadata>
|
</a:DeviceMetadata>
|
||||||
<a:DeviceMetadata>
|
<a:DeviceMetadata>
|
||||||
@ -1485,6 +1495,11 @@
|
|||||||
<a:Reference i:nil="true"/>
|
<a:Reference i:nil="true"/>
|
||||||
<a:Value>FrontEnd</a:Value>
|
<a:Value>FrontEnd</a:Value>
|
||||||
</a:DeviceProperty>
|
</a:DeviceProperty>
|
||||||
|
<a:DeviceProperty>
|
||||||
|
<a:Name>DeploymentId</a:Name>
|
||||||
|
<a:Reference i:nil="true"/>
|
||||||
|
<a:Value>1</a:Value>
|
||||||
|
</a:DeviceProperty>
|
||||||
</a:Properties>
|
</a:Properties>
|
||||||
</a:DeviceMetadata>
|
</a:DeviceMetadata>
|
||||||
<a:DeviceMetadata>
|
<a:DeviceMetadata>
|
||||||
@ -1495,6 +1510,11 @@
|
|||||||
<a:Reference i:nil="true"/>
|
<a:Reference i:nil="true"/>
|
||||||
<a:Value>FrontEnd</a:Value>
|
<a:Value>FrontEnd</a:Value>
|
||||||
</a:DeviceProperty>
|
</a:DeviceProperty>
|
||||||
|
<a:DeviceProperty>
|
||||||
|
<a:Name>DeploymentId</a:Name>
|
||||||
|
<a:Reference i:nil="true"/>
|
||||||
|
<a:Value>1</a:Value>
|
||||||
|
</a:DeviceProperty>
|
||||||
</a:Properties>
|
</a:Properties>
|
||||||
</a:DeviceMetadata>
|
</a:DeviceMetadata>
|
||||||
<a:DeviceMetadata>
|
<a:DeviceMetadata>
|
||||||
@ -1505,6 +1525,11 @@
|
|||||||
<a:Reference i:nil="true"/>
|
<a:Reference i:nil="true"/>
|
||||||
<a:Value>BackEnd</a:Value>
|
<a:Value>BackEnd</a:Value>
|
||||||
</a:DeviceProperty>
|
</a:DeviceProperty>
|
||||||
|
<a:DeviceProperty>
|
||||||
|
<a:Name>DeploymentId</a:Name>
|
||||||
|
<a:Reference i:nil="true"/>
|
||||||
|
<a:Value>1</a:Value>
|
||||||
|
</a:DeviceProperty>
|
||||||
</a:Properties>
|
</a:Properties>
|
||||||
</a:DeviceMetadata>
|
</a:DeviceMetadata>
|
||||||
<a:DeviceMetadata>
|
<a:DeviceMetadata>
|
||||||
@ -1515,6 +1540,12 @@
|
|||||||
<a:Reference i:nil="true"/>
|
<a:Reference i:nil="true"/>
|
||||||
<a:Value>BackEnd</a:Value>
|
<a:Value>BackEnd</a:Value>
|
||||||
</a:DeviceProperty>
|
</a:DeviceProperty>
|
||||||
|
<a:DeviceProperty>
|
||||||
|
<a:Name>DeploymentId</a:Name>
|
||||||
|
<a:Reference i:nil="true"/>
|
||||||
|
<a:Value>1</a:Value>
|
||||||
|
</a:DeviceProperty>
|
||||||
|
|
||||||
</a:Properties>
|
</a:Properties>
|
||||||
</a:DeviceMetadata>
|
</a:DeviceMetadata>
|
||||||
</Devices>
|
</Devices>
|
||||||
|
@ -304,6 +304,7 @@ class TestMultiNpuCfgGen(TestCase):
|
|||||||
self.assertEqual(output['localhost']['sub_role'], 'FrontEnd')
|
self.assertEqual(output['localhost']['sub_role'], 'FrontEnd')
|
||||||
else:
|
else:
|
||||||
self.assertEqual(output['localhost']['sub_role'], 'BackEnd')
|
self.assertEqual(output['localhost']['sub_role'], 'BackEnd')
|
||||||
|
self.assertEqual(output['localhost']['deployment_id'], "1")
|
||||||
|
|
||||||
def test_global_asic_acl(self):
|
def test_global_asic_acl(self):
|
||||||
argument = "-m {} -p {} --var-json \"ACL_TABLE\"".format(self.sample_graph, self.sample_port_config)
|
argument = "-m {} -p {} --var-json \"ACL_TABLE\"".format(self.sample_graph, self.sample_port_config)
|
||||||
|
Reference in New Issue
Block a user