Skip to content

Commit

Permalink
Refactor(eos_designs): Various optimizations for speed (#1355)
Browse files Browse the repository at this point in the history
  • Loading branch information
ClausHolbechArista authored Nov 25, 2021
1 parent 49bb10f commit a8fa1c4
Show file tree
Hide file tree
Showing 18 changed files with 82 additions and 84 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# clock
# Table of Contents
<!-- toc -->

- [Management](#management)
- [Management Interfaces](#management-interfaces)
Expand All @@ -18,7 +17,6 @@
- [ACL](#acl)
- [Quality Of Service](#quality-of-service)

<!-- toc -->
# Management

## Management Interfaces
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# link-tracking-groups
# Table of Contents
<!-- toc -->

- [Management](#management)
- [Management Interfaces](#management-interfaces)
Expand All @@ -18,7 +17,6 @@
- [ACL](#acl)
- [Quality Of Service](#quality-of-service)

<!-- toc -->
# Management

## Management Interfaces
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# management-console
# Table of Contents
<!-- toc -->

- [Management](#management)
- [Management Interfaces](#management-interfaces)
Expand All @@ -18,7 +17,6 @@
- [ACL](#acl)
- [Quality Of Service](#quality-of-service)

<!-- toc -->
# Management

## Management Interfaces
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# management-security
# Table of Contents
<!-- toc -->

- [Management](#management)
- [Management Interfaces](#management-interfaces)
Expand All @@ -20,7 +19,6 @@
- [ACL](#acl)
- [Quality Of Service](#quality-of-service)

<!-- toc -->
# Management

## Management Interfaces
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# roles
# Table of Contents
<!-- toc -->

- [Management](#management)
- [Management Interfaces](#management-interfaces)
Expand All @@ -18,7 +17,6 @@
- [ACL](#acl)
- [Quality Of Service](#quality-of-service)

<!-- toc -->
# Management

## Management Interfaces
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# router-bgp-evpn-mpls
# Table of Contents
<!-- toc -->

- [Management](#management)
- [Management Interfaces](#management-interfaces)
Expand All @@ -18,7 +17,6 @@
- [ACL](#acl)
- [Quality Of Service](#quality-of-service)

<!-- toc -->
# Management

## Management Interfaces
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# router-bgp-vpws
# Table of Contents
<!-- toc -->

- [Management](#management)
- [Management Interfaces](#management-interfaces)
Expand All @@ -18,7 +17,6 @@
- [ACL](#acl)
- [Quality Of Service](#quality-of-service)

<!-- toc -->
# Management

## Management Interfaces
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# snmp-server-traps
# Table of Contents
<!-- toc -->

- [Management](#management)
- [Management Interfaces](#management-interfaces)
Expand All @@ -18,7 +17,6 @@
- [ACL](#acl)
- [Quality Of Service](#quality-of-service)

<!-- toc -->
# Management

## Management Interfaces
Expand Down
Original file line number Diff line number Diff line change
@@ -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) %}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
{% 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 %}
{% endif %}
{% 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') %}
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
switch:

{# switch.type #}
type: {{ type | arista.avd.default }}

{# switch.group #}
group: {{ switch_data.group | arista.avd.default() }}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
{% endfor %}
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() %}
Expand Down
Original file line number Diff line number Diff line change
@@ -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) %}
Expand Down

0 comments on commit a8fa1c4

Please sign in to comment.