-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Let bgp docker generate configuration by itself
- Loading branch information
Showing
9 changed files
with
654 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
! | ||
{% block banner %} | ||
! =========== Managed by Ansible DO NOT EDIT! ======================== | ||
! generated by templates/quagga/bgpd.conf.j2 using minigraph_facts.py | ||
! file: bgpd.conf | ||
! | ||
{% endblock banner %} | ||
! | ||
{% block system_init %} | ||
hostname {{ inventory_hostname }} | ||
password zebra | ||
log syslog informational | ||
log facility local4 | ||
! enable password {# {{ en_passwd }} TODO: param needed #} | ||
{% endblock system_init %} | ||
! | ||
{% block bgp_init %} | ||
! | ||
! bgp multiple-instance | ||
! | ||
router bgp {{ minigraph_bgp_asn }} | ||
bgp log-neighbor-changes | ||
bgp bestpath as-path multipath-relax | ||
{# TODO: use lo[0] for backward compatibility, will revisit the case with multiple lo interfaces #} | ||
bgp router-id {{ minigraph_lo_interfaces[0]['addr'] }} | ||
{# advertise loopback #} | ||
{% for lo in minigraph_lo_interfaces %} | ||
{% if lo['addr'] | ipv4 %} | ||
network {{ lo['addr'] }}/32 | ||
{% elif lo['addr'] | ipv6 %} | ||
address-family ipv6 | ||
network {{ lo['addr'] }}/128 | ||
exit-address-family | ||
{% endif %} | ||
{% endfor %} | ||
{% endblock bgp_init %} | ||
{% block vlan_advertisement %} | ||
{% for interface in minigraph_interfaces %} | ||
{% if interface['name'].startswith('Vlan') %} | ||
network {{ interface['subnet'] }} | ||
{% endif %} | ||
{% endfor %} | ||
{% endblock vlan_advertisement %} | ||
{% block bgp_sessions %} | ||
{% for bgp_session in minigraph_bgp %} | ||
{% if bgp_session['asn'] != 0 %} | ||
neighbor {{ bgp_session['addr'] }} remote-as {{ bgp_session['asn'] }} | ||
neighbor {{ bgp_session['addr'] }} description {{ bgp_session['name'] }} | ||
{% if bgp_session['addr'] | ipv6 %} | ||
address-family ipv6 | ||
neighbor {{ bgp_session['addr'] }} activate | ||
maximum-paths 64 | ||
exit-address-family | ||
{% endif %} | ||
{% endif %} | ||
{% endfor %} | ||
{% endblock bgp_sessions %} | ||
! | ||
maximum-paths 64 | ||
! | ||
route-map ISOLATE permit 10 | ||
set as-path prepend {{ minigraph_bgp_asn }} | ||
! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/bash | ||
|
||
cd /etc/swss | ||
|
||
awk '{system("python render_config.py -m /etc/swss/minigraph.xml "$1 ">"$2" && chown "$3" "$2" && chmod "$4" "$2)}' template_list | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/bash | ||
## vtysh only accepts script in stdin, so cannot be directly used in shebang | ||
## Cut the tail of this script and feed vtysh stdin | ||
sed -n -e '9,$p' < "$0" | vtysh "$@" | ||
## Exit with vtysh return code | ||
exit $? | ||
|
||
## vtysh script start from next line, which line number MUST eqaul in 'sed' command above | ||
|
||
configure terminal | ||
router bgp {{ minigraph_bgp_asn }} | ||
{% for bgp_session in minigraph_bgp %} | ||
neighbor {{ bgp_session['addr'] }} route-map ISOLATE out | ||
{% endfor %} | ||
exit | ||
exit | ||
|
||
{% for bgp_session in minigraph_bgp %} | ||
clear ip bgp {{ bgp_session['addr'] }} soft out | ||
{% endfor %} |
Oops, something went wrong.