Minigraph resource type changes (#5198)
* Parse sub_role from minigraph into DEVICE_METADATA * Change minigraph sub_role to resource_type
This commit is contained in:
parent
b6e8d38fc4
commit
7c83bb69e0
@ -615,6 +615,7 @@ def parse_meta(meta, hname):
|
||||
cloudtype = None
|
||||
downstream_subrole = None
|
||||
qos_profile = None
|
||||
resource_type = None
|
||||
device_metas = meta.find(str(QName(ns, "Devices")))
|
||||
for device in device_metas.findall(str(QName(ns1, "DeviceMetadata"))):
|
||||
if device.find(str(QName(ns1, "Name"))).text.lower() == hname.lower():
|
||||
@ -645,7 +646,9 @@ def parse_meta(meta, hname):
|
||||
downstream_subrole = value
|
||||
elif name == "SonicQosProfile":
|
||||
qos_profile = value
|
||||
return syslog_servers, dhcp_servers, ntp_servers, tacacs_servers, mgmt_routes, erspan_dst, deployment_id, region, cloudtype, downstream_subrole, qos_profile
|
||||
elif name == "ResourceType":
|
||||
resource_type = value
|
||||
return syslog_servers, dhcp_servers, ntp_servers, tacacs_servers, mgmt_routes, erspan_dst, deployment_id, region, cloudtype, downstream_subrole, qos_profile, resource_type
|
||||
|
||||
|
||||
def parse_linkmeta(meta, hname):
|
||||
@ -924,6 +927,7 @@ def parse_xml(filename, platform=None, port_config_file=None, asic_name=None):
|
||||
devices = None
|
||||
sub_role = None
|
||||
downstream_subrole = None
|
||||
resource_type = None
|
||||
docker_routing_config_mode = "separated"
|
||||
port_speeds_default = {}
|
||||
port_speed_png = {}
|
||||
@ -981,7 +985,7 @@ def parse_xml(filename, platform=None, port_config_file=None, asic_name=None):
|
||||
elif child.tag == str(QName(ns, "UngDec")):
|
||||
(u_neighbors, u_devices, _, _, _, _, _, _) = parse_png(child, hostname)
|
||||
elif child.tag == str(QName(ns, "MetadataDeclaration")):
|
||||
(syslog_servers, dhcp_servers, ntp_servers, tacacs_servers, mgmt_routes, erspan_dst, deployment_id, region, cloudtype, downstream_subrole, qos_profile) = parse_meta(child, hostname)
|
||||
(syslog_servers, dhcp_servers, ntp_servers, tacacs_servers, mgmt_routes, erspan_dst, deployment_id, region, cloudtype, downstream_subrole, qos_profile, resource_type) = parse_meta(child, hostname)
|
||||
elif child.tag == str(QName(ns, "LinkMetadataDeclaration")):
|
||||
linkmetas = parse_linkmeta(child, hostname)
|
||||
elif child.tag == str(QName(ns, "DeviceInfos")):
|
||||
@ -1033,6 +1037,8 @@ def parse_xml(filename, platform=None, port_config_file=None, asic_name=None):
|
||||
|
||||
if downstream_subrole is not None:
|
||||
results['DEVICE_METADATA']['localhost']['downstream_subrole'] = downstream_subrole
|
||||
if resource_type is not None:
|
||||
results['DEVICE_METADATA']['localhost']['resource_type'] = resource_type
|
||||
|
||||
results['BGP_NEIGHBOR'] = bgp_sessions
|
||||
results['BGP_MONITORS'] = bgp_monitors
|
||||
|
@ -258,6 +258,11 @@
|
||||
<a:Reference i:nil="true"/>
|
||||
<a:Value>downstream_subrole_y</a:Value>
|
||||
</a:DeviceProperty>
|
||||
<a:DeviceProperty>
|
||||
<a:Name>ResourceType</a:Name>
|
||||
<a:Reference i:nil="true"/>
|
||||
<a:Value>resource_type_x</a:Value>
|
||||
</a:DeviceProperty>
|
||||
</a:Properties>
|
||||
</a:DeviceMetadata>
|
||||
</Devices>
|
||||
|
@ -82,6 +82,11 @@ class TestCfgGen(TestCase):
|
||||
argument = '-v "DEVICE_METADATA[\'localhost\'][\'downstream_subrole\']" -m "' + self.sample_graph_metadata + '"'
|
||||
output = self.run_script(argument)
|
||||
self.assertEqual(output.strip(), 'downstream_subrole_y')
|
||||
|
||||
def test_minigraph_resourcetype(self):
|
||||
argument = '-v "DEVICE_METADATA[\'localhost\'][\'resource_type\']" -m "' + self.sample_graph_metadata + '"'
|
||||
output = self.run_script(argument)
|
||||
self.assertEqual(output.strip(), 'resource_type_x')
|
||||
|
||||
def test_print_data(self):
|
||||
argument = '-m "' + self.sample_graph + '" --print-data'
|
||||
|
Loading…
Reference in New Issue
Block a user