[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
b7d0f2213f
commit
c69d71af1c
@ -1009,6 +1009,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"))):
|
||||
@ -1058,7 +1059,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):
|
||||
@ -1484,6 +1487,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")
|
||||
@ -1516,7 +1520,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")):
|
||||
@ -1565,6 +1569,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