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
9a1f68ba12
commit
42d9a44e05
@ -547,6 +547,7 @@ def parse_meta(meta, hname):
|
|||||||
deployment_id = None
|
deployment_id = None
|
||||||
region = None
|
region = None
|
||||||
cloudtype = None
|
cloudtype = None
|
||||||
|
resource_type = None
|
||||||
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"))):
|
||||||
if device.find(str(QName(ns1, "Name"))).text.lower() == hname.lower():
|
if device.find(str(QName(ns1, "Name"))).text.lower() == hname.lower():
|
||||||
@ -573,7 +574,9 @@ def parse_meta(meta, hname):
|
|||||||
region = value
|
region = value
|
||||||
elif name == "CloudType":
|
elif name == "CloudType":
|
||||||
cloudtype = value
|
cloudtype = value
|
||||||
return syslog_servers, dhcp_servers, ntp_servers, tacacs_servers, mgmt_routes, erspan_dst, deployment_id, region, cloudtype
|
elif name == "ResourceType":
|
||||||
|
resource_type = value
|
||||||
|
return syslog_servers, dhcp_servers, ntp_servers, tacacs_servers, mgmt_routes, erspan_dst, deployment_id, region, cloudtype, resource_type
|
||||||
|
|
||||||
|
|
||||||
def parse_linkmeta(meta, hname):
|
def parse_linkmeta(meta, hname):
|
||||||
@ -820,6 +823,7 @@ def parse_xml(filename, platform=None, port_config_file=None, asic_name=None, hw
|
|||||||
neighbors = None
|
neighbors = None
|
||||||
devices = None
|
devices = None
|
||||||
sub_role = None
|
sub_role = None
|
||||||
|
resource_type = None
|
||||||
docker_routing_config_mode = "separated"
|
docker_routing_config_mode = "separated"
|
||||||
port_speeds_default = {}
|
port_speeds_default = {}
|
||||||
port_speed_png = {}
|
port_speed_png = {}
|
||||||
@ -871,7 +875,7 @@ def parse_xml(filename, platform=None, port_config_file=None, asic_name=None, hw
|
|||||||
elif child.tag == str(QName(ns, "UngDec")):
|
elif child.tag == str(QName(ns, "UngDec")):
|
||||||
(u_neighbors, u_devices, _, _, _, _, _, _) = parse_png(child, hostname)
|
(u_neighbors, u_devices, _, _, _, _, _, _) = parse_png(child, hostname)
|
||||||
elif child.tag == str(QName(ns, "MetadataDeclaration")):
|
elif child.tag == str(QName(ns, "MetadataDeclaration")):
|
||||||
(syslog_servers, dhcp_servers, ntp_servers, tacacs_servers, mgmt_routes, erspan_dst, deployment_id, region, cloudtype) = parse_meta(child, hostname)
|
(syslog_servers, dhcp_servers, ntp_servers, tacacs_servers, mgmt_routes, erspan_dst, deployment_id, region, cloudtype, resource_type) = parse_meta(child, hostname)
|
||||||
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")):
|
||||||
@ -917,6 +921,10 @@ def parse_xml(filename, platform=None, port_config_file=None, asic_name=None, hw
|
|||||||
current_device['sub_role'] = sub_role
|
current_device['sub_role'] = sub_role
|
||||||
results['DEVICE_METADATA']['localhost']['sub_role'] = sub_role
|
results['DEVICE_METADATA']['localhost']['sub_role'] = sub_role
|
||||||
results['DEVICE_METADATA']['localhost']['asic_name'] = asic_name
|
results['DEVICE_METADATA']['localhost']['asic_name'] = asic_name
|
||||||
|
|
||||||
|
if resource_type is not None:
|
||||||
|
results['DEVICE_METADATA']['localhost']['resource_type'] = resource_type
|
||||||
|
|
||||||
results['BGP_NEIGHBOR'] = bgp_sessions
|
results['BGP_NEIGHBOR'] = bgp_sessions
|
||||||
results['BGP_MONITORS'] = bgp_monitors
|
results['BGP_MONITORS'] = bgp_monitors
|
||||||
results['BGP_PEER_RANGE'] = bgp_peers_with_range
|
results['BGP_PEER_RANGE'] = bgp_peers_with_range
|
||||||
|
@ -253,6 +253,11 @@
|
|||||||
<a:Reference i:nil="true"/>
|
<a:Reference i:nil="true"/>
|
||||||
<a:Value>10.0.10.7;10.0.10.8</a:Value>
|
<a:Value>10.0.10.7;10.0.10.8</a:Value>
|
||||||
</a:DeviceProperty>
|
</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:Properties>
|
||||||
</a:DeviceMetadata>
|
</a:DeviceMetadata>
|
||||||
</Devices>
|
</Devices>
|
||||||
|
@ -80,6 +80,11 @@ class TestCfgGen(TestCase):
|
|||||||
output = self.run_script(argument)
|
output = self.run_script(argument)
|
||||||
self.assertEqual(output.strip(), 'Public')
|
self.assertEqual(output.strip(), 'Public')
|
||||||
|
|
||||||
|
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):
|
def test_print_data(self):
|
||||||
argument = '-m "' + self.sample_graph + '" --print-data'
|
argument = '-m "' + self.sample_graph + '" --print-data'
|
||||||
output = self.run_script(argument)
|
output = self.run_script(argument)
|
||||||
|
Loading…
Reference in New Issue
Block a user