Skip to content

Commit 86e3aea

Browse files
committed
Address new comments
1 parent 4bbc076 commit 86e3aea

File tree

2 files changed

+31
-31
lines changed

2 files changed

+31
-31
lines changed

scripts/sysreadyshow

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,26 @@ class SysreadyShow(object):
3838
self.db = SonicV2Connector(host="127.0.0.1")
3939
self.db.connect(self.db.STATE_DB)
4040

41-
def show(self, cmd):
41+
def show(self, detailed_info):
4242
keys = self.db.keys(self.db.STATE_DB, SERVICE_STATUS_TABLE + '*')
4343
if not keys:
4444
print('No system ready status data available - system-health service might be down\n')
4545
return
46-
47-
if cmd == "alldetail":
48-
header_info = header_detail
46+
47+
sysready_state = self.db.get(self.db.STATE_DB, SYSREADY_TABLE, "Status")
48+
if sysready_state == "UP":
49+
print("System is ready\n")
4950
else:
51+
print("System is not ready - one or more services are not up\n")
52+
53+
#When brief option is specified, return here.
54+
if detailed_info == False:
55+
return
56+
57+
if detailed_info is None:
5058
header_info = header
59+
else:
60+
header_info = header_detail
5161

5262
table = []
5363
for key in natsorted(keys):
@@ -66,21 +76,11 @@ class SysreadyShow(object):
6676
except ValueError as e:
6777
print('Error in data_dict')
6878

69-
if cmd == "alldetail":
70-
table.append((name, service_status, app_ready_status, fail_reason, update_time))
71-
else:
79+
if detailed_info is None:
7280
table.append((name, service_status, app_ready_status, fail_reason))
81+
else:
82+
table.append((name, service_status, app_ready_status, fail_reason, update_time))
7383

74-
sysready_state = self.db.get(self.db.STATE_DB, SYSREADY_TABLE, "Status")
75-
if sysready_state == "UP":
76-
print("System is ready\n")
77-
else:
78-
print("System is not ready - one or more services are not up\n")
79-
80-
81-
if cmd == "allbrief":
82-
return
83-
8484

8585
if table:
8686
print(tabulate(table, header_info, tablefmt='simple', stralign='left'))
@@ -93,24 +93,24 @@ def main():
9393
formatter_class=argparse.RawTextHelpFormatter,
9494
epilog="""
9595
Examples:
96-
sysreadyshow --all
97-
sysreadyshow --allbrief
98-
sysreadyshow --alldetail
96+
sysreadyshow
97+
sysreadyshow --brief
98+
sysreadyshow --detail
9999
""")
100100

101-
parser.add_argument('-a', '--all', action='store_true', help='all service status', default=True)
102-
parser.add_argument('-b', '--allbrief', action='store_true', help='all service status brief', default=False)
103-
parser.add_argument('-d', '--alldetail', action='store_true', help='all service status detail', default=False)
101+
parser.add_argument('-b', '--brief', action='store_true', help='brief system ready status', default=False)
102+
parser.add_argument('-d', '--detail', action='store_true', help='detailed system ready status', default=False)
104103
args = parser.parse_args()
105104

106105
try:
107106
sysready = SysreadyShow()
108-
if args.alldetail:
109-
sysready.show("alldetail")
110-
elif args.allbrief:
111-
sysready.show("allbrief")
107+
if args.detail:
108+
detailed_info = True
109+
elif args.brief:
110+
detailed_info = False
112111
else:
113-
sysready.show("all")
112+
detailed_info = None
113+
sysready.show(detailed_info)
114114
except Exception as e:
115115
print(str(e), file=sys.stderr)
116116
sys.exit(1)

show/system_health.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ def sysready_status(ctx):
207207

208208
if ctx.invoked_subcommand is None:
209209
try:
210-
cmd = "sysreadyshow --all"
210+
cmd = "sysreadyshow"
211211
clicommon.run_command(cmd, display_cmd=False)
212212
except Exception as e:
213213
click.echo("Exception: {}".format(str(e)))
@@ -216,7 +216,7 @@ def sysready_status(ctx):
216216
@sysready_status.command('brief')
217217
def sysready_status_brief():
218218
try:
219-
cmd = "sysreadyshow --allbrief"
219+
cmd = "sysreadyshow --brief"
220220
clicommon.run_command(cmd, display_cmd=False)
221221
except Exception as e:
222222
click.echo("Exception: {}".format(str(e)))
@@ -225,7 +225,7 @@ def sysready_status_brief():
225225
@sysready_status.command('detail')
226226
def sysready_status_detail():
227227
try:
228-
cmd = "sysreadyshow --alldetail"
228+
cmd = "sysreadyshow --detail"
229229
clicommon.run_command(cmd, display_cmd=False)
230230
except Exception as e:
231231
click.echo("Exception: {}".format(str(e)))

0 commit comments

Comments
 (0)