[multi-ASIC] util changes with the BGP_INTERNAL_NEIGHBOR table. (#5760)

- Why I did it
Update the routine is_bgp_session_internal() by checking the BGP_INTERNAL_NEIGHBOR table.
Additionally to address the review comment #5520 (comment)
Add timer settings as will in the internal session templates and keep it minimal as these sessions which will always be up.
Updates to the internal tests data + add all of it to template tests.

- How I did it
Updated the APIs and the template files.

- How to verify it
Verified the internal BGP sessions are displayed correctly with show commands with this API is_bgp_session_internal()
This commit is contained in:
judyjoseph 2020-11-09 11:10:10 -08:00 committed by GitHub
parent e0fdf45ad0
commit c972052594
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 21 additions and 21 deletions

View File

@ -3,6 +3,7 @@
! !
neighbor {{ neighbor_addr }} remote-as {{ bgp_session['asn'] }} neighbor {{ neighbor_addr }} remote-as {{ bgp_session['asn'] }}
neighbor {{ neighbor_addr }} description {{ bgp_session['name'] }} neighbor {{ neighbor_addr }} description {{ bgp_session['name'] }}
neighbor {{ neighbor_addr }} timers 3 10
! !
{% if neighbor_addr | ipv4 %} {% if neighbor_addr | ipv4 %}
address-family ipv4 address-family ipv4

View File

@ -3,8 +3,7 @@
! !
neighbor 10.10.10.10 remote-as 555 neighbor 10.10.10.10 remote-as 555
neighbor 10.10.10.10 description remote_peer neighbor 10.10.10.10 description remote_peer
neighbor 10.10.10.10 timers 5 30 neighbor 10.10.10.10 timers 3 10
neighbor 10.10.10.10 shutdown
address-family ipv4 address-family ipv4
neighbor 10.10.10.10 peer-group INTERNAL_PEER_V4 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-map FROM_BGP_INTERNAL_PEER_V4 in

View File

@ -3,8 +3,7 @@
! !
neighbor fc::10 remote-as 555 neighbor fc::10 remote-as 555
neighbor fc::10 description remote_peer neighbor fc::10 description remote_peer
neighbor fc::10 timers 5 30 neighbor fc::10 timers 3 10
neighbor fc::10 shutdown
address-family ipv6 address-family ipv6
neighbor fc::10 peer-group INTERNAL_PEER_V6 neighbor fc::10 peer-group INTERNAL_PEER_V6
neighbor fc::10 route-map FROM_BGP_INTERNAL_PEER_V6 in neighbor fc::10 route-map FROM_BGP_INTERNAL_PEER_V6 in

View File

@ -3,8 +3,7 @@
! !
neighbor 10.10.10.10 remote-as 555 neighbor 10.10.10.10 remote-as 555
neighbor 10.10.10.10 description remote_peer neighbor 10.10.10.10 description remote_peer
neighbor 10.10.10.10 timers 5 30 neighbor 10.10.10.10 timers 3 10
neighbor 10.10.10.10 shutdown
address-family ipv4 address-family ipv4
neighbor 10.10.10.10 peer-group INTERNAL_PEER_V4 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

View File

@ -3,8 +3,7 @@
! !
neighbor fc::10 remote-as 555 neighbor fc::10 remote-as 555
neighbor fc::10 description remote_peer neighbor fc::10 description remote_peer
neighbor fc::10 timers 5 30 neighbor fc::10 timers 3 10
neighbor fc::10 shutdown
address-family ipv6 address-family ipv6
neighbor fc::10 peer-group INTERNAL_PEER_V6 neighbor fc::10 peer-group INTERNAL_PEER_V6
neighbor fc::10 next-hop-self force neighbor fc::10 next-hop-self force

View File

@ -105,6 +105,18 @@ def test_general_instance():
test_data = load_tests("general", "instance.conf") test_data = load_tests("general", "instance.conf")
run_tests("general_instance", *test_data) run_tests("general_instance", *test_data)
def test_internal_policies():
test_data = load_tests("internal", "policies.conf")
run_tests("internal_policies", *test_data)
def test_internal_pg():
test_data = load_tests("internal", "peer-group.conf")
run_tests("internal_pg", *test_data)
def test_internal_instance():
test_data = load_tests("internal", "instance.conf")
run_tests("internal_instance", *test_data)
def test_dynamic_policies(): def test_dynamic_policies():
test_data = load_tests("dynamic", "policies.conf") test_data = load_tests("dynamic", "policies.conf")
run_tests("dynamic_policies", *test_data) run_tests("dynamic_policies", *test_data)

View File

@ -21,6 +21,7 @@ INTERNAL_PORT = 'Int'
PORT_CHANNEL_CFG_DB_TABLE = 'PORTCHANNEL' PORT_CHANNEL_CFG_DB_TABLE = 'PORTCHANNEL'
PORT_CFG_DB_TABLE = 'PORT' PORT_CFG_DB_TABLE = 'PORT'
BGP_NEIGH_CFG_DB_TABLE = 'BGP_NEIGHBOR' BGP_NEIGH_CFG_DB_TABLE = 'BGP_NEIGHBOR'
BGP_INTERNAL_NEIGH_CFG_DB_TABLE = 'BGP_INTERNAL_NEIGHBOR'
NEIGH_DEVICE_METADATA_CFG_DB_TABLE = 'DEVICE_NEIGHBOR_METADATA' NEIGH_DEVICE_METADATA_CFG_DB_TABLE = 'DEVICE_NEIGHBOR_METADATA'
DEFAULT_NAMESPACE = '' DEFAULT_NAMESPACE = ''
PORT_ROLE = 'role' PORT_ROLE = 'role'
@ -359,20 +360,10 @@ def is_bgp_session_internal(bgp_neigh_ip, namespace=None):
for ns in ns_list: for ns in ns_list:
config_db = connect_config_db_for_ns(ns) config_db = connect_config_db_for_ns(ns)
bgp_sessions = config_db.get_table(BGP_NEIGH_CFG_DB_TABLE) bgp_sessions = config_db.get_table(BGP_INTERNAL_NEIGH_CFG_DB_TABLE)
if bgp_neigh_ip not in bgp_sessions: if bgp_neigh_ip in bgp_sessions:
continue
bgp_neigh_name = bgp_sessions[bgp_neigh_ip]['name']
neighbor_metadata = config_db.get_table(
NEIGH_DEVICE_METADATA_CFG_DB_TABLE)
if ((neighbor_metadata) and
(neighbor_metadata[bgp_neigh_name]['type'].lower() ==
ASIC_NAME_PREFIX)):
return True return True
else:
return False
return False return False
def get_front_end_namespaces(): def get_front_end_namespaces():