From a8fa1c403a1fb976419d2253515aad4be0cb0ac1 Mon Sep 17 00:00:00 2001 From: ClausHolbechArista <48674677+ClausHolbechArista@users.noreply.github.com> Date: Thu, 25 Nov 2021 14:48:51 +0100 Subject: [PATCH] Refactor(eos_designs): Various optimizations for speed (#1355) --- .../documentation/devices/clock.md | 2 - .../devices/link-tracking-groups.md | 2 - .../devices/management-console.md | 2 - .../devices/management-security.md | 2 - .../documentation/devices/roles.md | 2 - .../devices/router-bgp-evpn-mpls.md | 2 - .../documentation/devices/router-bgp-vpws.md | 2 - .../devices/snmp-server-traps.md | 2 - .../upgrade/overload-upgraded-data-model.j2 | 5 +- .../templates/facts/switch/logic.j2 | 14 +++--- .../templates/facts/switch/switch.j2 | 3 ++ .../templates/facts/topology/p2p-uplinks.j2 | 30 ++++++------ .../facts/topology/port-channel-uplinks.j2 | 47 ++++++++++--------- .../inband_management/parent-logic.j2 | 11 +++-- .../overlay/logic-evpn-route-clients.j2 | 12 ++--- .../overlay/logic-evpn-route-servers.j2 | 10 ++-- .../eos_designs/templates/underlay/logic.j2 | 13 ++--- .../upgrade/overload-upgraded-data-model.j2 | 5 +- 18 files changed, 82 insertions(+), 84 deletions(-) diff --git a/ansible_collections/arista/avd/molecule/eos_cli_config_gen/documentation/devices/clock.md b/ansible_collections/arista/avd/molecule/eos_cli_config_gen/documentation/devices/clock.md index dcdd952a7eb..e6021cc482f 100644 --- a/ansible_collections/arista/avd/molecule/eos_cli_config_gen/documentation/devices/clock.md +++ b/ansible_collections/arista/avd/molecule/eos_cli_config_gen/documentation/devices/clock.md @@ -1,6 +1,5 @@ # clock # Table of Contents - - [Management](#management) - [Management Interfaces](#management-interfaces) @@ -18,7 +17,6 @@ - [ACL](#acl) - [Quality Of Service](#quality-of-service) - # Management ## Management Interfaces diff --git a/ansible_collections/arista/avd/molecule/eos_cli_config_gen/documentation/devices/link-tracking-groups.md b/ansible_collections/arista/avd/molecule/eos_cli_config_gen/documentation/devices/link-tracking-groups.md index d1812cb2641..cfbfb39ec06 100644 --- a/ansible_collections/arista/avd/molecule/eos_cli_config_gen/documentation/devices/link-tracking-groups.md +++ b/ansible_collections/arista/avd/molecule/eos_cli_config_gen/documentation/devices/link-tracking-groups.md @@ -1,6 +1,5 @@ # link-tracking-groups # Table of Contents - - [Management](#management) - [Management Interfaces](#management-interfaces) @@ -18,7 +17,6 @@ - [ACL](#acl) - [Quality Of Service](#quality-of-service) - # Management ## Management Interfaces diff --git a/ansible_collections/arista/avd/molecule/eos_cli_config_gen/documentation/devices/management-console.md b/ansible_collections/arista/avd/molecule/eos_cli_config_gen/documentation/devices/management-console.md index a5bb1a0eef8..f6680397025 100644 --- a/ansible_collections/arista/avd/molecule/eos_cli_config_gen/documentation/devices/management-console.md +++ b/ansible_collections/arista/avd/molecule/eos_cli_config_gen/documentation/devices/management-console.md @@ -1,6 +1,5 @@ # management-console # Table of Contents - - [Management](#management) - [Management Interfaces](#management-interfaces) @@ -18,7 +17,6 @@ - [ACL](#acl) - [Quality Of Service](#quality-of-service) - # Management ## Management Interfaces diff --git a/ansible_collections/arista/avd/molecule/eos_cli_config_gen/documentation/devices/management-security.md b/ansible_collections/arista/avd/molecule/eos_cli_config_gen/documentation/devices/management-security.md index 2374026b875..fab1324fa93 100644 --- a/ansible_collections/arista/avd/molecule/eos_cli_config_gen/documentation/devices/management-security.md +++ b/ansible_collections/arista/avd/molecule/eos_cli_config_gen/documentation/devices/management-security.md @@ -1,6 +1,5 @@ # management-security # Table of Contents - - [Management](#management) - [Management Interfaces](#management-interfaces) @@ -20,7 +19,6 @@ - [ACL](#acl) - [Quality Of Service](#quality-of-service) - # Management ## Management Interfaces diff --git a/ansible_collections/arista/avd/molecule/eos_cli_config_gen/documentation/devices/roles.md b/ansible_collections/arista/avd/molecule/eos_cli_config_gen/documentation/devices/roles.md index 824db91c693..8d6982cb59f 100644 --- a/ansible_collections/arista/avd/molecule/eos_cli_config_gen/documentation/devices/roles.md +++ b/ansible_collections/arista/avd/molecule/eos_cli_config_gen/documentation/devices/roles.md @@ -1,6 +1,5 @@ # roles # Table of Contents - - [Management](#management) - [Management Interfaces](#management-interfaces) @@ -18,7 +17,6 @@ - [ACL](#acl) - [Quality Of Service](#quality-of-service) - # Management ## Management Interfaces diff --git a/ansible_collections/arista/avd/molecule/eos_cli_config_gen/documentation/devices/router-bgp-evpn-mpls.md b/ansible_collections/arista/avd/molecule/eos_cli_config_gen/documentation/devices/router-bgp-evpn-mpls.md index 0b11aa0e4ca..149ac3ae923 100644 --- a/ansible_collections/arista/avd/molecule/eos_cli_config_gen/documentation/devices/router-bgp-evpn-mpls.md +++ b/ansible_collections/arista/avd/molecule/eos_cli_config_gen/documentation/devices/router-bgp-evpn-mpls.md @@ -1,6 +1,5 @@ # router-bgp-evpn-mpls # Table of Contents - - [Management](#management) - [Management Interfaces](#management-interfaces) @@ -18,7 +17,6 @@ - [ACL](#acl) - [Quality Of Service](#quality-of-service) - # Management ## Management Interfaces diff --git a/ansible_collections/arista/avd/molecule/eos_cli_config_gen/documentation/devices/router-bgp-vpws.md b/ansible_collections/arista/avd/molecule/eos_cli_config_gen/documentation/devices/router-bgp-vpws.md index 287722ed7ad..99af82ca8bd 100644 --- a/ansible_collections/arista/avd/molecule/eos_cli_config_gen/documentation/devices/router-bgp-vpws.md +++ b/ansible_collections/arista/avd/molecule/eos_cli_config_gen/documentation/devices/router-bgp-vpws.md @@ -1,6 +1,5 @@ # router-bgp-vpws # Table of Contents - - [Management](#management) - [Management Interfaces](#management-interfaces) @@ -18,7 +17,6 @@ - [ACL](#acl) - [Quality Of Service](#quality-of-service) - # Management ## Management Interfaces diff --git a/ansible_collections/arista/avd/molecule/eos_cli_config_gen/documentation/devices/snmp-server-traps.md b/ansible_collections/arista/avd/molecule/eos_cli_config_gen/documentation/devices/snmp-server-traps.md index 3a0d6d4c68f..f4837b95d7c 100644 --- a/ansible_collections/arista/avd/molecule/eos_cli_config_gen/documentation/devices/snmp-server-traps.md +++ b/ansible_collections/arista/avd/molecule/eos_cli_config_gen/documentation/devices/snmp-server-traps.md @@ -1,6 +1,5 @@ # snmp-server-traps # Table of Contents - - [Management](#management) - [Management Interfaces](#management-interfaces) @@ -18,7 +17,6 @@ - [ACL](#acl) - [Quality Of Service](#quality-of-service) - # Management ## Management Interfaces diff --git a/ansible_collections/arista/avd/roles/eos_cli_config_gen/templates/upgrade/overload-upgraded-data-model.j2 b/ansible_collections/arista/avd/roles/eos_cli_config_gen/templates/upgrade/overload-upgraded-data-model.j2 index 7a79881b13c..ad9814f1abd 100644 --- a/ansible_collections/arista/avd/roles/eos_cli_config_gen/templates/upgrade/overload-upgraded-data-model.j2 +++ b/ansible_collections/arista/avd/roles/eos_cli_config_gen/templates/upgrade/overload-upgraded-data-model.j2 @@ -1,8 +1,9 @@ {% set tmp_hostvars = {} %} {% set upgraded_data_model = eos_cli_config_gen_upgraded_data_model | arista.avd.default({}) %} +{% set switch_hostvars = hostvars[inventory_hostname] %} {% for key in upgraded_data_model.keys() %} -{% if hostvars[inventory_hostname][key] is arista.avd.defined %} -{% do tmp_hostvars.update({key: hostvars[inventory_hostname][key]}) %} +{% if switch_hostvars[key] is arista.avd.defined %} +{% do tmp_hostvars.update({key: switch_hostvars[key]}) %} {% endif %} {% endfor %} {% set merged_data_model = tmp_hostvars | combine(upgraded_data_model, recursive=true) %} diff --git a/ansible_collections/arista/avd/roles/eos_designs/templates/facts/switch/logic.j2 b/ansible_collections/arista/avd/roles/eos_designs/templates/facts/switch/logic.j2 index e3587a68ca5..7ef2323e53a 100644 --- a/ansible_collections/arista/avd/roles/eos_designs/templates/facts/switch/logic.j2 +++ b/ansible_collections/arista/avd/roles/eos_designs/templates/facts/switch/logic.j2 @@ -1,11 +1,13 @@ -{% if inventory_hostname in hostvars[inventory_hostname][switch.node_type_key].nodes | arista.avd.default([]) %} -{% set switch_data.node = hostvars[inventory_hostname][switch.node_type_key].nodes[inventory_hostname] %} +{% set node_type_vars = hostvars[inventory_hostname][switch.node_type_key] | arista.avd.default %} +{% if inventory_hostname in node_type_vars.nodes | arista.avd.default([]) %} +{% set switch_data.node = node_type_vars.nodes[inventory_hostname] %} {% set switch_data.node_group = {} %} {% endif %} {% if switch_data.node is not arista.avd.defined %} -{% for node_group in hostvars[inventory_hostname][switch.node_type_key].node_groups | arista.avd.default([]) %} -{% if inventory_hostname in hostvars[inventory_hostname][switch.node_type_key].node_groups[node_group].nodes | arista.avd.default([]) %} -{% set switch_data.node_group = hostvars[inventory_hostname][switch.node_type_key].node_groups[node_group] %} +{% set tmp_node_groups = node_type_vars.node_groups | arista.avd.default([]) %} +{% for node_group in tmp_node_groups %} +{% if inventory_hostname in tmp_node_groups[node_group].nodes | arista.avd.default([]) %} +{% set switch_data.node_group = tmp_node_groups[node_group] %} {% set switch_data.group = node_group %} {% set switch_data.node = switch_data.node_group.nodes[inventory_hostname] %} {% break %} @@ -13,6 +15,6 @@ {% endfor %} {% endif %} {% if switch_data.node is arista.avd.defined(fail_action='error',var_name=switch.node_type_key ~ '.(node_groups.)nodes.' ~ inventory_hostname) %} -{% set switch_data.defaults = hostvars[inventory_hostname][switch.node_type_key].defaults | arista.avd.default() %} +{% set switch_data.defaults = node_type_vars.defaults | arista.avd.default() %} {% endif %} {% set switch_data.combined = switch_data.defaults | combine(switch_data.node_group, switch_data.node, recursive=true, list_merge='replace') %} diff --git a/ansible_collections/arista/avd/roles/eos_designs/templates/facts/switch/switch.j2 b/ansible_collections/arista/avd/roles/eos_designs/templates/facts/switch/switch.j2 index 4fdb928edcb..91e979ed8c7 100644 --- a/ansible_collections/arista/avd/roles/eos_designs/templates/facts/switch/switch.j2 +++ b/ansible_collections/arista/avd/roles/eos_designs/templates/facts/switch/switch.j2 @@ -1,5 +1,8 @@ switch: +{# switch.type #} + type: {{ type | arista.avd.default }} + {# switch.group #} group: {{ switch_data.group | arista.avd.default() }} diff --git a/ansible_collections/arista/avd/roles/eos_designs/templates/facts/topology/p2p-uplinks.j2 b/ansible_collections/arista/avd/roles/eos_designs/templates/facts/topology/p2p-uplinks.j2 index 25a54510687..ca6aeeccdef 100644 --- a/ansible_collections/arista/avd/roles/eos_designs/templates/facts/topology/p2p-uplinks.j2 +++ b/ansible_collections/arista/avd/roles/eos_designs/templates/facts/topology/p2p-uplinks.j2 @@ -6,32 +6,34 @@ topology: links: {% for uplink_interface in switch.uplink_interfaces | arista.avd.default([]) %} {% set uplink_switch = switch.uplink_switches[loop.index0] | arista.avd.default() %} -{% if uplink_switch is arista.avd.defined and uplink_switch in groups[fabric_name] and - hostvars[uplink_switch].switch is arista.avd.defined(fail_action='warning',var_name='hostvars[' ~ uplink_switch ~ '].switch') %} -{% do topology_peers.append(uplink_switch) %} +{% if uplink_switch is arista.avd.defined and uplink_switch in groups[fabric_name] %} +{% set uplink_switch_facts = hostvars[uplink_switch].switch | arista.avd.default %} +{% if uplink_switch_facts is arista.avd.defined(fail_action='warning',var_name='hostvars[' ~ uplink_switch ~ '].switch') %} +{% do topology_peers.append(uplink_switch) %} {{ uplink_interface }}: peer: {{ uplink_switch }} peer_interface: {{ switch.uplink_switch_interfaces[loop.index0 ] }} - peer_type: {{ hostvars[uplink_switch].type }} - peer_bgp_as: "{{ hostvars[uplink_switch].switch.bgp_as | arista.avd.default() }}" + peer_type: {{ uplink_switch_facts.type }} + peer_bgp_as: "{{ uplink_switch_facts.bgp_as | arista.avd.default() }}" type: underlay_p2p -{% if switch.uplink_interface_speed is arista.avd.defined %} +{% if switch.uplink_interface_speed is arista.avd.defined %} speed: {{ switch.uplink_interface_speed }} -{% endif %} -{% if switch.uplink_bfd is arista.avd.defined(true) %} +{% endif %} +{% if switch.uplink_bfd is arista.avd.defined(true) %} bfd: true -{% endif %} -{% if switch.uplink_ptp.enable is arista.avd.defined %} +{% endif %} +{% if switch.uplink_ptp.enable is arista.avd.defined %} ptp: {{ switch.uplink_ptp.enable }} -{% endif %} -{% if underlay_rfc5549 is arista.avd.defined(true) %} +{% endif %} +{% if underlay_rfc5549 is arista.avd.defined(true) %} ipv6_enable: true -{% else %} -{% set uplink_switch_index = loop.index0 %} +{% else %} +{% set uplink_switch_index = loop.index0 %} ip_address: {% include switch.ip_addressing.p2p_uplinks_ip %} peer_ip_address: {% include switch.ip_addressing.p2p_uplinks_peer_ip %} +{% endif %} {% endif %} {% endif %} {% endfor %} diff --git a/ansible_collections/arista/avd/roles/eos_designs/templates/facts/topology/port-channel-uplinks.j2 b/ansible_collections/arista/avd/roles/eos_designs/templates/facts/topology/port-channel-uplinks.j2 index 7e9b753d8ea..ff480e92a9a 100644 --- a/ansible_collections/arista/avd/roles/eos_designs/templates/facts/topology/port-channel-uplinks.j2 +++ b/ansible_collections/arista/avd/roles/eos_designs/templates/facts/topology/port-channel-uplinks.j2 @@ -7,41 +7,44 @@ topology: links: {% for uplink_interface in switch.uplink_interfaces | arista.avd.default([]) %} {% set uplink_switch = switch.uplink_switches[loop.index0] | arista.avd.default() %} -{% if uplink_switch is arista.avd.defined and uplink_switch in groups[fabric_name] and - hostvars[uplink_switch].switch is arista.avd.defined(fail_action='warning',var_name='hostvars[' ~ uplink_switch ~ '].switch') %} -{% do topology_peers.append(uplink_switch) %} +{% if uplink_switch is arista.avd.defined and uplink_switch in groups[fabric_name] %} +{% set uplink_switch_facts = hostvars[uplink_switch].switch | arista.avd.default %} +{% if uplink_switch_facts is arista.avd.defined(fail_action='warning',var_name='hostvars[' ~ uplink_switch ~ '].switch') %} +{% do topology_peers.append(uplink_switch) %} {{ uplink_interface }}: peer: {{ uplink_switch }} peer_interface: {{ switch.uplink_switch_interfaces[loop.index0] }} - peer_type: {{ hostvars[uplink_switch].type }} + peer_type: {{ uplink_switch_facts.type }} type: underlay_l2 -{% if switch.uplink_interface_speed is arista.avd.defined %} +{% if switch.uplink_interface_speed is arista.avd.defined %} speed: {{ switch.uplink_interface_speed }} -{% endif %} -{% if hostvars[uplink_switch].switch.mlag is arista.avd.defined(true) or switch.short_esi is arista.avd.defined %} +{% endif %} +{% if uplink_switch_facts.mlag is arista.avd.defined(true) or switch.short_esi is arista.avd.defined %} {# Override our description on port-channel to be peer's group name if they are mlag pair or A/A #} - channel_description: {{ hostvars[uplink_switch].switch.group }} -{% endif %} -{% if switch.mlag is arista.avd.defined(true) %} + channel_description: {{ uplink_switch_facts.group }} +{% endif %} +{% if switch.mlag is arista.avd.defined(true) %} {# Override the peer's description on port-channel to be our group name if we are mlag pair #} peer_channel_description: {{ switch.group }} -{% endif %} -{% if switch.mlag_role is arista.avd.defined('secondary') %} - channel_group_id: {{ hostvars[switch.mlag_peer].switch.uplink_interfaces[0] | regex_findall("\d") | join }} - peer_channel_group_id: {{ hostvars[switch.mlag_peer].switch.uplink_switch_interfaces[0] | regex_findall("\d") | join }} -{% else %} +{% endif %} +{% if switch.mlag_role is arista.avd.defined('secondary') %} +{% set mlag_peer_switch_facts = hostvars[switch.mlag_peer].switch %} + channel_group_id: {{ mlag_peer_switch_facts.uplink_interfaces[0] | regex_findall("\d") | join }} + peer_channel_group_id: {{ mlag_peer_switch_facts.uplink_switch_interfaces[0] | regex_findall("\d") | join }} +{% else %} channel_group_id: {{ switch.uplink_interfaces[0] | regex_findall("\d") | join }} peer_channel_group_id: {{ switch.uplink_switch_interfaces[0] | regex_findall("\d") | join }} -{% endif %} +{% endif %} {# Remove vlans if upstream switch does not have them #} -{% set uplink_vlans = switch.vlans | arista.avd.default([]) | select('in', hostvars[uplink_switch].switch.vlans) %} -{% set ns.vlans = uplink_vlans %} -{% if switch.inband_management_vlan is arista.avd.defined %} -{% do uplink_vlans.append(switch.inband_management_vlan | int) %} -{% endif %} +{% set uplink_vlans = switch.vlans | arista.avd.default([]) | select('in', uplink_switch_facts.vlans) %} +{% set ns.vlans = uplink_vlans %} +{% if switch.inband_management_vlan is arista.avd.defined %} +{% do uplink_vlans.append(switch.inband_management_vlan | int) %} +{% endif %} vlans: {{ uplink_vlans | unique }} -{% if switch.short_esi is arista.avd.defined %} +{% if switch.short_esi is arista.avd.defined %} peer_short_esi: {{ switch.short_esi }} +{% endif %} {% endif %} {% endif %} {% endfor %} diff --git a/ansible_collections/arista/avd/roles/eos_designs/templates/inband_management/parent-logic.j2 b/ansible_collections/arista/avd/roles/eos_designs/templates/inband_management/parent-logic.j2 index 40a05785e49..0c6bfed0eae 100644 --- a/ansible_collections/arista/avd/roles/eos_designs/templates/inband_management/parent-logic.j2 +++ b/ansible_collections/arista/avd/roles/eos_designs/templates/inband_management/parent-logic.j2 @@ -4,11 +4,12 @@ {# Add underlay links defined on other devices pointing to this device #} {% for fabric_switch in groups[fabric_name] | arista.avd.natural_sort %} -{% if inventory_hostname in hostvars[fabric_switch].switch.inband_management_parents | arista.avd.default([]) %} +{% set fabric_switch_facts = hostvars[fabric_switch].switch | arista.avd.default %} +{% if inventory_hostname in fabric_switch_facts.inband_management_parents | arista.avd.default([]) %} {% set inband_management_data.role = 'parent' %} -{% if hostvars[fabric_switch].switch.inband_management_subnet not in inband_management_data.subnets %} -{% do inband_management_data.vlans.append(hostvars[fabric_switch].switch.inband_management_vlan) %} -{% do inband_management_data.subnets.append(hostvars[fabric_switch].switch.inband_management_subnet) %} +{% if fabric_switch_facts.inband_management_subnet not in inband_management_data.subnets %} +{% do inband_management_data.vlans.append(fabric_switch_facts.inband_management_vlan) %} +{% do inband_management_data.subnets.append(fabric_switch_facts.inband_management_subnet) %} {% endif %} {% endif %} -{% endfor %} \ No newline at end of file +{% endfor %} diff --git a/ansible_collections/arista/avd/roles/eos_designs/templates/overlay/logic-evpn-route-clients.j2 b/ansible_collections/arista/avd/roles/eos_designs/templates/overlay/logic-evpn-route-clients.j2 index 2dfb0badd42..a6098f6f21d 100644 --- a/ansible_collections/arista/avd/roles/eos_designs/templates/overlay/logic-evpn-route-clients.j2 +++ b/ansible_collections/arista/avd/roles/eos_designs/templates/overlay/logic-evpn-route-clients.j2 @@ -3,15 +3,15 @@ {# #} {# Look for switches pointing to us as evpn_route_server #} {% for fabric_switch in groups[fabric_name] if fabric_switch not in overlay_data.evpn_route_servers | arista.avd.natural_sort %} -{% if hostvars[fabric_switch].switch is arista.avd.defined(fail_action='warning',var_name='hostvars[' ~ fabric_switch ~ '].switch') %} -{% set fabric_switch_vars = hostvars[fabric_switch] %} -{% set fabric_switch_evpn_role = fabric_switch_vars.switch.evpn_role | arista.avd.default('none') %} -{% set fabric_switch_evpn_route_servers = fabric_switch_vars.switch.evpn_route_servers | arista.avd.default([]) %} +{% set fabric_switch_facts = hostvars[fabric_switch].switch | arista.avd.default %} +{% if fabric_switch_facts is arista.avd.defined(fail_action='warning',var_name='hostvars[' ~ fabric_switch ~ '].switch') %} +{% set fabric_switch_evpn_role = fabric_switch_facts.evpn_role | arista.avd.default('none') %} +{% set fabric_switch_evpn_route_servers = fabric_switch_facts.evpn_route_servers | arista.avd.default([]) %} {% if inventory_hostname in fabric_switch_evpn_route_servers and fabric_switch_evpn_role in ['client', 'server'] %} {# Found a matching client. Gathering information for this client #} {% set client = namespace() %} -{% set client.bgp_as = fabric_switch_vars.switch.bgp_as %} -{% set client.ip_address = fabric_switch_vars.switch.router_id %} +{% set client.bgp_as = fabric_switch_facts.bgp_as %} +{% set client.ip_address = fabric_switch_facts.router_id %} {% do overlay_data.evpn_route_clients.update({ fabric_switch: client }) %} {% endif %} {% endif %} diff --git a/ansible_collections/arista/avd/roles/eos_designs/templates/overlay/logic-evpn-route-servers.j2 b/ansible_collections/arista/avd/roles/eos_designs/templates/overlay/logic-evpn-route-servers.j2 index 203ba7c4ba4..45a52ea832d 100644 --- a/ansible_collections/arista/avd/roles/eos_designs/templates/overlay/logic-evpn-route-servers.j2 +++ b/ansible_collections/arista/avd/roles/eos_designs/templates/overlay/logic-evpn-route-servers.j2 @@ -2,13 +2,13 @@ {# #} {# Expand data for evpn_route_servers #} {% for route_server in switch.evpn_route_servers | arista.avd.natural_sort %} -{% if hostvars[route_server].switch is arista.avd.defined(fail_action='warning',var_name='hostvars[' ~ route_server ~ '].switch') %} -{% set route_server_vars = hostvars[route_server] %} -{% if route_server_vars.switch.evpn_role is arista.avd.defined('server') %} +{% set fabric_switch_switch_facts = hostvars[route_server].switch | arista.avd.default %} +{% if fabric_switch_switch_facts is arista.avd.defined(fail_action='warning',var_name='hostvars[' ~ route_server ~ '].switch') %} +{% if fabric_switch_switch_facts.evpn_role is arista.avd.defined('server') %} {# Found a matching server. Gathering information for this server #} {% set server = namespace() %} -{% set server.bgp_as = route_server_vars.switch.bgp_as %} -{% set server.ip_address = route_server_vars.switch.router_id %} +{% set server.bgp_as = fabric_switch_switch_facts.bgp_as %} +{% set server.ip_address = fabric_switch_switch_facts.router_id %} {% do overlay_data.evpn_route_servers.update({ route_server: server }) %} {% endif %} {% endif %} diff --git a/ansible_collections/arista/avd/roles/eos_designs/templates/underlay/logic.j2 b/ansible_collections/arista/avd/roles/eos_designs/templates/underlay/logic.j2 index 64803b0cc18..716fb529050 100644 --- a/ansible_collections/arista/avd/roles/eos_designs/templates/underlay/logic.j2 +++ b/ansible_collections/arista/avd/roles/eos_designs/templates/underlay/logic.j2 @@ -3,16 +3,17 @@ {# Add underlay links defined on other devices pointing to this device #} {% for fabric_switch in groups[fabric_name] | arista.avd.natural_sort %} -{% if inventory_hostname in hostvars[fabric_switch].topology.peers | arista.avd.default([]) %} -{% set fabric_switch_vars = hostvars[fabric_switch] %} -{% for fabric_switch_interface in fabric_switch_vars.topology.links | arista.avd.natural_sort %} -{% set fabric_switch_link = fabric_switch_vars.topology.links[fabric_switch_interface] %} +{% set fabric_switch_topology_facts = hostvars[fabric_switch].topology | arista.avd.default %} +{% if inventory_hostname in fabric_switch_topology_facts.peers | arista.avd.default([]) %} +{% set fabric_switch_switch_facts = hostvars[fabric_switch].switch | arista.avd.default %} +{% for fabric_switch_interface in fabric_switch_topology_facts.links | arista.avd.natural_sort %} +{% set fabric_switch_link = fabric_switch_topology_facts.links[fabric_switch_interface] %} {% if fabric_switch_link.peer is arista.avd.defined(inventory_hostname) %} {% set link = namespace() %} {% set link.peer = fabric_switch %} {% set link.peer_interface = fabric_switch_interface %} -{% set link.peer_type = fabric_switch_vars.type %} -{% set link.peer_bgp_as = fabric_switch_vars.switch.bgp_as | arista.avd.default() %} +{% set link.peer_type = fabric_switch_switch_facts.type %} +{% set link.peer_bgp_as = fabric_switch_switch_facts.bgp_as | arista.avd.default() %} {% set link.type = fabric_switch_link.type | arista.avd.default() %} {% set link.speed = fabric_switch_link.speed | arista.avd.default() %} {% set link.ip_address = fabric_switch_link.peer_ip_address | arista.avd.default() %} diff --git a/ansible_collections/arista/avd/roles/eos_designs/templates/upgrade/overload-upgraded-data-model.j2 b/ansible_collections/arista/avd/roles/eos_designs/templates/upgrade/overload-upgraded-data-model.j2 index 199c2848c3d..b0457702486 100644 --- a/ansible_collections/arista/avd/roles/eos_designs/templates/upgrade/overload-upgraded-data-model.j2 +++ b/ansible_collections/arista/avd/roles/eos_designs/templates/upgrade/overload-upgraded-data-model.j2 @@ -1,8 +1,9 @@ {% set tmp_hostvars = {} %} +{% set switch_hostvars = hostvars[inventory_hostname] %} {% set upgraded_data_model = eos_designs_upgraded_data_model | arista.avd.default({}) %} {% for key in upgraded_data_model.keys() %} -{% if hostvars[inventory_hostname][key] is arista.avd.defined %} -{% do tmp_hostvars.update({key: hostvars[inventory_hostname][key]}) %} +{% if switch_hostvars[key] is arista.avd.defined %} +{% do tmp_hostvars.update({key: switch_hostvars[key]}) %} {% endif %} {% endfor %} {% set merged_data_model = tmp_hostvars | combine(upgraded_data_model, recursive=true) %}