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
72 changes: 42 additions & 30 deletions ansible/templates/minigraph_link_meta.j2
Original file line number Diff line number Diff line change
@@ -1,6 +1,25 @@
{% if 'dualtor' in topo %}
{% set 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 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 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>
<a:Name i:nil="true" />
Expand All @@ -24,13 +43,9 @@
<a:Key>{{ dual_tor_facts['positions']['lower'] }}:{{ tunnel }};{{ dual_tor_facts['positions']['upper'] }}:{{ tunnel }}</a:Key>
</a:LinkMetadata>
{% endfor %}
</Link>
</LinkMetadataDeclaration>
{% endif %}

{% if macsec_card is defined and macsec_card == True and 't2' in topo %}
<LinkMetadataDeclaration>
<Link xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution">
{% for index in range(vms_number) %}
{% set vm_intfs=vm_topo_config['vm'][vms[index]]['intfs'][dut_index|int]|sort %}
{% set dut_intfs=vm_topo_config['vm'][vms[index]]['interface_indexes'][dut_index|int]|sort %}
Expand All @@ -49,38 +64,35 @@
{% endif %}
{% endfor %}
{% endfor %}
</Link>
</LinkMetadataDeclaration>
{% endif %}

{% if msft_an_enabled is defined and vm_topo_config.get('autoneg_interfaces') is not none %}
<LinkMetadataDeclaration>
<Link xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution">
{% for if_index in vm_topo_config['autoneg_interfaces']['intfs'] %}

{% if "mellanox" in device_info[inventory_hostname]['HwSku']|lower %}
{% set autoneg_intf = "etp" ~ if_index %}
{% else %}
{% set autoneg_intf = "Ethernet" ~ if_index ~ "/1" %}
{% endif %}
{% if port_alias_map[autoneg_intf] in device_conn[inventory_hostname] and device_conn[inventory_hostname][port_alias_map[autoneg_intf]]['autoneg']|lower == "on" %}
{% 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'] %}
<a:LinkMetadata>
<a:Name i:nil="true"/>
<a:Properties>
<a:DeviceProperty>
<a:Name>AutoNegotiation</a:Name>
<a:Value>True</a:Value>
</a:DeviceProperty>
<a:DeviceProperty>
<a:Name>FECDisabled</a:Name>
<a:Reference i:nil="true"/>
<a:Value>True</a:Value>
</a:DeviceProperty>
<a:DeviceProperty>
<a:Name>AutoNegotiation</a:Name>
<a:Value>True</a:Value>
</a:DeviceProperty>
{% 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 %}
</a:Properties>
<a:Key>{{ device_conn[inventory_hostname][port_alias_map[autoneg_intf]]['peerdevice'] }}:{{ device_conn[inventory_hostname][port_alias_map[autoneg_intf]]['peerport'] }};{{ inventory_hostname }}:{{ autoneg_intf }}</a:Key>
</a:LinkMetadata>
{% endif %}
<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 %}
{% endfor %}
{% endif %}

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