Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom plugin to collect topology data for use by scripts #483

Closed
wants to merge 13 commits into from
Closed
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
5 changes: 3 additions & 2 deletions docs/module/bgp.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,11 @@ The following features are only supported on a subset of platforms:
| Cisco IOS/IOS XE | ❌ | ❌ | ✅ | ✅ | ✅ |
| Cumulus Linux 4.x | ✅ | ✅ | ✅ | ✅ | ✅ |
| Cumulus Linux 5.x | ✅ | ✅ | ❌ | ❌ | ✅ |
| Dell OS10 | | | ✅ | ❌ | |
| Dell OS10 | | | ✅ | ❌ | |
| FRR 7.5.0 | ✅ | ❌ | ✅ | ✅ | ✅ |
| Nokia SR Linux | ✅ | ❌ | ✅ | ✅ | ✅ |

| Nokia SR OS | ❌ | ❌ | ✅ | ✅ | ✅ |
| VyOS | ✅ | ✅ | ✅ | ❌ | ✅ |

## Global BGP Configuration Parameters

Expand Down
4 changes: 2 additions & 2 deletions docs/module/evpn.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ The following table describes per-platform support of individual VXLAN features:
| Arista EOS | ✅ | ✅ | ✅ | ❌ | ✅ |
| Cumulus Linux | ✅ | ✅ | ❌ | ❌ | ✅ |
| Nokia SR Linux | ✅ | ✅ | ❌ | ❌ | ✅ |
| Nokia SR OS | ❌ | ❌ | ❌ | | |
| Nokia SR OS | ✅ | ✅ | ❌ | | |
| FRR | ✅ | ✅ | ❌ | ❌ | ✅ |
| VyOS | ✅ | ✅ | ❌ | ❌ | ✅ |
| Dell OS 10 | ✅ | ✅ | ❌ | ❌ | ✅ |
Expand Down Expand Up @@ -89,4 +89,4 @@ IRB is configured whenever EVPN-enabled VLANs in a VRF contain IPv4 or IPv6 addr
* Asymmetric IRB requires no extra parameters[^NS]
* Symmetric IRB needs a transit VNI that has to be set with the **evpn.transit_vni** parameter. This parameter could be set to an integer value or to *True* in which case the EVPN configuration module auto-assigns a VNI to the VRF. Note that the EVI value used in this case is currently based on the VRF ID (vrfidx)

[^NS]: Asymmetric IRB is not supported at the moment
[^NS]: Asymmetric IRB is only supported on Nokia SR OS at the moment
2 changes: 1 addition & 1 deletion docs/module/ospf.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ The following table describes per-platform support of individual router-level OS
| Juniper vSRX 3.0 | ✅ | ✅ | ✅ | ✅ |
| Mikrotik CHR RouterOS | ✅ | ❌ | ❌ | ✅ |
| Nokia SR Linux | ✅ | ✅ | ✅ | ✅ |
| Nokia SR OS | ✅ | ✅ | | ✅ |
| Nokia SR OS | ✅ | ✅ | | ✅ |
| VyOS | ✅ | ✅ | ✅ | ✅ |
| Dell OS10 | ✅ | ✅ | ✅ | ✅ |

