Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 24 additions & 31 deletions src/sonic-config-engine/minigraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -847,6 +847,9 @@ def parse_meta(meta, hname):
resource_type = None
downstream_subrole = None
kube_data = {}
redundancy_type = None
downstream_redundancy_types = 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():
Expand Down Expand Up @@ -881,29 +884,11 @@ def parse_meta(meta, hname):
kube_data["enable"] = value
elif name == "KubernetesServerIp":
kube_data["ip"] = value
return syslog_servers, dhcp_servers, dhcpv6_servers, ntp_servers, tacacs_servers, mgmt_routes, erspan_dst, deployment_id, region, cloudtype, resource_type, downstream_subrole, kube_data

def parse_system_defaults(meta):
system_default_values = {}

system_defaults = meta.find(str(QName(ns1, "SystemDefaults")))

if system_defaults is None:
return system_default_values

for system_default in system_defaults.findall(str(QName(ns1, "SystemDefault"))):
name = system_default.find(str(QName(ns1, "Name"))).text
value = system_default.find(str(QName(ns1, "Value"))).text

# Tunnel Qos remapping
if name == "TunnelQosRemapEnabled":
if value.lower() == "true":
status = "enabled"
else:
status = "disabled"
system_default_values["tunnel_qos_remap"] = {"status": status}

return system_default_values
elif name == "DownstreamRedundancyTypes":
downstream_redundancy_types = value
elif name == "RedundancyType":
redundancy_type = value
return syslog_servers, dhcp_servers, dhcpv6_servers, ntp_servers, tacacs_servers, mgmt_routes, erspan_dst, deployment_id, region, cloudtype, resource_type, downstream_subrole, kube_data, downstream_redundancy_types, redundancy_type

def parse_linkmeta(meta, hname):
link = meta.find(str(QName(ns, "Link")))
Expand Down Expand Up @@ -1202,6 +1187,8 @@ def parse_xml(filename, platform=None, port_config_file=None, asic_name=None, hw
local_devices = []
kube_data = {}
system_defaults = {}
downstream_redundancy_types = None
redundancy_type = None

hwsku_qn = QName(ns, "HwSku")
hostname_qn = QName(ns, "Hostname")
Expand Down Expand Up @@ -1232,13 +1219,11 @@ 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, kube_data) = 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, kube_data, downstream_redundancy_types, redundancy_type) = parse_meta(child, hostname)
elif child.tag == str(QName(ns, "LinkMetadataDeclaration")):
linkmetas = parse_linkmeta(child, hostname)
elif child.tag == str(QName(ns, "DeviceInfos")):
(port_speeds_default, port_descriptions) = parse_deviceinfo(child, hwsku)
elif child.tag == str(QName(ns, "SystemDefaultsDeclaration")):
system_defaults = parse_system_defaults(child)
else:
if child.tag == str(QName(ns, "DpgDec")):
(intfs, lo_intfs, mvrf, mgmt_intf, vlans, vlan_members, dhcp_relay_table, pcs, pc_members, acls, vni, tunnel_intfs, dpg_ecmp_content, tunnel_intfs_qos_remap_config) = parse_dpg(child, asic_name)
Expand All @@ -1253,8 +1238,6 @@ def parse_xml(filename, platform=None, port_config_file=None, asic_name=None, hw
linkmetas = parse_linkmeta(child, hostname)
elif child.tag == str(QName(ns, "DeviceInfos")):
(port_speeds_default, port_descriptions) = parse_deviceinfo(child, hwsku)
elif child.tag == str(QName(ns, "SystemDefaultsDeclaration")):
system_defaults = parse_system_defaults(child)

# set the host device type in asic metadata also
device_type = [devices[key]['type'] for key in devices if key.lower() == hostname.lower()][0]
Expand Down Expand Up @@ -1289,9 +1272,6 @@ def parse_xml(filename, platform=None, port_config_file=None, asic_name=None, hw
}
}

if len(system_defaults) > 0:
results['SYSTEM_DEFAULTS'] = system_defaults

results['PEER_SWITCH'], mux_tunnel_name, peer_switch_ip = get_peer_switch_info(linkmetas, devices)

