@@ -38,16 +38,26 @@ class SysreadyShow(object):
38
38
self .db = SonicV2Connector (host = "127.0.0.1" )
39
39
self .db .connect (self .db .STATE_DB )
40
40
41
- def show (self , cmd ):
41
+ def show (self , detailed_info ):
42
42
keys = self .db .keys (self .db .STATE_DB , SERVICE_STATUS_TABLE + '*' )
43
43
if not keys :
44
44
print ('No system ready status data available - system-health service might be down\n ' )
45
45
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 " )
49
50
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 :
50
58
header_info = header
59
+ else :
60
+ header_info = header_detail
51
61
52
62
table = []
53
63
for key in natsorted (keys ):
@@ -66,21 +76,11 @@ class SysreadyShow(object):
66
76
except ValueError as e :
67
77
print ('Error in data_dict' )
68
78
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 :
72
80
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 ))
73
83
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
-
84
84
85
85
if table :
86
86
print (tabulate (table , header_info , tablefmt = 'simple' , stralign = 'left' ))
@@ -93,24 +93,24 @@ def main():
93
93
formatter_class = argparse .RawTextHelpFormatter ,
94
94
epilog = """
95
95
Examples:
96
- sysreadyshow --all
97
- sysreadyshow --allbrief
98
- sysreadyshow --alldetail
96
+ sysreadyshow
97
+ sysreadyshow --brief
98
+ sysreadyshow --detail
99
99
""" )
100
100
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 )
104
103
args = parser .parse_args ()
105
104
106
105
try :
107
106
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
112
111
else :
113
- sysready .show ("all" )
112
+ detailed_info = None
113
+ sysready .show (detailed_info )
114
114
except Exception as e :
115
115
print (str (e ), file = sys .stderr )
116
116
sys .exit (1 )
0 commit comments