[minigraph] Add rack_mgmt_rack parse support in minigraph.py (#15064)
Why I did it We need to store information of power shelf in config_db for SONiC MX switch. Current minigraph parser cannot parse rack_mgmt_map field. Work item tracking Microsoft ADO (number only): 22179645 How I did it Add support for parsing rack_mgmt_map.
This commit is contained in:
parent
8a48cab032
commit
782c044a75
@ -955,6 +955,7 @@ def parse_meta(meta, hname):
|
||||
redundancy_type = None
|
||||
downstream_redundancy_types = None
|
||||
qos_profile = None
|
||||
rack_mgmt_map = None
|
||||
|
||||
device_metas = meta.find(str(QName(ns, "Devices")))
|
||||
for device in device_metas.findall(str(QName(ns1, "DeviceMetadata"))):
|
||||
@ -1004,7 +1005,9 @@ def parse_meta(meta, hname):
|
||||
downstream_redundancy_types = value
|
||||
elif name == "SonicQosProfile":
|
||||
qos_profile = value
|
||||
return syslog_servers, dhcp_servers, dhcpv6_servers, ntp_servers, tacacs_servers, mgmt_routes, erspan_dst, deployment_id, region, cloudtype, resource_type, downstream_subrole, switch_id, switch_type, max_cores, kube_data, macsec_profile, downstream_redundancy_types, redundancy_type, qos_profile
|
||||
elif name == "RackMgmtMap":
|
||||
rack_mgmt_map = value
|
||||
return syslog_servers, dhcp_servers, dhcpv6_servers, ntp_servers, tacacs_servers, mgmt_routes, erspan_dst, deployment_id, region, cloudtype, resource_type, downstream_subrole, switch_id, switch_type, max_cores, kube_data, macsec_profile, downstream_redundancy_types, redundancy_type, qos_profile, rack_mgmt_map
|
||||
|
||||
|
||||
def parse_linkmeta(meta, hname):
|
||||
@ -1421,6 +1424,7 @@ def parse_xml(filename, platform=None, port_config_file=None, asic_name=None, hw
|
||||
downstream_redundancy_types = None
|
||||
redundancy_type = None
|
||||
qos_profile = None
|
||||
rack_mgmt_map = None
|
||||
|
||||
hwsku_qn = QName(ns, "HwSku")
|
||||
hostname_qn = QName(ns, "Hostname")
|
||||
@ -1453,7 +1457,7 @@ def parse_xml(filename, platform=None, port_config_file=None, asic_name=None, hw
|
||||
elif child.tag == str(QName(ns, "UngDec")):
|
||||
(u_neighbors, u_devices, _, _, _, _, _, _) = parse_png(child, hostname, None)
|
||||
elif child.tag == str(QName(ns, "MetadataDeclaration")):
|
||||
(syslog_servers, dhcp_servers, dhcpv6_servers, ntp_servers, tacacs_servers, mgmt_routes, erspan_dst, deployment_id, region, cloudtype, resource_type, downstream_subrole, switch_id, switch_type, max_cores, kube_data, macsec_profile, downstream_redundancy_types, redundancy_type, qos_profile) = parse_meta(child, hostname)
|
||||
(syslog_servers, dhcp_servers, dhcpv6_servers, ntp_servers, tacacs_servers, mgmt_routes, erspan_dst, deployment_id, region, cloudtype, resource_type, downstream_subrole, switch_id, switch_type, max_cores, kube_data, macsec_profile, downstream_redundancy_types, redundancy_type, qos_profile, rack_mgmt_map) = parse_meta(child, hostname)
|
||||
elif child.tag == str(QName(ns, "LinkMetadataDeclaration")):
|
||||
linkmetas = parse_linkmeta(child, hostname)
|
||||
elif child.tag == str(QName(ns, "DeviceInfos")):
|
||||
@ -1498,6 +1502,9 @@ def parse_xml(filename, platform=None, port_config_file=None, asic_name=None, hw
|
||||
if deployment_id is not None:
|
||||
results['DEVICE_METADATA']['localhost']['deployment_id'] = deployment_id
|
||||
|
||||
if rack_mgmt_map is not None:
|
||||
results['DEVICE_METADATA']['localhost']['rack_mgmt_map'] = rack_mgmt_map
|
||||
|
||||
cluster = [devices[key] for key in devices if key.lower() == hostname.lower()][0].get('cluster', "")
|
||||
if cluster:
|
||||
results['DEVICE_METADATA']['localhost']['cluster'] = cluster
|
||||
|
@ -537,6 +537,11 @@
|
||||
<a:Reference i:nil="true"/>
|
||||
<a:Value>Mixed</a:Value>
|
||||
</a:DeviceProperty>
|
||||
<a:DeviceProperty>
|
||||
<a:Name>RackMgmtMap</a:Name>
|
||||
<a:Reference i:nil="true"/>
|
||||
<a:Value>dummy_value</a:Value>
|
||||
</a:DeviceProperty>
|
||||
</a:Properties>
|
||||
</a:DeviceMetadata>
|
||||
</Devices>
|
||||
|
@ -193,6 +193,11 @@ class TestCfgGenCaseInsensitive(TestCase):
|
||||
output = self.run_script(argument)
|
||||
self.assertEqual(output.strip(), "1")
|
||||
|
||||
def test_minigraph_rack_mgmt_map(self):
|
||||
argument = ['-m', self.sample_graph, '-p', self.port_config, '-v', "DEVICE_METADATA[\'localhost\'][\'rack_mgmt_map\']"]
|
||||
output = self.run_script(argument)
|
||||
self.assertEqual(output.strip(), "dummy_value")
|
||||
|
||||
def test_minigraph_cluster(self):
|
||||
argument = ['-m', self.sample_graph, '-p', self.port_config, '-v', "DEVICE_METADATA[\'localhost\'][\'cluster\']"]
|
||||
output = self.run_script(argument)
|
||||
|
Loading…
Reference in New Issue
Block a user