Expand Down
1 change: 1 addition & 0 deletions docs/module/vlan.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ VLANs are supported on these platforms:
| FRR [❗](../caveats.html#caveats-frr-config) | ✅ | ✅ | ✅ | ✅ | ✅ |
| Mikrotik CHR RouterOS | ✅ | ✅ | ✅ | ✅ | ✅ |
| Nokia SR Linux | ✅ | ✅ | ✅ | ✅ | ✅ |
| Nokia SR OS | ✅ | ✅ | ✅ | ✅ | ✅ |
| VyOS | ✅ | ✅ | ✅ | ✅ | ✅ |

## VLAN Connectivity Model
Expand Down
1 change: 1 addition & 0 deletions docs/module/vxlan.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ The following table describes per-platform support of individual VXLAN features:
| Dell OS10 | ✅ | ✅ | ❌ |
| FRR | ✅ | ✅ | ❌ |
| Nokia SR Linux | ✅ | ❌ | ❌ |
| Nokia SR OS | ✅ | ❌ | ❌ |
| VyOS | ✅ | ✅ | ✅ |

```{note}
Expand Down
13 changes: 9 additions & 4 deletions netsim/ansible/tasks/deploy-config/sros.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---

- name: Check that required plugin exists, use 'ansible-galaxy collection install nokia.grpc' to install it
- name: Check that required plugin exists, use 'netlab install grpc' to install it
vars:
ansible_connection: nokia.grpc.gnmi
nokia.grpc.gnmi_config:
Expand All @@ -25,7 +25,7 @@
# uses_route_reflector: "{{ rr != [] }}"

- name: Check if OpenConfig can be used as provisioning method/model (config_template={{config_template}})
when: "'ospf' in config_template or 'sr' in module or not sros_use_openconfig|default(true)"
when: "'ospf' in config_template or 'sr' in module|default([]) or not sros_use_openconfig|default(true)"
set_fact:
sros_provisioning_model: "sros.gnmi"

Expand All @@ -38,10 +38,15 @@
src: "{{ template_to_use }}"
dest: "{{ tempfile_1.path }}"

- name: Check that prepared config from {{template_to_use}} in {{tempfile_1.path}} is valid YAML
- block:
- name: Show generated config from {{template_to_use}} based on {{tempfile_1.path}}
debug: msg="{{ cfg }}" verbosity=1

- name: Check that prepared config from {{template_to_use}} in {{tempfile_1.path}} is valid YAML
debug: msg="{{ cfg | from_yaml }}" verbosity=2

vars:
cfg: "{{ lookup('file', tempfile_1.path ) }}"
debug: msg="{{ cfg | from_yaml }}"

- name: Wait up to 150s for gNMI(TCP {{sros_grpc_port}}) to be ready on {{ ansible_host }}
local_action:
Expand Down
6 changes: 3 additions & 3 deletions netsim/ansible/tasks/deploy-config/vyos.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
- template:
src: "{{ config_template }}"
dest: /tmp/config.sh
dest: /tmp/config-{{ netsim_action }}.sh

- name: "execute config.sh to deploy {{ netsim_action }} config from {{ config_template }}"
command: "/bin/vbash /tmp/config.sh"
- name: "execute config-{{ netsim_action }}.sh to deploy {{ netsim_action }} config from {{ config_template }}"
command: "/bin/vbash /tmp/config-{{ netsim_action }}.sh"
become: true
tags: [ print_action, always ]
6 changes: 5 additions & 1 deletion netsim/ansible/templates/bgp/dellos10.j2
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
router bgp {{ bgp.as }}
log-neighbor-changes

! define a generic unnumbered template to be used for eBGP unnumbered...
! WTF Dell...
template unnumbered_ebgp

{% if bgp.router_id|ipv4 %}
router-id {{ bgp.router_id }}
{% endif %}
Expand All @@ -14,7 +18,7 @@ router bgp {{ bgp.as }}
{% endif %}
{% for n in bgp.neighbors %}
{% for af in ['ipv4','ipv6'] if n[af] is defined %}
{{ bgpcfg.neighbor(n,n[af],bgp) }}
{{ bgpcfg.neighbor(n,n[af],bgp,af) }}
{% endfor %}
{% endfor %}
!
Expand Down
26 changes: 22 additions & 4 deletions netsim/ansible/templates/bgp/dellos10.macro.j2
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
{#
Define a BGP neighbor
#}
{% macro neighbor(n,ip,bgp) %}
{% macro neighbor(n,ip,bgp,af) %}
{% set peer = ip if ip is string else 'interface ' + n.local_if|default('?') %}
!
neighbor {{ ip }}
neighbor {{ peer }}
{% if peer!=n[af] %}
! This is an unnumbered eBGP session
! WTF Remote-AS configuration not supported for unnumbered peer
inherit template unnumbered_ebgp inherit-type ebgp
{% else %}
remote-as {{ n.as }}
{% endif %}

description "{{ n.name }}"

{% if n.local_as is defined %}
Expand All @@ -17,7 +25,7 @@
{#
In Dell OS10, next-hop-self is configured under AF
#}
{% for af in ['ipv4','ipv6'] if bgp[af] is defined %}
{% for af in ['ipv4','ipv6'] if bgp[af] is defined and n.activate[af] is defined and n.activate[af] %}
!
address-family {{ af }} unicast
next-hop-self
Expand Down Expand Up @@ -45,13 +53,23 @@
{% endif %}
{% endif %}

{% for af in ['ipv4','ipv6'] if bgp[af] is defined %}
{% for af in ['ipv4','ipv6'] if bgp[af] is defined and n.activate[af] is defined and n.activate[af] %}
!
address-family {{ af }} unicast
soft-reconfiguration inbound
activate
exit
{% endfor %}

{#
And now, **WTF**, since Dell OS10 cannot disable ipv4 AF by default, we need to:
#}
{% if n.activate['ipv4'] is not defined or (n.activate['ipv4'] is defined and not n.activate['ipv4']) %}
!
address-family ipv4 unicast
no activate
exit
{% endif %}

no shutdown
exit
Expand Down
2 changes: 1 addition & 1 deletion netsim/ansible/templates/bgp/frr.bgp-config.j2
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ router bgp {{ bgp.as }}
{% endfor %}
!
{% for n in bgp.neighbors if n[af] is defined and n.activate[af] is defined and n.activate[af] %}
{% set peer = n[af] if af in n and n[af] is string else n.local_if %}
{% set peer = n[af] if n[af] is string else n.local_if %}
neighbor {{ peer }} activate
{% if 'ibgp' in n.type %}
{% if bgp.next_hop_self is defined and bgp.next_hop_self %}
Expand Down
35 changes: 20 additions & 15 deletions netsim/ansible/templates/bgp/srlinux.macro.j2
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@
{# Create route export policies #}
{% for af in ['ipv4','ipv6'] if af in vrf_context.af and vrf_context.af[af] %}
{% if loopback[af] is defined and bgp.advertise_loopback and vrf=='default' %}
{{ bgp_export_prefix(vrf,loopback[af]) }}
{{ bgp_export_prefix(vrf,loopback[af]|ipaddr('address')|ipaddr('host')) }}
{% endif %}

{% for l in interfaces|default([]) if l.bgp.advertise|default(0) and l[af]|default(False) is string and l.vrf|default('default')==vrf %}
{{ bgp_export_prefix(vrf,l[af]|ipaddr('address')|ipaddr('host')) }}
{{ bgp_export_prefix(vrf,l[af]|ipaddr('subnet')) }}
{% endfor %}

{% for pfx in vrf_bgp.originate|default([]) if af == 'ipv4' %}
Expand Down Expand Up @@ -123,14 +123,14 @@
standard: {{ 'standard' in list }}
large: {{ 'extended' in list }}
{% endif %}
{% if transport_ip %}
transport:
local-address: {{ transport_ip }}
{% endif %}
{% if 'ibgp' in type %}
next-hop-self: {{ vrf_bgp.next_hop_self|default(False) }}
peer-as: {{ neighbor.as }}
transport:
local-address: {{ transport_ip }}
{% if vrf_bgp.rr|default(0) %}
passive-mode: True
_annotate_passive-mode: "Improve robustness during startup"
route-reflector:
cluster-id: {{ vrf_bgp.rr_cluster_id|default(False) or router_id }}
client: True
Expand All @@ -150,20 +150,25 @@
{% set transport_ip = loopback[af]|ipaddr('address') if af in loopback and n.type=='ibgp' else None %}
{{ bgp_peer_group(peer_group,'ibgp' if 'ibgp' in n.type else 'ebgp',n,transport_ip) }}

- path: network-instance[name={{vrf}}]/protocols/bgp/neighbor[peer-address={{n[af]}}]
- path: network-instance[name={{vrf}}]/protocols/bgp
val:
description: {{ n.name }}
peer-group: {{ peer_group }}
neighbor:
- peer-address: "{{ n[af] }}"
description: {{ n.name }}
peer-group: {{ peer_group }}
{% if 'ebgp' in n.type %}
peer-as: {{ n.as }}
peer-as: {{ n.as }}
{% elif vrf_bgp.rr|default(False) and n.rr|default(False) %}
route-reflector:
client: False # Don't reflect routes between ibgp route reflectors
route-reflector:
client: False # Don't reflect routes between ibgp route reflectors
transport:
passive-mode: False
_annotate_passive-mode: "Connect actively to other Route Reflectors"
{% endif %}
{% if n.local_as is defined %}
local-as:
- as-number: {{ n.local_as }}
prepend-global-as: {{ not n.replace_global_as|default(True) }} # Don't include iBGP global AS in eBGP advertisements
local-as:
- as-number: {{ n.local_as }}
prepend-global-as: {{ not n.replace_global_as|default(True) }} # Don't include iBGP global AS in eBGP advertisements
{% endif %}

{% elif n[af]==True and af=='ipv6' and n.type == 'ebgp' %}
Expand Down
71 changes: 4 additions & 67 deletions netsim/ansible/templates/bgp/sros.gnmi.j2
Original file line number Diff line number Diff line change
@@ -1,73 +1,10 @@
# Generated by sros.gnmi.j2 template
updates:
- path: configure/router[router-name=Base]
val:
router-id: "{{ bgp.router_id }}"
autonomous-system: {{ bgp.as }}
bgp:
ebgp-default-reject-policy:
import: False
export: False
multipath:
ibgp: {{ 16 if 'ixr' in clab.type else 64 }}
ebgp: {{ 16 if 'ixr' in clab.type else 64 }}
min-route-advertisement: 1 # Be aggressive about sending updates
connect-retry: 5 # Retry frequently, suitable in DC context
client-reflect: {{ bgp.rr|default('')|bool }}
# family: cannot disable this
# ipv4: False # Enabled by default, disable globally and set per group
group:
{% set ibgp_v4 = ['ibgp-ipv4'] if 'ipv4' in loopback and loopback['ipv4'] else [] %}
{% set ibgp_v6 = ['ibgp-ipv6'] if 'ipv6' in loopback and loopback['ipv6'] else [] %}
{% for c in ['ebgp']+ibgp_v4+ibgp_v6 %}
{% set bgp_type=c[:4] %}
- group-name: "{{c}}"
admin-state: enable
family:
ipv4: {{ 'ipv4' in bgp.address_families[bgp_type] }}
ipv6: {{ 'ipv6' in bgp.address_families[bgp_type] }}
import:
policy: ["accept_all"]
export:
policy: ["accept_all"]
{% if bgp.community[ bgp_type ]|default([]) %}
send-communities:
{% if not ('standard' in bgp.community[ bgp_type ] or 'both' in bgp.community[ bgp_type ]) %}
standard: False
{% endif %}
{% if not ('extended' in bgp.community[ bgp_type ] or 'both' in bgp.community[ bgp_type ]) %}
extended: False
{% endif %}
{% if not ('large' in bgp.community[ bgp_type ]) %}
large: False
{% endif %}
{% endif %}
{% if c!='ebgp' %}
local-address: "{{ loopback[ c[5:] ]|ipaddr('address') }}"
{% if bgp.rr|default('')|bool %}
cluster:
cluster-id: "{{ bgp.rr_cluster_id|default(False) or bgp.router_id }}"
{% elif bgp.next_hop_self|default(false) %}
next-hop-self: True
{% endif %}
{% endif %}
{% from "./sros.gnmi.macro.j2" import bgp_config with context %}

{% endfor %}
neighbor:
{% for n in bgp.neighbors %}
{% for af in ['ipv4','ipv6'] if n[af] is defined %}
- ip-address: "{{ n[af] }}"
description: "{{ n.name }}"
peer-as: {{ n.as }}
group: "{{ 'ebgp' if n.type=='ebgp' else (n.type+'-'+af) }}"
{% if n.local_as is defined %}
local-as:
as-number: {{ n.local_as }}
{% endif %}
{% endfor %}
{% endfor %}
updates:

- path: configure/policy-options/policy-statement[name=accept_all]
val:
default-action:
action-type: accept

{{ bgp_config(bgp,None) }}
Loading