From 49d9087ced6f75d4e4c2c551b3d39c11bbd5fefd Mon Sep 17 00:00:00 2001 From: Abhishek Dosi Date: Mon, 5 Feb 2024 22:18:45 +0000 Subject: [PATCH] Added change to not return error for Sonic t2/spine-router role when config bgp shut/startup command given for BGP Neighbor if the given neighbor are not present. This is done because for T2 BGP neighbors are present across different LC's so it's possible when command is executed that neighbor might not be present on that LC Signed-off-by: Abhishek Dosi --- config/main.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/config/main.py b/config/main.py index e3cc093d1..27621683b 100644 --- a/config/main.py +++ b/config/main.py @@ -3619,8 +3619,12 @@ def neighbor(ipaddr_or_hostname, verbose): if _change_bgp_session_status(config_db, ipaddr_or_hostname, 'down', verbose): found_neighbor = True + device_metadata = config_db.get_entry('DEVICE_METADATA', 'localhost') if not found_neighbor: - click.get_current_context().fail("Could not locate neighbor '{}'".format(ipaddr_or_hostname)) + if device_metadata['type'] == 'SpineRouter': + click.echo("Could not locate neighbor '{}'".format(ipaddr_or_hostname)) + else: + click.get_current_context().fail("Could not locate neighbor '{}'".format(ipaddr_or_hostname)) @bgp.group(cls=clicommon.AbbreviationGroup) def startup(): @@ -3674,8 +3678,12 @@ def neighbor(ipaddr_or_hostname, verbose): if _change_bgp_session_status(config_db, ipaddr_or_hostname, 'up', verbose): found_neighbor = True + device_metadata = config_db.get_entry('DEVICE_METADATA', 'localhost') if not found_neighbor: - click.get_current_context().fail("Could not locate neighbor '{}'".format(ipaddr_or_hostname)) + if device_metadata['type'] == 'SpineRouter': + click.echo("Could not locate neighbor '{}'".format(ipaddr_or_hostname)) + else: + click.get_current_context().fail("Could not locate neighbor '{}'".format(ipaddr_or_hostname)) # # 'remove' subgroup ('config bgp remove ...')