Skip to content
Merged
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
45 changes: 18 additions & 27 deletions ansible/templates/minigraph_link_meta.j2
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
{% set link_metadata_defined = False %}
{%- set ns = namespace(link_metadata_defined=False) -%}

{% if 'dualtor' in topo or
(macsec_card is defined and macsec_card == True and 't2' in topo) %}
{% set link_metadata_defined = True %}
{% endif %}
{%- if 'dualtor' in topo or (macsec_card is defined and macsec_card == True and 't2' in topo) -%}
{% set ns.link_metadata_defined = True %}
{%- endif -%}

{% if device_conn is defined and inventory_hostname in device_conn %}
{% for iface in device_conn[inventory_hostname] %}
{% if 'autoneg' in device_conn[inventory_hostname][iface] and
'on' in device_conn[inventory_hostname][iface]['autoneg'] %}
{% set link_metadata_defined = True %}
{% endif %}
{% endfor %}
{% endif %}
{%- if device_conn is defined and inventory_hostname in device_conn and
device_conn[inventory_hostname].values() | selectattr('autoneg', 'defined') | selectattr('autoneg', 'equalto', 'on') | list | length > 0 -%}
{% set ns.link_metadata_defined = True %}
{%- endif -%}
{% if ns.link_metadata_defined %}

{% if link_metadata_defined %}
<LinkMetadataDeclaration>
<Link xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution">
{% endif %}

{% if 'dualtor' in topo %}
{% for tunnel in tunnel_configs %}
<a:LinkMetadata>
Expand All @@ -44,7 +38,6 @@
</a:LinkMetadata>
{% endfor %}
{% endif %}

{% if macsec_card is defined and macsec_card == True and 't2' in topo %}
{% for index in range(vms_number) %}
{% set vm_intfs=vm_topo_config['vm'][vms[index]]['intfs'][dut_index|int]|sort %}
Expand All @@ -65,34 +58,32 @@
{% endfor %}
{% endfor %}
{% endif %}

{% if device_conn is defined and inventory_hostname in device_conn %}
{% for iface_name in device_conn[inventory_hostname].keys() %}
{% if iface_name in device_conn[inventory_hostname] and 'autoneg' in device_conn[inventory_hostname][iface_name] %}
{% if 'on' in device_conn[inventory_hostname][iface_name]['autoneg'] %}
{% if iface_name in device_conn[inventory_hostname] and 'autoneg' in device_conn[inventory_hostname][iface_name] %}
{% if 'on' in device_conn[inventory_hostname][iface_name]['autoneg'] %}
<a:LinkMetadata>
<a:Name i:nil="true"/>
<a:Properties>
<a:DeviceProperty>
<a:Name>AutoNegotiation</a:Name>
<a:Value>True</a:Value>
</a:DeviceProperty>
{% if msft_an_enabled is defined %}
{% if msft_an_enabled is defined %}
<a:DeviceProperty>
<a:Name>FECDisabled</a:Name>
<a:Reference i:nil="true"/>
<a:Value>True</a:Value>
</a:DeviceProperty>
{% endif %}
{% endif %}
</a:Properties>
<a:Key>{{ device_conn[inventory_hostname][iface_name]['peerdevice'] }}:{{ device_conn[inventory_hostname][iface_name]['peerport'] }};{{ inventory_hostname }}:{{ port_name_map[iface_name] }}</a:Key>
</a:LinkMetadata>
{% endif %}
{% endif %}
{% endif %}
{% endif %}
{% endfor %}
{% endif %}

{% if link_metadata_defined %}
</Link>
</LinkMetadataDeclaration>
{% if ns.link_metadata_defined %}
</Link>
</LinkMetadataDeclaration>
{% endif %}