Skip to content

Commit

Permalink
[show][muxcable] fix show mux hwmode muxdirection RC (#2812)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
zjswhhh authored and yxieca committed May 4, 2023
1 parent 6b5bf99 commit 2e9c99e
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions show/muxcable.py
Original file line number Diff line number Diff line change
Expand Up @@ -1370,13 +1370,14 @@ def muxdirection(db, port, json_output):
headers = ['Port', 'Direction', 'Presence']
click.echo(tabulate(body, headers=headers))

return rc
rc_exit = EXIT_SUCCESS if rc==0 else EXIT_FAIL
sys.exit(rc_exit)

else:

logical_port_list = platform_sfputil_helper.get_logical_list()

rc_exit = True
rc_exit = EXIT_SUCCESS
body = []
active_active = False
if json_output:
Expand Down Expand Up @@ -1425,8 +1426,9 @@ def muxdirection(db, port, json_output):
active_active = True
else:
rc = create_active_standby_mux_direction_result(body, port, db)
if rc != 0:
rc_exit = False

if rc != 0:
rc_exit = EXIT_FAIL



Expand All @@ -1440,8 +1442,7 @@ def muxdirection(db, port, json_output):
headers = ['Port', 'Direction', 'Presence']
click.echo(tabulate(body, headers=headers))

if rc_exit == False:
sys.exit(EXIT_FAIL)
sys.exit(rc_exit)


@hwmode.command()
Expand Down Expand Up @@ -2116,7 +2117,7 @@ def get_grpc_cached_version_mux_direction_per_port(db, port):
mux_info_dict = {}
mux_info_full_dict = {}
trans_info_full_dict = {}
mux_info_dict["rc"] = False
mux_info_dict["rc"] = 1

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

Expand Down Expand Up @@ -2158,7 +2159,7 @@ def get_grpc_cached_version_mux_direction_per_port(db, port):

mux_info_dict["presence"] = presence

mux_info_dict["rc"] = True
mux_info_dict["rc"] = 0

return mux_info_dict

Expand Down Expand Up @@ -2198,14 +2199,15 @@ def muxdirection(db, port, json_output):
rc = create_active_active_mux_direction_result(body, port, db)
click.echo(tabulate(body, headers=headers))

return rc
rc_exit = EXIT_SUCCESS if rc==0 else EXIT_FAIL
sys.exit(rc_exit)

else:


logical_port_list = platform_sfputil_helper.get_logical_list()

rc_exit = True
rc_exit = EXIT_SUCCESS
body = []
if json_output:
result = {}
Expand Down Expand Up @@ -2242,8 +2244,8 @@ def muxdirection(db, port, json_output):
else:
rc = create_active_active_mux_direction_result(body, port, db)

if rc != True:
rc_exit = False
if rc != 0:
rc_exit = EXIT_FAIL

if json_output:
click.echo("{}".format(json.dumps(result, indent=4)))
Expand All @@ -2252,7 +2254,6 @@ def muxdirection(db, port, json_output):

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

if rc_exit == False:
sys.exit(EXIT_FAIL)
sys.exit(rc_exit)


0 comments on commit 2e9c99e

Please sign in to comment.