Skip to content

Commit b38fcfd

Browse files
authored
[show][muxcable] fix show mux hwmode muxdirection RC (sonic-net#2812)
What I did show mux hwmode muxdirection always has rc==1. Fixed the issue below: get_grpc_cached_version_mux_direction_per_port has reverted TRUE/FALSE return value compared to get_hwmode_mux_direction_port. The former is used to get results for active-active ports, the latter is used to get results for active-standby ports. Use sys.exit() instead of return rc. CLI rc is different from function return value. Fixed show mux grpc muxdirection as well. sign-off: Jing Zhang How to verify it Tested on DUTs to verify rc. Run commands for single port and all ports, with and without --json. Passed all UTs.
1 parent 7e24463 commit b38fcfd

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

show/muxcable.py

+15-14
Original file line numberDiff line numberDiff line change
@@ -1394,13 +1394,14 @@ def muxdirection(db, port, json_output):
13941394
headers = ['Port', 'Direction', 'Presence']
13951395
click.echo(tabulate(body, headers=headers))
13961396

1397-
return rc
1397+
rc_exit = EXIT_SUCCESS if rc==0 else EXIT_FAIL
1398+
sys.exit(rc_exit)
13981399

13991400
else:
14001401

14011402
logical_port_list = platform_sfputil_helper.get_logical_list()
14021403

1403-
rc_exit = True
1404+
rc_exit = EXIT_SUCCESS
14041405
body = []
14051406
active_active = False
14061407
if json_output:
@@ -1449,8 +1450,9 @@ def muxdirection(db, port, json_output):
14491450
active_active = True
14501451
else:
14511452
rc = create_active_standby_mux_direction_result(body, port, db)
1452-
if rc != 0:
1453-
rc_exit = False
1453+
1454+
if rc != 0:
1455+
rc_exit = EXIT_FAIL
14541456

14551457

14561458

@@ -1464,8 +1466,7 @@ def muxdirection(db, port, json_output):
14641466
headers = ['Port', 'Direction', 'Presence']
14651467
click.echo(tabulate(body, headers=headers))
14661468

1467-
if rc_exit == False:
1468-
sys.exit(EXIT_FAIL)
1469+
sys.exit(rc_exit)
14691470

14701471

14711472
@hwmode.command()
@@ -2140,7 +2141,7 @@ def get_grpc_cached_version_mux_direction_per_port(db, port):
21402141
mux_info_dict = {}
21412142
mux_info_full_dict = {}
21422143
trans_info_full_dict = {}
2143-
mux_info_dict["rc"] = False
2144+
mux_info_dict["rc"] = 1
21442145

21452146
# Getting all front asic namespace and correspding config and state DB connector
21462147

@@ -2182,7 +2183,7 @@ def get_grpc_cached_version_mux_direction_per_port(db, port):
21822183

21832184
mux_info_dict["presence"] = presence
21842185

2185-
mux_info_dict["rc"] = True
2186+
mux_info_dict["rc"] = 0
21862187

21872188
return mux_info_dict
21882189

@@ -2222,14 +2223,15 @@ def muxdirection(db, port, json_output):
22222223
rc = create_active_active_mux_direction_result(body, port, db)
22232224
click.echo(tabulate(body, headers=headers))
22242225

2225-
return rc
2226+
rc_exit = EXIT_SUCCESS if rc==0 else EXIT_FAIL
2227+
sys.exit(rc_exit)
22262228

22272229
else:
22282230

22292231

22302232
logical_port_list = platform_sfputil_helper.get_logical_list()
22312233

2232-
rc_exit = True
2234+
rc_exit = EXIT_SUCCESS
22332235
body = []
22342236
if json_output:
22352237
result = {}
@@ -2266,8 +2268,8 @@ def muxdirection(db, port, json_output):
22662268
else:
22672269
rc = create_active_active_mux_direction_result(body, port, db)
22682270

2269-
if rc != True:
2270-
rc_exit = False
2271+
if rc != 0:
2272+
rc_exit = EXIT_FAIL
22712273

22722274
if json_output:
22732275
click.echo("{}".format(json.dumps(result, indent=4)))
@@ -2276,8 +2278,7 @@ def muxdirection(db, port, json_output):
22762278

22772279
click.echo(tabulate(body, headers=headers))
22782280

2279-
if rc_exit == False:
2280-
sys.exit(EXIT_FAIL)
2281+
sys.exit(rc_exit)
22812282

22822283
@muxcable.command()
22832284
@click.argument('port', metavar='<port_name>', required=True, default=None)

0 commit comments

Comments
 (0)