[docker-fpm-quagga]: Add support for PeerAsn and UpdateAddress (#2766)

This commit is contained in:
pavel-shirshov 2019-04-10 21:50:36 -07:00 committed by Ying Xie
parent 19813c2924
commit 144fe975e5
2 changed files with 13 additions and 1 deletions

View File

@ -98,14 +98,22 @@ router bgp {{ DEVICE_METADATA['localhost']['bgp_asn'] }}
{% for bgp_peer in BGP_PEER_RANGE.values() %} {% for bgp_peer in BGP_PEER_RANGE.values() %}
neighbor {{ bgp_peer['name'] }} peer-group neighbor {{ bgp_peer['name'] }} peer-group
neighbor {{ bgp_peer['name'] }} passive neighbor {{ bgp_peer['name'] }} passive
{% if bgp_peer['peer_asn'] is defined %}
neighbor {{ bgp_peer['name'] }} remote-as {{ bgp_peer['peer_asn'] }}
{% else %}
neighbor {{ bgp_peer['name'] }} remote-as {{ deployment_id_asn_map[DEVICE_METADATA['localhost']['deployment_id']] }} neighbor {{ bgp_peer['name'] }} remote-as {{ deployment_id_asn_map[DEVICE_METADATA['localhost']['deployment_id']] }}
{% endif %}
neighbor {{ bgp_peer['name'] }} ebgp-multihop 255 neighbor {{ bgp_peer['name'] }} ebgp-multihop 255
neighbor {{ bgp_peer['name'] }} soft-reconfiguration inbound neighbor {{ bgp_peer['name'] }} soft-reconfiguration inbound
{% if bgp_peer['src_address'] is defined %}
neighbor {{ bgp_peer['name'] }} update-source {{ bgp_peer['src_address'] | ip }}
{% else %}
{% for (name, prefix) in LOOPBACK_INTERFACE %} {% for (name, prefix) in LOOPBACK_INTERFACE %}
{% if name == 'Loopback1' %} {% if name == 'Loopback1' %}
neighbor {{ bgp_peer['name'] }} update-source {{ prefix | ip }} neighbor {{ bgp_peer['name'] }} update-source {{ prefix | ip }}
{% endif %} {% endif %}
{% endfor %} {% endfor %}
{% endif %}
neighbor {{ bgp_peer['name'] }} route-map FROM_BGP_SPEAKER_V4 in neighbor {{ bgp_peer['name'] }} route-map FROM_BGP_SPEAKER_V4 in
neighbor {{ bgp_peer['name'] }} route-map TO_BGP_SPEAKER_V4 out neighbor {{ bgp_peer['name'] }} route-map TO_BGP_SPEAKER_V4 out
{% for ip_range in bgp_peer['ip_range'] %} {% for ip_range in bgp_peer['ip_range'] %}

View File

@ -336,7 +336,7 @@ def parse_cpg(cpg, hname):
peers = router.find(str(QName(ns1, "Peers"))) peers = router.find(str(QName(ns1, "Peers")))
for bgpPeer in peers.findall(str(QName(ns, "BGPPeer"))): for bgpPeer in peers.findall(str(QName(ns, "BGPPeer"))):
addr = bgpPeer.find(str(QName(ns, "Address"))).text addr = bgpPeer.find(str(QName(ns, "Address"))).text
if bgpPeer.find(str(QName(ns1, "PeersRange"))) is not None: if bgpPeer.find(str(QName(ns1, "PeersRange"))) is not None: # FIXME: is better to check for type BGPPeerPassive
name = bgpPeer.find(str(QName(ns1, "Name"))).text name = bgpPeer.find(str(QName(ns1, "Name"))).text
ip_range = bgpPeer.find(str(QName(ns1, "PeersRange"))).text ip_range = bgpPeer.find(str(QName(ns1, "PeersRange"))).text
ip_range_group = ip_range.split(';') if ip_range and ip_range != "" else [] ip_range_group = ip_range.split(';') if ip_range and ip_range != "" else []
@ -344,6 +344,10 @@ def parse_cpg(cpg, hname):
'name': name, 'name': name,
'ip_range': ip_range_group 'ip_range': ip_range_group
} }
if bgpPeer.find(str(QName(ns1, "Address"))) is not None:
bgp_peers_with_range[name]['src_address'] = bgpPeer.find(str(QName(ns1, "Address"))).text
if bgpPeer.find(str(QName(ns1, "PeerAsn"))) is not None:
bgp_peers_with_range[name]['peer_asn'] = bgpPeer.find(str(QName(ns1, "PeerAsn"))).text
else: else:
for peer in bgp_sessions: for peer in bgp_sessions:
bgp_session = bgp_sessions[peer] bgp_session = bgp_sessions[peer]