diff --git a/src/sonic-config-engine/minigraph.py b/src/sonic-config-engine/minigraph.py index a05880e522..ee6a84183e 100644 --- a/src/sonic-config-engine/minigraph.py +++ b/src/sonic-config-engine/minigraph.py @@ -1041,6 +1041,7 @@ def parse_asic_meta(meta, hname): switch_id = None switch_type = None max_cores = None + deployment_id = None macsec_profile = {} device_metas = meta.find(str(QName(ns, "Devices"))) for device in device_metas.findall(str(QName(ns1, "DeviceMetadata"))): @@ -1057,10 +1058,12 @@ def parse_asic_meta(meta, hname): switch_type = value elif name == "MaxCores": max_cores = value + elif name == "DeploymentId": + deployment_id = value elif name == 'MacSecProfile': 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): 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")): (neighbors, devices, port_speed_png) = parse_asic_png(child, asic_name, hostname) 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")): linkmetas = parse_linkmeta(child, hostname) elif child.tag == str(QName(ns, "DeviceInfos")): @@ -1989,7 +1992,7 @@ def parse_asic_sub_role(filename, asic_name): root = ET.parse(filename).getroot() for child in root: 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 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() for child in root: 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 None diff --git a/src/sonic-config-engine/tests/multi_npu_data/sample-minigraph.xml b/src/sonic-config-engine/tests/multi_npu_data/sample-minigraph.xml index 935d2c0c83..be3938f24b 100644 --- a/src/sonic-config-engine/tests/multi_npu_data/sample-minigraph.xml +++ b/src/sonic-config-engine/tests/multi_npu_data/sample-minigraph.xml @@ -1465,6 +1465,11 @@ FrontEnd + + DeploymentId + + 1 + @@ -1475,6 +1480,11 @@ FrontEnd + + DeploymentId + + 1 + @@ -1485,6 +1495,11 @@ FrontEnd + + DeploymentId + + 1 + @@ -1495,6 +1510,11 @@ FrontEnd + + DeploymentId + + 1 + @@ -1505,6 +1525,11 @@ BackEnd + + DeploymentId + + 1 + @@ -1515,6 +1540,12 @@ BackEnd + + DeploymentId + + 1 + + diff --git a/src/sonic-config-engine/tests/test_multinpu_cfggen.py b/src/sonic-config-engine/tests/test_multinpu_cfggen.py index 35c2000c0e..a34b0b6cfd 100644 --- a/src/sonic-config-engine/tests/test_multinpu_cfggen.py +++ b/src/sonic-config-engine/tests/test_multinpu_cfggen.py @@ -304,6 +304,7 @@ class TestMultiNpuCfgGen(TestCase): self.assertEqual(output['localhost']['sub_role'], 'FrontEnd') else: self.assertEqual(output['localhost']['sub_role'], 'BackEnd') + self.assertEqual(output['localhost']['deployment_id'], "1") def test_global_asic_acl(self): argument = "-m {} -p {} --var-json \"ACL_TABLE\"".format(self.sample_graph, self.sample_port_config)