if bool(results['PEER_SWITCH']):
Expand All @@ -1300,7 +1280,20 @@ def parse_xml(filename, platform=None, port_config_file=None, asic_name=None, hw
print("Warning: more than one peer switch was found. Only the first will be parsed: {}".format(results['PEER_SWITCH'].keys()[0]))

results['DEVICE_METADATA']['localhost']['peer_switch'] = list(results['PEER_SWITCH'].keys())[0]

# Enable tunnel_qos_remap if downstream_redundancy_types(T1) or redundancy_type(T0) = Gemini/Libra
enable_tunnel_qos_map = False
if results['DEVICE_METADATA']['localhost']['type'].lower() == 'leafrouter' and ('gemini' in str(downstream_redundancy_types).lower() or 'libra' in str(downstream_redundancy_types).lower()):
enable_tunnel_qos_map = True
elif results['DEVICE_METADATA']['localhost']['type'].lower() == 'torrouter' and ('gemini' in str(redundancy_type).lower() or 'libra' in str(redundancy_type).lower()):
enable_tunnel_qos_map = True

if enable_tunnel_qos_map:
system_defaults['tunnel_qos_remap'] = {"status": "enabled"}

if len(system_defaults) > 0:
results['SYSTEM_DEFAULTS'] = system_defaults

# for this hostname, if sub_role is defined, add sub_role in
# device_metadata
if sub_role is not None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2334,19 +2334,16 @@
<a:Reference i:nil="true"/>
<a:Value>10.20.6.16</a:Value>
</a:DeviceProperty>
<a:DeviceProperty>
<a:Name>RedundancyType</a:Name>
<a:Reference i:nil="true"/>
<a:Value>Gemini</a:Value>
</a:DeviceProperty>
</a:Properties>
</a:DeviceMetadata>
</Devices>
<Properties xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution"/>
</MetadataDeclaration>
<SystemDefaultsDeclaration>
<a:SystemDefaults xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution">
<a:SystemDefault>
<a:Name>TunnelQosRemapEnabled</a:Name>
<a:Value>True</a:Value>
</a:SystemDefault>
</a:SystemDefaults>
</SystemDefaultsDeclaration>
<LinkMetadataDeclaration>
<Link xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution">
<a:LinkMetadata>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4600,19 +4600,16 @@
<a:Reference i:nil="true"/>
<a:Value>10.20.6.16</a:Value>
</a:DeviceProperty>
<a:DeviceProperty>
<a:Name>RedundancyType</a:Name>
<a:Reference i:nil="true"/>
<a:Value>Gemini</a:Value>
</a:DeviceProperty>
</a:Properties>
</a:DeviceMetadata>
</Devices>
<Properties xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution"/>
</MetadataDeclaration>
<SystemDefaultsDeclaration>
<a:SystemDefaults xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution">
<a:SystemDefault>
<a:Name>TunnelQosRemapEnabled</a:Name>
<a:Value>True</a:Value>
</a:SystemDefault>
</a:SystemDefaults>
</SystemDefaultsDeclaration>
<LinkMetadataDeclaration>
<Link xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution">
<a:LinkMetadata>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2481,19 +2481,16 @@
<a:Reference i:nil="true"/>
<a:Value>10.20.6.16</a:Value>
</a:DeviceProperty>
<a:DeviceProperty>
<a:Name>DownstreamRedundancyTypes</a:Name>
<a:Reference i:nil="true"/>
<a:Value>Gemini</a:Value>
</a:DeviceProperty>
</a:Properties>
</a:DeviceMetadata>
</Devices>
<Properties xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution"/>
</MetadataDeclaration>
<SystemDefaultsDeclaration>
<a:SystemDefaults xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution">
<a:SystemDefault>
<a:Name>TunnelQosRemapEnabled</a:Name>
<a:Value>True</a:Value>
</a:SystemDefault>
</a:SystemDefaults>
</SystemDefaultsDeclaration>
<Hostname>str-7260cx3-acs-7</Hostname>
<HwSku>Arista-7260CX3-C64</HwSku>
</DeviceMiniGraph>
Original file line number Diff line number Diff line change
Expand Up @@ -474,14 +474,6 @@
</Devices>
<Properties xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution"/>
</MetadataDeclaration>
<SystemDefaultsDeclaration>
<a:SystemDefaults xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution">
<a:SystemDefault>
<a:Name>TunnelQosRemapEnabled</a:Name>
<a:Value>False</a:Value>
</a:SystemDefault>
</a:SystemDefaults>
</SystemDefaultsDeclaration>
<DeviceInfos>
<DeviceInfo>
<EthernetInterfaces xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -469,19 +469,16 @@
<a:Reference i:nil="true"/>
<a:Value>Storage</a:Value>
</a:DeviceProperty>
<a:DeviceProperty>
<a:Name>RedundancyType</a:Name>
<a:Reference i:nil="true"/>
<a:Value>Gemini</a:Value>
</a:DeviceProperty>
</a:Properties>
</a:DeviceMetadata>
</Devices>
<Properties xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution"/>
</MetadataDeclaration>
<SystemDefaultsDeclaration>
<a:SystemDefaults xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution">
<a:SystemDefault>
<a:Name>TunnelQosRemapEnabled</a:Name>
<a:Value>True</a:Value>
</a:SystemDefault>
</a:SystemDefaults>
</SystemDefaultsDeclaration>
<DeviceInfos>
<DeviceInfo>
<EthernetInterfaces xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -469,19 +469,16 @@
<a:Reference i:nil="true"/>
<a:Value>Storage</a:Value>
</a:DeviceProperty>
<a:DeviceProperty>
<a:Name>RedundancyType</a:Name>
<a:Reference i:nil="true"/>
<a:Value>Gemini</a:Value>
</a:DeviceProperty>
</a:Properties>
</a:DeviceMetadata>
</Devices>
<Properties xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution"/>
</MetadataDeclaration>
<SystemDefaultsDeclaration>
<a:SystemDefaults xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution">
<a:SystemDefault>
<a:Name>TunnelQosRemapEnabled</a:Name>
<a:Value>True</a:Value>
</a:SystemDefault>
</a:SystemDefaults>
</SystemDefaultsDeclaration>
<DeviceInfos>
<DeviceInfo>
<EthernetInterfaces xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution">
Expand Down