057ced0391
The one big bgp configuration template was splitted into chunks. Currently we have three types of bgp neighbor peers: general bgp peers. They are represented by CONFIG_DB::BGP_NEIGHBOR table entries dynamic bgp peers. They are represented by CONFIG_DB::BGP_PEER_RANGE table entries monitors bgp peers. They are represented by CONFIG_DB::BGP_MONITORS table entries This PR introduces three templates for each peer type: bgp policies: represent policieas that will be applied to the bgp peer-group (ip prefix-lists, route-maps, etc) bgp peer-group: represent bgp peer group which has common configuration for the bgp peer type and uses bgp routing policy from the previous item bgp peer-group instance: represent bgp configuration, which will be used to instatiate a bgp peer-group for the bgp peer-type. Usually this one is simple, consist of the referral to the bgp peer-group, bgp peer description and bgp peer ip address. This PR redefined constant.yml file. Now this file has a setting for to use or don't use bgp_neighbor metadata. This file has more parameters for now, which are not used. They will be used in the next iteration of bgpcfgd. Currently all tests have been disabled. I'm going to create next PR with the tests right after this PR is merged. I'm going to introduce better bgpcfgd in a short time. It will include support of dynamic changes for the templates. FIX:: #4231
64 lines
2.6 KiB
Django/Jinja
64 lines
2.6 KiB
Django/Jinja
!
|
|
{# VNET BGP Instance #}
|
|
! Vnet BGP instance
|
|
{% set interfaces_in_vnets = [] %}
|
|
{% block vnet_bgp_instance %}
|
|
{% for vnet_name, vnet_metadata in VNET.iteritems() %}
|
|
router bgp {{ DEVICE_METADATA['localhost']['bgp_asn'] }} vrf {{ vnet_name }}
|
|
no bgp default ipv4-unicast
|
|
bgp log-neighbor-changes
|
|
bgp bestpath as-path multipath-relax
|
|
no bgp default ipv4-unicast
|
|
bgp graceful-restart restart-time 240
|
|
bgp graceful-restart
|
|
{# Router ID #}
|
|
{% for (name, prefix) in LOOPBACK_INTERFACE | pfx_filter %}
|
|
{% if prefix | ipv4 and name == 'Loopback0' %}
|
|
bgp router-id {{ prefix | ip }}
|
|
{% endif %}
|
|
{% endfor %}
|
|
{# Got interfaces that belong this vnet #}
|
|
{% set interfaces_in_vnet = [] %}
|
|
{% for (key, metadata) in INTERFACE.iteritems() %}
|
|
{% if metadata.has_key("vnet_name") and metadata["vnet_name"] == vnet_name %}
|
|
{% for (name_prefix_pair, metadata) in INTERFACE.iteritems() %}
|
|
{% if key == name_prefix_pair[0] %}
|
|
{% if interfaces_in_vnet.append( name_prefix_pair[1] | ip ) %}
|
|
{% endif %}
|
|
{% if interfaces_in_vnets.append( name_prefix_pair[1] | ip ) %}
|
|
{% endif %}
|
|
{% endif %}
|
|
{% endfor %}
|
|
{% endif %}
|
|
{% endfor %}
|
|
{# Each bgp neighbors #}
|
|
{% for neighbor_addr, bgp_session in BGP_NEIGHBOR.iteritems() %}
|
|
{% if bgp_session.has_key("local_addr") and bgp_session["local_addr"] in interfaces_in_vnet %}
|
|
{% if bgp_session['asn'] | int != 0 %}
|
|
neighbor {{ neighbor_addr }} remote-as {{ bgp_session['asn'] }}
|
|
neighbor {{ neighbor_addr }} description {{ bgp_session['name'] }}
|
|
{# set the bgp neighbor timers if they have not default values #}
|
|
{% if (bgp_session['keepalive'] is defined and bgp_session['keepalive'] | int != 60)
|
|
or (bgp_session['holdtime'] is defined and bgp_session['holdtime'] | int != 180) %}
|
|
neighbor {{ neighbor_addr }} timers {{ bgp_session['keepalive'] }} {{ bgp_session['holdtime'] }}
|
|
{% endif %}
|
|
{% if bgp_session.has_key('admin_status') and bgp_session['admin_status'] == 'down' or not bgp_session.has_key('admin_status') and DEVICE_METADATA['localhost'].has_key('default_bgp_status') and DEVICE_METADATA['localhost']['default_bgp_status'] == 'down' %}
|
|
neighbor {{ neighbor_addr }} shutdown
|
|
{% endif %}
|
|
{% if neighbor_addr | ipv4 %}
|
|
address-family ipv4 unicast
|
|
neighbor {{ neighbor_addr }} activate
|
|
neighbor {{ neighbor_addr }} soft-reconfiguration inbound
|
|
maximum-paths 64
|
|
exit-address-family
|
|
{% endif %}
|
|
address-family l2vpn evpn
|
|
advertise ipv4 unicast
|
|
exit-address-family
|
|
{% endif %}
|
|
{% endif %}
|
|
{% endfor %}
|
|
{% endfor %}
|
|
{% endblock vnet_bgp_instance %}
|
|
!
|