@@ -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 )
0 commit comments