[multi-ASIC] BGP internal neighbor table support (#5520)
* Initial commit for BGP internal neighbor table support. > Add new template named "internal" for the internal BGP sessions > Add a new table in database "BGP_INTERNAL_NEIGHBOR" > The internal BGP sessions will be stored in this new table "BGP_INTERNAL_NEIGHBOR" * Changes in template generation tests with the introduction of internal neighbor template files.
This commit is contained in:
parent
09d5a62fad
commit
6088bd59de
@ -15,27 +15,12 @@
|
|||||||
!
|
!
|
||||||
{% if neighbor_addr | ipv4 %}
|
{% if neighbor_addr | ipv4 %}
|
||||||
address-family ipv4
|
address-family ipv4
|
||||||
{% if 'ASIC' in bgp_session['name'] %}
|
|
||||||
neighbor {{ neighbor_addr }} peer-group PEER_V4_INT
|
|
||||||
{% else %}
|
|
||||||
neighbor {{ neighbor_addr }} peer-group PEER_V4
|
neighbor {{ neighbor_addr }} peer-group PEER_V4
|
||||||
{% endif %}
|
|
||||||
!
|
|
||||||
{% if CONFIG_DB__DEVICE_METADATA['localhost']['sub_role'] == 'BackEnd' %}
|
|
||||||
neighbor {{ neighbor_addr }} route-map FROM_BGP_PEER_V4_INT in
|
|
||||||
{% endif %}
|
|
||||||
!
|
!
|
||||||
{% elif neighbor_addr | ipv6 %}
|
{% elif neighbor_addr | ipv6 %}
|
||||||
address-family ipv6
|
address-family ipv6
|
||||||
{% if 'ASIC' in bgp_session['name'] %}
|
|
||||||
neighbor {{ neighbor_addr }} peer-group PEER_V6_INT
|
|
||||||
{% else %}
|
|
||||||
neighbor {{ neighbor_addr }} peer-group PEER_V6
|
neighbor {{ neighbor_addr }} peer-group PEER_V6
|
||||||
{% endif %}
|
|
||||||
!
|
!
|
||||||
{% if CONFIG_DB__DEVICE_METADATA['localhost']['sub_role'] == 'BackEnd' %}
|
|
||||||
neighbor {{ neighbor_addr }} route-map FROM_BGP_PEER_V6_INT in
|
|
||||||
{% endif %}
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
!
|
!
|
||||||
{% if bgp_session.has_key('rrclient') and bgp_session['rrclient'] | int != 0 %}
|
{% if bgp_session.has_key('rrclient') and bgp_session['rrclient'] | int != 0 %}
|
||||||
@ -45,10 +30,6 @@
|
|||||||
{% if bgp_session.has_key('nhopself') and bgp_session['nhopself'] | int != 0 %}
|
{% if bgp_session.has_key('nhopself') and bgp_session['nhopself'] | int != 0 %}
|
||||||
neighbor {{ neighbor_addr }} next-hop-self
|
neighbor {{ neighbor_addr }} next-hop-self
|
||||||
{% endif %}
|
{% endif %}
|
||||||
!
|
|
||||||
{% if 'ASIC' in bgp_session['name'] %}
|
|
||||||
neighbor {{ neighbor_addr }} next-hop-self force
|
|
||||||
{% endif %}
|
|
||||||
!
|
!
|
||||||
neighbor {{ neighbor_addr }} activate
|
neighbor {{ neighbor_addr }} activate
|
||||||
exit-address-family
|
exit-address-family
|
||||||
|
@ -2,46 +2,30 @@
|
|||||||
! template: bgpd/templates/general/peer-group.conf.j2
|
! template: bgpd/templates/general/peer-group.conf.j2
|
||||||
!
|
!
|
||||||
neighbor PEER_V4 peer-group
|
neighbor PEER_V4 peer-group
|
||||||
neighbor PEER_V4_INT peer-group
|
|
||||||
neighbor PEER_V6 peer-group
|
neighbor PEER_V6 peer-group
|
||||||
neighbor PEER_V6_INT peer-group
|
|
||||||
address-family ipv4
|
address-family ipv4
|
||||||
{% if CONFIG_DB__DEVICE_METADATA['localhost']['type'] == 'ToRRouter' %}
|
{% if CONFIG_DB__DEVICE_METADATA['localhost']['type'] == 'ToRRouter' %}
|
||||||
neighbor PEER_V4 allowas-in 1
|
neighbor PEER_V4 allowas-in 1
|
||||||
neighbor PEER_V4_INT allowas-in 1
|
|
||||||
{% elif CONFIG_DB__DEVICE_METADATA['localhost']['type'] == 'LeafRouter' %}
|
{% elif CONFIG_DB__DEVICE_METADATA['localhost']['type'] == 'LeafRouter' %}
|
||||||
{% if CONFIG_DB__BGP_BBR['status'] == 'enabled' %}
|
{% if CONFIG_DB__BGP_BBR['status'] == 'enabled' %}
|
||||||
neighbor PEER_V4 allowas-in 1
|
neighbor PEER_V4 allowas-in 1
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
|
||||||
{% if CONFIG_DB__DEVICE_METADATA['localhost']['sub_role'] == 'BackEnd' %}
|
|
||||||
neighbor PEER_V4_INT route-reflector-client
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
neighbor PEER_V4 soft-reconfiguration inbound
|
neighbor PEER_V4 soft-reconfiguration inbound
|
||||||
neighbor PEER_V4 route-map FROM_BGP_PEER_V4 in
|
neighbor PEER_V4 route-map FROM_BGP_PEER_V4 in
|
||||||
neighbor PEER_V4 route-map TO_BGP_PEER_V4 out
|
neighbor PEER_V4 route-map TO_BGP_PEER_V4 out
|
||||||
neighbor PEER_V4_INT soft-reconfiguration inbound
|
|
||||||
neighbor PEER_V4_INT route-map FROM_BGP_PEER_V4 in
|
|
||||||
neighbor PEER_V4_INT route-map TO_BGP_PEER_V4 out
|
|
||||||
exit-address-family
|
exit-address-family
|
||||||
address-family ipv6
|
address-family ipv6
|
||||||
{% if CONFIG_DB__DEVICE_METADATA['localhost']['type'] == 'ToRRouter' %}
|
{% if CONFIG_DB__DEVICE_METADATA['localhost']['type'] == 'ToRRouter' %}
|
||||||
neighbor PEER_V6 allowas-in 1
|
neighbor PEER_V6 allowas-in 1
|
||||||
neighbor PEER_V6_INT allowas-in 1
|
|
||||||
{% elif CONFIG_DB__DEVICE_METADATA['localhost']['type'] == 'LeafRouter' %}
|
{% elif CONFIG_DB__DEVICE_METADATA['localhost']['type'] == 'LeafRouter' %}
|
||||||
{% if CONFIG_DB__BGP_BBR['status'] == 'enabled' %}
|
{% if CONFIG_DB__BGP_BBR['status'] == 'enabled' %}
|
||||||
neighbor PEER_V6 allowas-in 1
|
neighbor PEER_V6 allowas-in 1
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
|
||||||
{% if CONFIG_DB__DEVICE_METADATA['localhost']['sub_role'] == 'BackEnd' %}
|
|
||||||
neighbor PEER_V6_INT route-reflector-client
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
neighbor PEER_V6 soft-reconfiguration inbound
|
neighbor PEER_V6 soft-reconfiguration inbound
|
||||||
neighbor PEER_V6 route-map FROM_BGP_PEER_V6 in
|
neighbor PEER_V6 route-map FROM_BGP_PEER_V6 in
|
||||||
neighbor PEER_V6 route-map TO_BGP_PEER_V6 out
|
neighbor PEER_V6 route-map TO_BGP_PEER_V6 out
|
||||||
neighbor PEER_V6_INT soft-reconfiguration inbound
|
|
||||||
neighbor PEER_V6_INT route-map FROM_BGP_PEER_V6 in
|
|
||||||
neighbor PEER_V6_INT route-map TO_BGP_PEER_V6 out
|
|
||||||
exit-address-family
|
exit-address-family
|
||||||
!
|
!
|
||||||
! end of template: bgpd/templates/general/peer-group.conf.j2
|
! end of template: bgpd/templates/general/peer-group.conf.j2
|
||||||
|
@ -42,16 +42,5 @@ route-map FROM_BGP_PEER_V6 permit 100
|
|||||||
!
|
!
|
||||||
route-map TO_BGP_PEER_V6 permit 100
|
route-map TO_BGP_PEER_V6 permit 100
|
||||||
!
|
!
|
||||||
{% if CONFIG_DB__DEVICE_METADATA['localhost']['sub_role'] == 'BackEnd' %}
|
|
||||||
route-map FROM_BGP_PEER_V4_INT permit 2
|
|
||||||
set originator-id {{ loopback0_ipv4 | ip }}
|
|
||||||
!
|
|
||||||
route-map FROM_BGP_PEER_V6_INT permit 1
|
|
||||||
set ipv6 next-hop prefer-global
|
|
||||||
!
|
|
||||||
route-map FROM_BGP_PEER_V6_INT permit 2
|
|
||||||
set originator-id {{ loopback0_ipv4 | ip }}
|
|
||||||
{% endif %}
|
|
||||||
!
|
|
||||||
! end of template: bgpd/templates/general/policies.conf.j2
|
! end of template: bgpd/templates/general/policies.conf.j2
|
||||||
!
|
!
|
||||||
|
@ -0,0 +1,34 @@
|
|||||||
|
!
|
||||||
|
! template: bgpd/templates/internal/instance.conf.j2
|
||||||
|
!
|
||||||
|
neighbor {{ neighbor_addr }} remote-as {{ bgp_session['asn'] }}
|
||||||
|
neighbor {{ neighbor_addr }} description {{ bgp_session['name'] }}
|
||||||
|
!
|
||||||
|
{% if neighbor_addr | ipv4 %}
|
||||||
|
address-family ipv4
|
||||||
|
neighbor {{ neighbor_addr }} peer-group INTERNAL_PEER_V4
|
||||||
|
!
|
||||||
|
{% if CONFIG_DB__DEVICE_METADATA['localhost']['sub_role'] == 'BackEnd' %}
|
||||||
|
neighbor {{ neighbor_addr }} route-map FROM_BGP_INTERNAL_PEER_V4 in
|
||||||
|
{% endif %}
|
||||||
|
!
|
||||||
|
{% elif neighbor_addr | ipv6 %}
|
||||||
|
address-family ipv6
|
||||||
|
neighbor {{ neighbor_addr }} peer-group INTERNAL_PEER_V6
|
||||||
|
!
|
||||||
|
{% if CONFIG_DB__DEVICE_METADATA['localhost']['sub_role'] == 'BackEnd' %}
|
||||||
|
neighbor {{ neighbor_addr }} route-map FROM_BGP_INTERNAL_PEER_V6 in
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
!
|
||||||
|
{% if bgp_session.has_key('rrclient') and bgp_session['rrclient'] | int != 0 %}
|
||||||
|
neighbor {{ neighbor_addr }} route-reflector-client
|
||||||
|
{% endif %}
|
||||||
|
!
|
||||||
|
neighbor {{ neighbor_addr }} next-hop-self force
|
||||||
|
!
|
||||||
|
neighbor {{ neighbor_addr }} activate
|
||||||
|
exit-address-family
|
||||||
|
!
|
||||||
|
! end of template: bgpd/templates/internal/instance.conf.j2
|
||||||
|
!
|
@ -0,0 +1,24 @@
|
|||||||
|
!
|
||||||
|
! template: bgpd/templates/internal/peer-group.conf.j2
|
||||||
|
!
|
||||||
|
neighbor INTERNAL_PEER_V4 peer-group
|
||||||
|
neighbor INTERNAL_PEER_V6 peer-group
|
||||||
|
address-family ipv4
|
||||||
|
{% if CONFIG_DB__DEVICE_METADATA['localhost']['sub_role'] == 'BackEnd' %}
|
||||||
|
neighbor INTERNAL_PEER_V4 route-reflector-client
|
||||||
|
{% endif %}
|
||||||
|
neighbor INTERNAL_PEER_V4 soft-reconfiguration inbound
|
||||||
|
neighbor INTERNAL_PEER_V4 route-map FROM_BGP_INTERNAL_PEER_V4 in
|
||||||
|
neighbor INTERNAL_PEER_V4 route-map TO_BGP_INTERNAL_PEER_V4 out
|
||||||
|
exit-address-family
|
||||||
|
address-family ipv6
|
||||||
|
{% if CONFIG_DB__DEVICE_METADATA['localhost']['sub_role'] == 'BackEnd' %}
|
||||||
|
neighbor INTERNAL_PEER_V6 route-reflector-client
|
||||||
|
{% endif %}
|
||||||
|
neighbor INTERNAL_PEER_V6 soft-reconfiguration inbound
|
||||||
|
neighbor INTERNAL_PEER_V6 route-map FROM_BGP_INTERNAL_PEER_V6 in
|
||||||
|
neighbor INTERNAL_PEER_V6 route-map TO_BGP_INTERNAL_PEER_V6 out
|
||||||
|
exit-address-family
|
||||||
|
!
|
||||||
|
! end of template: bgpd/templates/internal/peer-group.conf.j2
|
||||||
|
!
|
@ -0,0 +1,27 @@
|
|||||||
|
!
|
||||||
|
! template: bgpd/templates/internal/policies.conf.j2
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
route-map FROM_BGP_INTERNAL_PEER_V4 permit 100
|
||||||
|
!
|
||||||
|
route-map TO_BGP_INTERNAL_PEER_V4 permit 100
|
||||||
|
!
|
||||||
|
!
|
||||||
|
route-map FROM_BGP_INTERNAL_PEER_V6 permit 1
|
||||||
|
set ipv6 next-hop prefer-global
|
||||||
|
!
|
||||||
|
route-map FROM_BGP_INTERNAL_PEER_V6 permit 100
|
||||||
|
!
|
||||||
|
route-map TO_BGP_INTERNAL_PEER_V6 permit 100
|
||||||
|
!
|
||||||
|
{% if CONFIG_DB__DEVICE_METADATA['localhost']['sub_role'] == 'BackEnd' %}
|
||||||
|
route-map FROM_BGP_INTERNAL_PEER_V4 permit 2
|
||||||
|
set originator-id {{ loopback0_ipv4 | ip }}
|
||||||
|
!
|
||||||
|
route-map FROM_BGP_INTERNAL_PEER_V6 permit 2
|
||||||
|
set originator-id {{ loopback0_ipv4 | ip }}
|
||||||
|
{% endif %}
|
||||||
|
!
|
||||||
|
! end of template: bgpd/templates/internal/policies.conf.j2
|
||||||
|
!
|
@ -40,6 +40,9 @@ constants:
|
|||||||
- ipv4
|
- ipv4
|
||||||
PEER_V6:
|
PEER_V6:
|
||||||
- ipv6
|
- ipv6
|
||||||
|
internal: # peer_type
|
||||||
|
db_table: "BGP_INTERNAL_NEIGHBOR"
|
||||||
|
template_dir: "internal"
|
||||||
monitors: # peer_type
|
monitors: # peer_type
|
||||||
enabled: true
|
enabled: true
|
||||||
db_table: "BGP_MONITORS"
|
db_table: "BGP_MONITORS"
|
||||||
|
@ -44,6 +44,7 @@ def do_work():
|
|||||||
ZebraSetSrc(common_objs, "STATE_DB", swsscommon.STATE_INTERFACE_TABLE_NAME),
|
ZebraSetSrc(common_objs, "STATE_DB", swsscommon.STATE_INTERFACE_TABLE_NAME),
|
||||||
# Peer Managers
|
# Peer Managers
|
||||||
BGPPeerMgrBase(common_objs, "CONFIG_DB", swsscommon.CFG_BGP_NEIGHBOR_TABLE_NAME, "general", True),
|
BGPPeerMgrBase(common_objs, "CONFIG_DB", swsscommon.CFG_BGP_NEIGHBOR_TABLE_NAME, "general", True),
|
||||||
|
BGPPeerMgrBase(common_objs, "CONFIG_DB", swsscommon.CFG_BGP_INTERNAL_NEIGHBOR_TABLE_NAME, "internal", False),
|
||||||
BGPPeerMgrBase(common_objs, "CONFIG_DB", "BGP_MONITORS", "monitors", False),
|
BGPPeerMgrBase(common_objs, "CONFIG_DB", "BGP_MONITORS", "monitors", False),
|
||||||
BGPPeerMgrBase(common_objs, "CONFIG_DB", "BGP_PEER_RANGE", "dynamic", False),
|
BGPPeerMgrBase(common_objs, "CONFIG_DB", "BGP_PEER_RANGE", "dynamic", False),
|
||||||
# AllowList Managers
|
# AllowList Managers
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
{
|
|
||||||
"CONFIG_DB__DEVICE_METADATA": {
|
|
||||||
"localhost": {}
|
|
||||||
},
|
|
||||||
"neighbor_addr": "FC00::",
|
|
||||||
"bgp_session": {
|
|
||||||
"asn": "555",
|
|
||||||
"name": "_ASIC_"
|
|
||||||
},
|
|
||||||
"constants": {
|
|
||||||
"deployment_id_asn_map": {
|
|
||||||
"5": "51111"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,9 +1,4 @@
|
|||||||
{
|
{
|
||||||
"CONFIG_DB__DEVICE_METADATA": {
|
|
||||||
"localhost": {
|
|
||||||
"sub_role": "BackEnd"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"neighbor_addr": "10.10.10.10",
|
"neighbor_addr": "10.10.10.10",
|
||||||
"bgp_session": {
|
"bgp_session": {
|
||||||
"asn": "555",
|
"asn": "555",
|
||||||
|
@ -1,9 +1,4 @@
|
|||||||
{
|
{
|
||||||
"CONFIG_DB__DEVICE_METADATA": {
|
|
||||||
"localhost": {
|
|
||||||
"sub_role": "BackEnd"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"neighbor_addr": "fc::10",
|
"neighbor_addr": "fc::10",
|
||||||
"bgp_session": {
|
"bgp_session": {
|
||||||
"asn": "555",
|
"asn": "555",
|
||||||
|
@ -1,13 +0,0 @@
|
|||||||
!
|
|
||||||
! template: bgpd/templates/general/instance.conf.j2
|
|
||||||
!
|
|
||||||
neighbor FC00:: remote-as 555
|
|
||||||
neighbor FC00:: description _ASIC_
|
|
||||||
address-family ipv6
|
|
||||||
neighbor FC00:: peer-group PEER_V6_INT
|
|
||||||
neighbor FC00:: next-hop-self force
|
|
||||||
neighbor FC00:: activate
|
|
||||||
exit-address-family
|
|
||||||
!
|
|
||||||
! end of template: bgpd/templates/general/instance.conf.j2
|
|
||||||
!
|
|
@ -7,7 +7,6 @@
|
|||||||
neighbor 10.10.10.10 shutdown
|
neighbor 10.10.10.10 shutdown
|
||||||
address-family ipv4
|
address-family ipv4
|
||||||
neighbor 10.10.10.10 peer-group PEER_V4
|
neighbor 10.10.10.10 peer-group PEER_V4
|
||||||
neighbor 10.10.10.10 route-map FROM_BGP_PEER_V4_INT in
|
|
||||||
neighbor 10.10.10.10 route-reflector-client
|
neighbor 10.10.10.10 route-reflector-client
|
||||||
neighbor 10.10.10.10 next-hop-self
|
neighbor 10.10.10.10 next-hop-self
|
||||||
neighbor 10.10.10.10 activate
|
neighbor 10.10.10.10 activate
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
neighbor fc::10 shutdown
|
neighbor fc::10 shutdown
|
||||||
address-family ipv6
|
address-family ipv6
|
||||||
neighbor fc::10 peer-group PEER_V6
|
neighbor fc::10 peer-group PEER_V6
|
||||||
neighbor fc::10 route-map FROM_BGP_PEER_V6_INT in
|
|
||||||
neighbor fc::10 route-reflector-client
|
neighbor fc::10 route-reflector-client
|
||||||
neighbor fc::10 next-hop-self
|
neighbor fc::10 next-hop-self
|
||||||
neighbor fc::10 activate
|
neighbor fc::10 activate
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
{
|
{
|
||||||
"CONFIG_DB__DEVICE_METADATA": {
|
"CONFIG_DB__DEVICE_METADATA": {
|
||||||
"localhost": {
|
"localhost": {
|
||||||
"type": "LeafRouter",
|
"type": "LeafRouter"
|
||||||
"sub_role": "BackEnd"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"CONFIG_DB__BGP_BBR": {
|
"CONFIG_DB__BGP_BBR": {
|
||||||
|
@ -2,28 +2,18 @@
|
|||||||
! template: bgpd/templates/general/peer-group.conf.j2
|
! template: bgpd/templates/general/peer-group.conf.j2
|
||||||
!
|
!
|
||||||
neighbor PEER_V4 peer-group
|
neighbor PEER_V4 peer-group
|
||||||
neighbor PEER_V4_INT peer-group
|
|
||||||
neighbor PEER_V6 peer-group
|
neighbor PEER_V6 peer-group
|
||||||
neighbor PEER_V6_INT peer-group
|
|
||||||
address-family ipv4
|
address-family ipv4
|
||||||
neighbor PEER_V4 allowas-in 1
|
neighbor PEER_V4 allowas-in 1
|
||||||
neighbor PEER_V4_INT allowas-in 1
|
|
||||||
neighbor PEER_V4 soft-reconfiguration inbound
|
neighbor PEER_V4 soft-reconfiguration inbound
|
||||||
neighbor PEER_V4 route-map FROM_BGP_PEER_V4 in
|
neighbor PEER_V4 route-map FROM_BGP_PEER_V4 in
|
||||||
neighbor PEER_V4 route-map TO_BGP_PEER_V4 out
|
neighbor PEER_V4 route-map TO_BGP_PEER_V4 out
|
||||||
neighbor PEER_V4_INT soft-reconfiguration inbound
|
|
||||||
neighbor PEER_V4_INT route-map FROM_BGP_PEER_V4 in
|
|
||||||
neighbor PEER_V4_INT route-map TO_BGP_PEER_V4 out
|
|
||||||
exit-address-family
|
exit-address-family
|
||||||
address-family ipv6
|
address-family ipv6
|
||||||
neighbor PEER_V6 allowas-in 1
|
neighbor PEER_V6 allowas-in 1
|
||||||
neighbor PEER_V6_INT allowas-in 1
|
|
||||||
neighbor PEER_V6 soft-reconfiguration inbound
|
neighbor PEER_V6 soft-reconfiguration inbound
|
||||||
neighbor PEER_V6 route-map FROM_BGP_PEER_V6 in
|
neighbor PEER_V6 route-map FROM_BGP_PEER_V6 in
|
||||||
neighbor PEER_V6 route-map TO_BGP_PEER_V6 out
|
neighbor PEER_V6 route-map TO_BGP_PEER_V6 out
|
||||||
neighbor PEER_V6_INT soft-reconfiguration inbound
|
|
||||||
neighbor PEER_V6_INT route-map FROM_BGP_PEER_V6 in
|
|
||||||
neighbor PEER_V6_INT route-map TO_BGP_PEER_V6 out
|
|
||||||
exit-address-family
|
exit-address-family
|
||||||
!
|
!
|
||||||
! end of template: bgpd/templates/general/peer-group.conf.j2
|
! end of template: bgpd/templates/general/peer-group.conf.j2
|
||||||
|
@ -2,26 +2,16 @@
|
|||||||
! template: bgpd/templates/general/peer-group.conf.j2
|
! template: bgpd/templates/general/peer-group.conf.j2
|
||||||
!
|
!
|
||||||
neighbor PEER_V4 peer-group
|
neighbor PEER_V4 peer-group
|
||||||
neighbor PEER_V4_INT peer-group
|
|
||||||
neighbor PEER_V6 peer-group
|
neighbor PEER_V6 peer-group
|
||||||
neighbor PEER_V6_INT peer-group
|
|
||||||
address-family ipv4
|
address-family ipv4
|
||||||
neighbor PEER_V4_INT route-reflector-client
|
|
||||||
neighbor PEER_V4 soft-reconfiguration inbound
|
neighbor PEER_V4 soft-reconfiguration inbound
|
||||||
neighbor PEER_V4 route-map FROM_BGP_PEER_V4 in
|
neighbor PEER_V4 route-map FROM_BGP_PEER_V4 in
|
||||||
neighbor PEER_V4 route-map TO_BGP_PEER_V4 out
|
neighbor PEER_V4 route-map TO_BGP_PEER_V4 out
|
||||||
neighbor PEER_V4_INT soft-reconfiguration inbound
|
|
||||||
neighbor PEER_V4_INT route-map FROM_BGP_PEER_V4 in
|
|
||||||
neighbor PEER_V4_INT route-map TO_BGP_PEER_V4 out
|
|
||||||
exit-address-family
|
exit-address-family
|
||||||
address-family ipv6
|
address-family ipv6
|
||||||
neighbor PEER_V6_INT route-reflector-client
|
|
||||||
neighbor PEER_V6 soft-reconfiguration inbound
|
neighbor PEER_V6 soft-reconfiguration inbound
|
||||||
neighbor PEER_V6 route-map FROM_BGP_PEER_V6 in
|
neighbor PEER_V6 route-map FROM_BGP_PEER_V6 in
|
||||||
neighbor PEER_V6 route-map TO_BGP_PEER_V6 out
|
neighbor PEER_V6 route-map TO_BGP_PEER_V6 out
|
||||||
neighbor PEER_V6_INT soft-reconfiguration inbound
|
|
||||||
neighbor PEER_V6_INT route-map FROM_BGP_PEER_V6 in
|
|
||||||
neighbor PEER_V6_INT route-map TO_BGP_PEER_V6 out
|
|
||||||
exit-address-family
|
exit-address-family
|
||||||
!
|
!
|
||||||
! end of template: bgpd/templates/general/peer-group.conf.j2
|
! end of template: bgpd/templates/general/peer-group.conf.j2
|
||||||
|
@ -1,9 +1,4 @@
|
|||||||
{
|
{
|
||||||
"CONFIG_DB__DEVICE_METADATA": {
|
|
||||||
"localhost": {
|
|
||||||
"sub_role": "BackEnd"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"loopback0_ipv4": "10.10.10.10/32",
|
"loopback0_ipv4": "10.10.10.10/32",
|
||||||
"constants": {
|
"constants": {
|
||||||
"bgp": {
|
"bgp": {
|
||||||
|
@ -1,9 +1,4 @@
|
|||||||
{
|
{
|
||||||
"CONFIG_DB__DEVICE_METADATA": {
|
|
||||||
"localhost": {
|
|
||||||
"sub_role": "NotBackEnd"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"loopback0_ipv4": "10.10.10.10/32",
|
"loopback0_ipv4": "10.10.10.10/32",
|
||||||
"constants": {
|
"constants": {
|
||||||
"bgp": {
|
"bgp": {
|
||||||
|
@ -1,9 +1,4 @@
|
|||||||
{
|
{
|
||||||
"CONFIG_DB__DEVICE_METADATA": {
|
|
||||||
"localhost": {
|
|
||||||
"sub_role": "BackEnd"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"loopback0_ipv4": "10.10.10.10/32",
|
"loopback0_ipv4": "10.10.10.10/32",
|
||||||
"constants": {
|
"constants": {
|
||||||
"bgp": {
|
"bgp": {
|
||||||
|
@ -26,14 +26,5 @@ route-map FROM_BGP_PEER_V6 permit 100
|
|||||||
!
|
!
|
||||||
route-map TO_BGP_PEER_V6 permit 100
|
route-map TO_BGP_PEER_V6 permit 100
|
||||||
!
|
!
|
||||||
route-map FROM_BGP_PEER_V4_INT permit 2
|
|
||||||
set originator-id 10.10.10.10
|
|
||||||
!
|
|
||||||
route-map FROM_BGP_PEER_V6_INT permit 1
|
|
||||||
set ipv6 next-hop prefer-global
|
|
||||||
!
|
|
||||||
route-map FROM_BGP_PEER_V6_INT permit 2
|
|
||||||
set originator-id 10.10.10.10
|
|
||||||
!
|
|
||||||
! end of template: bgpd/templates/general/policies.conf.j2
|
! end of template: bgpd/templates/general/policies.conf.j2
|
||||||
!
|
!
|
||||||
|
@ -26,14 +26,5 @@ route-map FROM_BGP_PEER_V6 permit 100
|
|||||||
!
|
!
|
||||||
route-map TO_BGP_PEER_V6 permit 100
|
route-map TO_BGP_PEER_V6 permit 100
|
||||||
!
|
!
|
||||||
route-map FROM_BGP_PEER_V4_INT permit 2
|
|
||||||
set originator-id 10.10.10.10
|
|
||||||
!
|
|
||||||
route-map FROM_BGP_PEER_V6_INT permit 1
|
|
||||||
set ipv6 next-hop prefer-global
|
|
||||||
!
|
|
||||||
route-map FROM_BGP_PEER_V6_INT permit 2
|
|
||||||
set originator-id 10.10.10.10
|
|
||||||
!
|
|
||||||
! end of template: bgpd/templates/general/policies.conf.j2
|
! end of template: bgpd/templates/general/policies.conf.j2
|
||||||
!
|
!
|
||||||
|
@ -0,0 +1,23 @@
|
|||||||
|
{
|
||||||
|
"CONFIG_DB__DEVICE_METADATA": {
|
||||||
|
"localhost": {
|
||||||
|
"sub_role": "BackEnd"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"neighbor_addr": "10.10.10.10",
|
||||||
|
"bgp_session": {
|
||||||
|
"asn": "555",
|
||||||
|
"name": "remote_peer",
|
||||||
|
"keepalive": "5",
|
||||||
|
"holdtime": "30",
|
||||||
|
"admin_status": "down",
|
||||||
|
"ASIC": "something",
|
||||||
|
"rrclient": "1",
|
||||||
|
"nhopself": "1"
|
||||||
|
},
|
||||||
|
"constants": {
|
||||||
|
"deployment_id_asn_map": {
|
||||||
|
"5": "51111"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
{
|
||||||
|
"CONFIG_DB__DEVICE_METADATA": {
|
||||||
|
"localhost": {
|
||||||
|
"sub_role": "BackEnd"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"neighbor_addr": "fc::10",
|
||||||
|
"bgp_session": {
|
||||||
|
"asn": "555",
|
||||||
|
"name": "remote_peer",
|
||||||
|
"keepalive": "5",
|
||||||
|
"holdtime": "30",
|
||||||
|
"admin_status": "down",
|
||||||
|
"ASIC": "something",
|
||||||
|
"rrclient": "1",
|
||||||
|
"nhopself": "1"
|
||||||
|
},
|
||||||
|
"constants": {
|
||||||
|
"deployment_id_asn_map": {
|
||||||
|
"5": "51111"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,11 +1,17 @@
|
|||||||
{
|
{
|
||||||
"CONFIG_DB__DEVICE_METADATA": {
|
"CONFIG_DB__DEVICE_METADATA": {
|
||||||
"localhost": {}
|
"localhost": {
|
||||||
|
"sub_role": "FrontEnd"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"neighbor_addr": "10.10.10.10",
|
"neighbor_addr": "10.10.10.10",
|
||||||
"bgp_session": {
|
"bgp_session": {
|
||||||
"asn": "555",
|
"asn": "555",
|
||||||
"name": "_ASIC_"
|
"name": "remote_peer",
|
||||||
|
"keepalive": "5",
|
||||||
|
"holdtime": "30",
|
||||||
|
"admin_status": "down",
|
||||||
|
"ASIC": "something"
|
||||||
},
|
},
|
||||||
"constants": {
|
"constants": {
|
||||||
"deployment_id_asn_map": {
|
"deployment_id_asn_map": {
|
@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"CONFIG_DB__DEVICE_METADATA": {
|
||||||
|
"localhost": {
|
||||||
|
"sub_role": "FrontEnd"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"neighbor_addr": "fc::10",
|
||||||
|
"bgp_session": {
|
||||||
|
"asn": "555",
|
||||||
|
"name": "remote_peer",
|
||||||
|
"keepalive": "5",
|
||||||
|
"holdtime": "30",
|
||||||
|
"admin_status": "down",
|
||||||
|
"ASIC": "something"
|
||||||
|
},
|
||||||
|
"constants": {
|
||||||
|
"deployment_id_asn_map": {
|
||||||
|
"5": "51111"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
!
|
||||||
|
! template: bgpd/templates/general/instance.conf.j2
|
||||||
|
!
|
||||||
|
neighbor 10.10.10.10 remote-as 555
|
||||||
|
neighbor 10.10.10.10 description remote_peer
|
||||||
|
neighbor 10.10.10.10 timers 5 30
|
||||||
|
neighbor 10.10.10.10 shutdown
|
||||||
|
address-family ipv4
|
||||||
|
neighbor 10.10.10.10 peer-group INTERNAL_PEER_V4
|
||||||
|
neighbor 10.10.10.10 route-map FROM_BGP_INTERNAL_PEER_V4 in
|
||||||
|
neighbor 10.10.10.10 route-reflector-client
|
||||||
|
neighbor 10.10.10.10 next-hop-self force
|
||||||
|
neighbor 10.10.10.10 activate
|
||||||
|
exit-address-family
|
||||||
|
!
|
||||||
|
! end of template: bgpd/templates/general/instance.conf.j2
|
||||||
|
!
|
@ -0,0 +1,17 @@
|
|||||||
|
!
|
||||||
|
! template: bgpd/templates/general/instance.conf.j2
|
||||||
|
!
|
||||||
|
neighbor fc::10 remote-as 555
|
||||||
|
neighbor fc::10 description remote_peer
|
||||||
|
neighbor fc::10 timers 5 30
|
||||||
|
neighbor fc::10 shutdown
|
||||||
|
address-family ipv6
|
||||||
|
neighbor fc::10 peer-group INTERNAL_PEER_V6
|
||||||
|
neighbor fc::10 route-map FROM_BGP_INTERNAL_PEER_V6 in
|
||||||
|
neighbor fc::10 route-reflector-client
|
||||||
|
neighbor fc::10 next-hop-self force
|
||||||
|
neighbor fc::10 activate
|
||||||
|
exit-address-family
|
||||||
|
!
|
||||||
|
! end of template: bgpd/templates/general/instance.conf.j2
|
||||||
|
!
|
@ -2,9 +2,11 @@
|
|||||||
! template: bgpd/templates/general/instance.conf.j2
|
! template: bgpd/templates/general/instance.conf.j2
|
||||||
!
|
!
|
||||||
neighbor 10.10.10.10 remote-as 555
|
neighbor 10.10.10.10 remote-as 555
|
||||||
neighbor 10.10.10.10 description _ASIC_
|
neighbor 10.10.10.10 description remote_peer
|
||||||
|
neighbor 10.10.10.10 timers 5 30
|
||||||
|
neighbor 10.10.10.10 shutdown
|
||||||
address-family ipv4
|
address-family ipv4
|
||||||
neighbor 10.10.10.10 peer-group PEER_V4_INT
|
neighbor 10.10.10.10 peer-group INTERNAL_PEER_V4
|
||||||
neighbor 10.10.10.10 next-hop-self force
|
neighbor 10.10.10.10 next-hop-self force
|
||||||
neighbor 10.10.10.10 activate
|
neighbor 10.10.10.10 activate
|
||||||
exit-address-family
|
exit-address-family
|
@ -0,0 +1,15 @@
|
|||||||
|
!
|
||||||
|
! template: bgpd/templates/general/instance.conf.j2
|
||||||
|
!
|
||||||
|
neighbor fc::10 remote-as 555
|
||||||
|
neighbor fc::10 description remote_peer
|
||||||
|
neighbor fc::10 timers 5 30
|
||||||
|
neighbor fc::10 shutdown
|
||||||
|
address-family ipv6
|
||||||
|
neighbor fc::10 peer-group INTERNAL_PEER_V6
|
||||||
|
neighbor fc::10 next-hop-self force
|
||||||
|
neighbor fc::10 activate
|
||||||
|
exit-address-family
|
||||||
|
!
|
||||||
|
! end of template: bgpd/templates/general/instance.conf.j2
|
||||||
|
!
|
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"CONFIG_DB__DEVICE_METADATA": {
|
||||||
|
"localhost": {
|
||||||
|
"type": "LeafRouter",
|
||||||
|
"sub_role": "BackEnd"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"CONFIG_DB__DEVICE_METADATA": {
|
||||||
|
"localhost": {
|
||||||
|
"type": "LeafRouter",
|
||||||
|
"sub_role": "FrontEnd"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
!
|
||||||
|
! template: bgpd/templates/general/peer-group.conf.j2
|
||||||
|
!
|
||||||
|
neighbor INTERNAL_PEER_V4 peer-group
|
||||||
|
neighbor INTERNAL_PEER_V6 peer-group
|
||||||
|
address-family ipv4
|
||||||
|
neighbor INTERNAL_PEER_V4 route-reflector-client
|
||||||
|
neighbor INTERNAL_PEER_V4 soft-reconfiguration inbound
|
||||||
|
neighbor INTERNAL_PEER_V4 route-map FROM_BGP_INTERNAL_PEER_V4 in
|
||||||
|
neighbor INTERNAL_PEER_V4 route-map TO_BGP_INTERNAL_PEER_V4 out
|
||||||
|
exit-address-family
|
||||||
|
address-family ipv6
|
||||||
|
neighbor INTERNAL_PEER_V6 route-reflector-client
|
||||||
|
neighbor INTERNAL_PEER_V6 soft-reconfiguration inbound
|
||||||
|
neighbor INTERNAL_PEER_V6 route-map FROM_BGP_INTERNAL_PEER_V6 in
|
||||||
|
neighbor INTERNAL_PEER_V6 route-map TO_BGP_INTERNAL_PEER_V6 out
|
||||||
|
exit-address-family
|
||||||
|
!
|
||||||
|
! end of template: bgpd/templates/general/peer-group.conf.j2
|
||||||
|
!
|
@ -0,0 +1,18 @@
|
|||||||
|
!
|
||||||
|
! template: bgpd/templates/general/peer-group.conf.j2
|
||||||
|
!
|
||||||
|
neighbor INTERNAL_PEER_V4 peer-group
|
||||||
|
neighbor INTERNAL_PEER_V6 peer-group
|
||||||
|
address-family ipv4
|
||||||
|
neighbor INTERNAL_PEER_V4 soft-reconfiguration inbound
|
||||||
|
neighbor INTERNAL_PEER_V4 route-map FROM_BGP_INTERNAL_PEER_V4 in
|
||||||
|
neighbor INTERNAL_PEER_V4 route-map TO_BGP_INTERNAL_PEER_V4 out
|
||||||
|
exit-address-family
|
||||||
|
address-family ipv6
|
||||||
|
neighbor INTERNAL_PEER_V6 soft-reconfiguration inbound
|
||||||
|
neighbor INTERNAL_PEER_V6 route-map FROM_BGP_INTERNAL_PEER_V6 in
|
||||||
|
neighbor INTERNAL_PEER_V6 route-map TO_BGP_INTERNAL_PEER_V6 out
|
||||||
|
exit-address-family
|
||||||
|
!
|
||||||
|
! end of template: bgpd/templates/general/peer-group.conf.j2
|
||||||
|
!
|
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"CONFIG_DB__DEVICE_METADATA": {
|
||||||
|
"localhost": {
|
||||||
|
"sub_role": "BackEnd"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"loopback0_ipv4": "10.10.10.10/32"
|
||||||
|
}
|
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"CONFIG_DB__DEVICE_METADATA": {
|
||||||
|
"localhost": {
|
||||||
|
"sub_role": "FrontkEnd"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"loopback0_ipv4": "10.10.10.10/32"
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
!
|
||||||
|
! template: bgpd/templates/general/policies.conf.j2
|
||||||
|
!
|
||||||
|
route-map FROM_BGP_INTERNAL_PEER_V4 permit 100
|
||||||
|
!
|
||||||
|
route-map TO_BGP_INTERNAL_PEER_V4 permit 100
|
||||||
|
!
|
||||||
|
route-map FROM_BGP_INTERNAL_PEER_V6 permit 1
|
||||||
|
set ipv6 next-hop prefer-global
|
||||||
|
!
|
||||||
|
route-map FROM_BGP_INTERNAL_PEER_V6 permit 100
|
||||||
|
!
|
||||||
|
route-map TO_BGP_INTERNAL_PEER_V6 permit 100
|
||||||
|
!
|
||||||
|
route-map FROM_BGP_INTERNAL_PEER_V4 permit 2
|
||||||
|
set originator-id 10.10.10.10
|
||||||
|
!
|
||||||
|
route-map FROM_BGP_INTERNAL_PEER_V6 permit 2
|
||||||
|
set originator-id 10.10.10.10
|
||||||
|
!
|
||||||
|
! end of template: bgpd/templates/general/policies.conf.j2
|
||||||
|
!
|
@ -0,0 +1,16 @@
|
|||||||
|
!
|
||||||
|
! template: bgpd/templates/general/policies.conf.j2
|
||||||
|
!
|
||||||
|
route-map FROM_BGP_INTERNAL_PEER_V4 permit 100
|
||||||
|
!
|
||||||
|
route-map TO_BGP_INTERNAL_PEER_V4 permit 100
|
||||||
|
!
|
||||||
|
route-map FROM_BGP_INTERNAL_PEER_V6 permit 1
|
||||||
|
set ipv6 next-hop prefer-global
|
||||||
|
!
|
||||||
|
route-map FROM_BGP_INTERNAL_PEER_V6 permit 100
|
||||||
|
!
|
||||||
|
route-map TO_BGP_INTERNAL_PEER_V6 permit 100
|
||||||
|
!
|
||||||
|
! end of template: bgpd/templates/general/policies.conf.j2
|
||||||
|
!
|
@ -484,8 +484,9 @@ def parse_host_loopback(dpg, hname):
|
|||||||
lo_intfs = parse_loopback_intf(child)
|
lo_intfs = parse_loopback_intf(child)
|
||||||
return lo_intfs
|
return lo_intfs
|
||||||
|
|
||||||
def parse_cpg(cpg, hname):
|
def parse_cpg(cpg, hname, local_devices=[]):
|
||||||
bgp_sessions = {}
|
bgp_sessions = {}
|
||||||
|
bgp_internal_sessions = {}
|
||||||
myasn = None
|
myasn = None
|
||||||
bgp_peers_with_range = {}
|
bgp_peers_with_range = {}
|
||||||
for child in cpg:
|
for child in cpg:
|
||||||
@ -506,24 +507,47 @@ def parse_cpg(cpg, hname):
|
|||||||
else:
|
else:
|
||||||
keepalive = 60
|
keepalive = 60
|
||||||
nhopself = 1 if session.find(str(QName(ns, "NextHopSelf"))) is not None else 0
|
nhopself = 1 if session.find(str(QName(ns, "NextHopSelf"))) is not None else 0
|
||||||
|
|
||||||
if end_router.lower() == hname.lower():
|
if end_router.lower() == hname.lower():
|
||||||
bgp_sessions[start_peer.lower()] = {
|
if end_router.lower() in local_devices and start_router.lower() in local_devices:
|
||||||
'name': start_router,
|
bgp_internal_sessions[start_peer.lower()] = {
|
||||||
'local_addr': end_peer.lower(),
|
'name': start_router,
|
||||||
'rrclient': rrclient,
|
'local_addr': end_peer.lower(),
|
||||||
'holdtime': holdtime,
|
'rrclient': rrclient,
|
||||||
'keepalive': keepalive,
|
'holdtime': holdtime,
|
||||||
'nhopself': nhopself
|
'keepalive': keepalive,
|
||||||
}
|
'nhopself': nhopself,
|
||||||
|
'admin_status': 'up'
|
||||||
|
}
|
||||||
|
else:
|
||||||
|
bgp_sessions[start_peer.lower()] = {
|
||||||
|
'name': start_router,
|
||||||
|
'local_addr': end_peer.lower(),
|
||||||
|
'rrclient': rrclient,
|
||||||
|
'holdtime': holdtime,
|
||||||
|
'keepalive': keepalive,
|
||||||
|
'nhopself': nhopself
|
||||||
|
}
|
||||||
elif start_router.lower() == hname.lower():
|
elif start_router.lower() == hname.lower():
|
||||||
bgp_sessions[end_peer.lower()] = {
|
if end_router.lower() in local_devices and start_router.lower() in local_devices:
|
||||||
'name': end_router,
|
bgp_internal_sessions[end_peer.lower()] = {
|
||||||
'local_addr': start_peer.lower(),
|
'name': end_router,
|
||||||
'rrclient': rrclient,
|
'local_addr': start_peer.lower(),
|
||||||
'holdtime': holdtime,
|
'rrclient': rrclient,
|
||||||
'keepalive': keepalive,
|
'holdtime': holdtime,
|
||||||
'nhopself': nhopself
|
'keepalive': keepalive,
|
||||||
}
|
'nhopself': nhopself,
|
||||||
|
'admin_status': 'up'
|
||||||
|
}
|
||||||
|
else:
|
||||||
|
bgp_sessions[end_peer.lower()] = {
|
||||||
|
'name': end_router,
|
||||||
|
'local_addr': start_peer.lower(),
|
||||||
|
'rrclient': rrclient,
|
||||||
|
'holdtime': holdtime,
|
||||||
|
'keepalive': keepalive,
|
||||||
|
'nhopself': nhopself
|
||||||
|
}
|
||||||
elif child.tag == str(QName(ns, "Routers")):
|
elif child.tag == str(QName(ns, "Routers")):
|
||||||
for router in child.findall(str(QName(ns1, "BGPRouterDeclaration"))):
|
for router in child.findall(str(QName(ns1, "BGPRouterDeclaration"))):
|
||||||
asn = router.find(str(QName(ns1, "ASN"))).text
|
asn = router.find(str(QName(ns1, "ASN"))).text
|
||||||
@ -550,11 +574,16 @@ def parse_cpg(cpg, hname):
|
|||||||
bgp_session = bgp_sessions[peer]
|
bgp_session = bgp_sessions[peer]
|
||||||
if hostname.lower() == bgp_session['name'].lower():
|
if hostname.lower() == bgp_session['name'].lower():
|
||||||
bgp_session['asn'] = asn
|
bgp_session['asn'] = asn
|
||||||
|
for peer in bgp_internal_sessions:
|
||||||
|
bgp_internal_session = bgp_internal_sessions[peer]
|
||||||
|
if hostname.lower() == bgp_internal_session['name'].lower():
|
||||||
|
bgp_internal_session['asn'] = asn
|
||||||
|
|
||||||
bgp_monitors = { key: bgp_sessions[key] for key in bgp_sessions if 'asn' in bgp_sessions[key] and bgp_sessions[key]['name'] == 'BGPMonitor' }
|
bgp_monitors = { key: bgp_sessions[key] for key in bgp_sessions if 'asn' in bgp_sessions[key] and bgp_sessions[key]['name'] == 'BGPMonitor' }
|
||||||
bgp_sessions = { key: bgp_sessions[key] for key in bgp_sessions if 'asn' in bgp_sessions[key] and int(bgp_sessions[key]['asn']) != 0 }
|
bgp_sessions = { key: bgp_sessions[key] for key in bgp_sessions if 'asn' in bgp_sessions[key] and int(bgp_sessions[key]['asn']) != 0 }
|
||||||
|
bgp_internal_sessions = { key: bgp_internal_sessions[key] for key in bgp_internal_sessions if 'asn' in bgp_internal_sessions[key] and int(bgp_internal_sessions[key]['asn']) != 0 }
|
||||||
|
|
||||||
return bgp_sessions, myasn, bgp_peers_with_range, bgp_monitors
|
return bgp_sessions, bgp_internal_sessions, myasn, bgp_peers_with_range, bgp_monitors
|
||||||
|
|
||||||
|
|
||||||
def parse_meta(meta, hname):
|
def parse_meta(meta, hname):
|
||||||
@ -865,6 +894,7 @@ def parse_xml(filename, platform=None, port_config_file=None, asic_name=None, hw
|
|||||||
hostname = None
|
hostname = None
|
||||||
linkmetas = {}
|
linkmetas = {}
|
||||||
host_lo_intfs = None
|
host_lo_intfs = None
|
||||||
|
local_devices = []
|
||||||
|
|
||||||
# hostname is the asic_name, get the asic_id from the asic_name
|
# hostname is the asic_name, get the asic_id from the asic_name
|
||||||
if asic_name is not None:
|
if asic_name is not None:
|
||||||
@ -887,12 +917,15 @@ def parse_xml(filename, platform=None, port_config_file=None, asic_name=None, hw
|
|||||||
port_alias_map.update(alias_map)
|
port_alias_map.update(alias_map)
|
||||||
port_alias_asic_map.update(alias_asic_map)
|
port_alias_asic_map.update(alias_asic_map)
|
||||||
|
|
||||||
|
# Get the local device node from DeviceMetadata
|
||||||
|
local_devices = parse_asic_meta_get_devices(root)
|
||||||
|
|
||||||
for child in root:
|
for child in root:
|
||||||
if asic_name is None:
|
if asic_name is None:
|
||||||
if child.tag == str(QName(ns, "DpgDec")):
|
if child.tag == str(QName(ns, "DpgDec")):
|
||||||
(intfs, lo_intfs, mvrf, mgmt_intf, vlans, vlan_members, pcs, pc_members, acls, vni) = parse_dpg(child, hostname)
|
(intfs, lo_intfs, mvrf, mgmt_intf, vlans, vlan_members, pcs, pc_members, acls, vni) = parse_dpg(child, hostname)
|
||||||
elif child.tag == str(QName(ns, "CpgDec")):
|
elif child.tag == str(QName(ns, "CpgDec")):
|
||||||
(bgp_sessions, bgp_asn, bgp_peers_with_range, bgp_monitors) = parse_cpg(child, hostname)
|
(bgp_sessions, bgp_internal_sessions, bgp_asn, bgp_peers_with_range, bgp_monitors) = parse_cpg(child, hostname)
|
||||||
elif child.tag == str(QName(ns, "PngDec")):
|
elif child.tag == str(QName(ns, "PngDec")):
|
||||||
(neighbors, devices, console_dev, console_port, mgmt_dev, mgmt_port, port_speed_png, console_ports, mux_cable_ports) = parse_png(child, hostname)
|
(neighbors, devices, console_dev, console_port, mgmt_dev, mgmt_port, port_speed_png, console_ports, mux_cable_ports) = parse_png(child, hostname)
|
||||||
elif child.tag == str(QName(ns, "UngDec")):
|
elif child.tag == str(QName(ns, "UngDec")):
|
||||||
@ -908,8 +941,7 @@ def parse_xml(filename, platform=None, port_config_file=None, asic_name=None, hw
|
|||||||
(intfs, lo_intfs, mvrf, mgmt_intf, vlans, vlan_members, pcs, pc_members, acls, vni) = parse_dpg(child, asic_name)
|
(intfs, lo_intfs, mvrf, mgmt_intf, vlans, vlan_members, pcs, pc_members, acls, vni) = parse_dpg(child, asic_name)
|
||||||
host_lo_intfs = parse_host_loopback(child, hostname)
|
host_lo_intfs = parse_host_loopback(child, hostname)
|
||||||
elif child.tag == str(QName(ns, "CpgDec")):
|
elif child.tag == str(QName(ns, "CpgDec")):
|
||||||
(bgp_sessions, bgp_asn, bgp_peers_with_range, bgp_monitors) = parse_cpg(child, asic_name)
|
(bgp_sessions, bgp_internal_sessions, bgp_asn, bgp_peers_with_range, bgp_monitors) = parse_cpg(child, asic_name, local_devices)
|
||||||
enable_internal_bgp_session(bgp_sessions, filename, asic_name)
|
|
||||||
elif child.tag == str(QName(ns, "PngDec")):
|
elif child.tag == str(QName(ns, "PngDec")):
|
||||||
(neighbors, devices, port_speed_png) = parse_asic_png(child, asic_name, hostname)
|
(neighbors, devices, port_speed_png) = parse_asic_png(child, asic_name, hostname)
|
||||||
elif child.tag == str(QName(ns, "MetadataDeclaration")):
|
elif child.tag == str(QName(ns, "MetadataDeclaration")):
|
||||||
@ -951,6 +983,7 @@ def parse_xml(filename, platform=None, port_config_file=None, asic_name=None, hw
|
|||||||
results['BGP_NEIGHBOR'] = bgp_sessions
|
results['BGP_NEIGHBOR'] = bgp_sessions
|
||||||
results['BGP_MONITORS'] = bgp_monitors
|
results['BGP_MONITORS'] = bgp_monitors
|
||||||
results['BGP_PEER_RANGE'] = bgp_peers_with_range
|
results['BGP_PEER_RANGE'] = bgp_peers_with_range
|
||||||
|
results['BGP_INTERNAL_NEIGHBOR'] = bgp_internal_sessions
|
||||||
if mgmt_routes:
|
if mgmt_routes:
|
||||||
# TODO: differentiate v4 and v6
|
# TODO: differentiate v4 and v6
|
||||||
next(iter(mgmt_intf.values()))['forced_mgmt_routes'] = mgmt_routes
|
next(iter(mgmt_intf.values()))['forced_mgmt_routes'] = mgmt_routes
|
||||||
@ -1229,6 +1262,18 @@ def parse_asic_sub_role(filename, asic_name):
|
|||||||
sub_role = parse_asic_meta(child, asic_name)
|
sub_role = parse_asic_meta(child, asic_name)
|
||||||
return sub_role
|
return sub_role
|
||||||
|
|
||||||
|
def parse_asic_meta_get_devices(root):
|
||||||
|
local_devices = []
|
||||||
|
|
||||||
|
for child in root:
|
||||||
|
if child.tag == str(QName(ns, "MetadataDeclaration")):
|
||||||
|
device_metas = child.find(str(QName(ns, "Devices")))
|
||||||
|
for device in device_metas.findall(str(QName(ns1, "DeviceMetadata"))):
|
||||||
|
name = device.find(str(QName(ns1, "Name"))).text.lower()
|
||||||
|
local_devices.append(name)
|
||||||
|
|
||||||
|
return local_devices
|
||||||
|
|
||||||
port_alias_map = {}
|
port_alias_map = {}
|
||||||
port_alias_asic_map = {}
|
port_alias_asic_map = {}
|
||||||
|
|
||||||
|
@ -226,16 +226,21 @@ class TestMultiNpuCfgGen(TestCase):
|
|||||||
output = json.loads(self.run_script(argument))
|
output = json.loads(self.run_script(argument))
|
||||||
self.assertDictEqual(output, \
|
self.assertDictEqual(output, \
|
||||||
{'10.0.0.1': {'rrclient': 0, 'name': '01T2', 'local_addr': '10.0.0.0', 'nhopself': 0, 'holdtime': '10', 'asn': '65200', 'keepalive': '3'},
|
{'10.0.0.1': {'rrclient': 0, 'name': '01T2', 'local_addr': '10.0.0.0', 'nhopself': 0, 'holdtime': '10', 'asn': '65200', 'keepalive': '3'},
|
||||||
'10.1.0.0': {'rrclient': 0, 'name': 'ASIC2', 'local_addr': '10.1.0.1', 'nhopself': 0, 'holdtime': '0', 'asn': '65100', 'keepalive': '0', 'admin_status': 'up'},
|
'fc00::2': {'rrclient': 0, 'name': '01T2', 'local_addr': 'fc00::1', 'nhopself': 0, 'holdtime': '10', 'asn': '65200', 'keepalive': '3'}})
|
||||||
'fc00::2': {'rrclient': 0, 'name': '01T2', 'local_addr': 'fc00::1', 'nhopself': 0, 'holdtime': '10', 'asn': '65200', 'keepalive': '3'},
|
|
||||||
'10.1.0.2': {'rrclient': 0, 'name': 'ASIC3', 'local_addr': '10.1.0.3', 'nhopself': 0, 'holdtime': '0', 'asn': '65100', 'keepalive': '0', 'admin_status': 'up'}})
|
|
||||||
|
|
||||||
def test_backend_asic_bgp_neighbor(self):
|
def test_frontend_asic_bgp_neighbor(self):
|
||||||
argument = "-m {} -p {} -n asic3 --var-json \"BGP_NEIGHBOR\"".format(self.sample_graph, self.port_config[3])
|
argument = "-m {} -p {} -n asic0 --var-json \"BGP_INTERNAL_NEIGHBOR\"".format(self.sample_graph, self.port_config[3])
|
||||||
output = json.loads(self.run_script(argument))
|
output = json.loads(self.run_script(argument))
|
||||||
self.assertDictEqual(output, \
|
self.assertDictEqual(output, \
|
||||||
{'10.1.0.7': {'rrclient': 0, 'name': 'ASIC1', 'local_addr': '10.1.0.6', 'nhopself': 0, 'holdtime': '0', 'asn': '65100', 'keepalive': '0', 'admin_status': 'up'},
|
{'10.1.0.0': {'rrclient': 0, 'name': 'ASIC2', 'local_addr': '10.1.0.1', 'nhopself': 0, 'admin_status': 'up', 'holdtime': '0', 'asn': '65100', 'keepalive': '0'},
|
||||||
'10.1.0.3': {'rrclient': 0, 'name': 'ASIC0', 'local_addr': '10.1.0.2', 'nhopself': 0, 'holdtime': '0', 'asn': '65100', 'keepalive': '0', 'admin_status': 'up'}})
|
'10.1.0.2': {'rrclient': 0, 'name': 'ASIC3', 'local_addr': '10.1.0.3', 'nhopself': 0, 'admin_status': 'up', 'holdtime': '0', 'asn': '65100', 'keepalive': '0'}})
|
||||||
|
|
||||||
|
def test_backend_asic_bgp_neighbor(self):
|
||||||
|
argument = "-m {} -p {} -n asic3 --var-json \"BGP_INTERNAL_NEIGHBOR\"".format(self.sample_graph, self.port_config[3])
|
||||||
|
output = json.loads(self.run_script(argument))
|
||||||
|
self.assertDictEqual(output, \
|
||||||
|
{'10.1.0.7': {'rrclient': 0, 'name': 'ASIC1', 'local_addr': '10.1.0.6', 'nhopself': 0, 'admin_status': 'up', 'holdtime': '0', 'asn': '65100', 'keepalive': '0'},
|
||||||
|
'10.1.0.3': {'rrclient': 0, 'name': 'ASIC0', 'local_addr': '10.1.0.2', 'nhopself': 0, 'admin_status': 'up', 'holdtime': '0', 'asn': '65100', 'keepalive': '0'}})
|
||||||
|
|
||||||
def test_device_asic_metadata(self):
|
def test_device_asic_metadata(self):
|
||||||
argument = "-m {} --var-json DEVICE_METADATA".format(self.sample_graph)
|
argument = "-m {} --var-json DEVICE_METADATA".format(self.sample_graph)
|
||||||
|
Loading…
Reference in New Issue
Block a user