tools: frr-reload combine "'router bgp' and line" checks

Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>

We had multiple places checking for

    if ctx_keys[0].startswith('router bgp') and line

Combine these into a single check
This commit is contained in:
Daniel Walton 2017-11-10 17:47:13 +00:00
parent c755f5c434
commit 028bcc883f

View File

@ -623,8 +623,10 @@ def ignore_delete_re_add_lines(lines_to_add, lines_to_del):
for (ctx_keys, line) in lines_to_del:
deleted = False
if ctx_keys[0].startswith('router bgp') and line and line.startswith('neighbor '):
"""
if ctx_keys[0].startswith('router bgp') and line:
if line.startswith('neighbor '):
'''
BGP changed how it displays swpX peers that are part of peer-group. Older
versions of frr would display these on separate lines:
neighbor swp1 interface
@ -641,7 +643,7 @@ def ignore_delete_re_add_lines(lines_to_add, lines_to_del):
neighbor swp1 peer-group FOO
If so then chop the del line and the corresponding add lines
"""
'''
re_swpx_int_peergroup = re.search('neighbor (\S+) interface peer-group (\S+)', line)
re_swpx_int_v6only_peergroup = re.search('neighbor (\S+) interface v6only peer-group (\S+)', line)
@ -682,7 +684,7 @@ def ignore_delete_re_add_lines(lines_to_add, lines_to_del):
lines_to_add_to_del.append((ctx_keys, swpx_interface))
lines_to_add_to_del.append((tmp_ctx_keys, swpx_peergroup))
"""
'''
In 3.0.1 we changed how we display neighbor interface command. Older
versions of frr would display the following:
neighbor swp1 interface
@ -704,7 +706,7 @@ def ignore_delete_re_add_lines(lines_to_add, lines_to_del):
neighbor swp1 capability extended-nexthop
If so then chop the del line and the corresponding add lines
"""
'''
re_swpx_int_remoteas = re.search('neighbor (\S+) interface remote-as (\S+)', line)
re_swpx_int_v6only_remoteas = re.search('neighbor (\S+) interface v6only remote-as (\S+)', line)
@ -741,7 +743,7 @@ def ignore_delete_re_add_lines(lines_to_add, lines_to_del):
reload to unnecessarily unapply this option to only apply it back
again, causing unnecessary session resets. Handle this.
'''
if ctx_keys[0].startswith('router bgp') and line and 'multipath-relax' in line:
if 'multipath-relax' in line:
re_asrelax_new = re.search('^bgp\s+bestpath\s+as-path\s+multipath-relax$', line)
old_asrelax_cmd = 'bgp bestpath as-path multipath-relax no-as-set'
found_asrelax_old = line_exist(lines_to_add, ctx_keys, old_asrelax_cmd)
@ -757,7 +759,7 @@ def ignore_delete_re_add_lines(lines_to_add, lines_to_del):
avoid installing all routes in the RIB the second the 'no table-map'
is issued.
'''
if ctx_keys[0].startswith('router bgp') and line and line.startswith('table-map'):
if line.startswith('table-map'):
found_table_map = line_exist(lines_to_add, ctx_keys, 'table-map', False)
if found_table_map: