File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed
Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change 1+ #!/usr/bin/python3
2+ import json
3+ import subprocess
4+ import sys
5+
6+ gluster_volume_names = []
7+ gstatus_output = subprocess .check_output ('python /root/gstatus/gstatus.py -a -o json ' , shell = True ).decode ()
8+ date , time , json_part = gstatus_output .split (maxsplit = 2 )
9+ gluster_info = json .loads (json_part )
10+ volume_list = gluster_info ["volume_summary" ]
11+
12+ nargs = len (sys .argv )
13+
14+ if nargs == 1 :
15+ for volume in volume_list :
16+ gluster_volume_names .append ({"{#VOLUME_NAME}" : volume ["volume_name" ]})
17+ print (json .dumps ({'data' : gluster_volume_names }))
18+
19+ elif nargs == 2 :
20+ print (gluster_info [sys .argv [1 ]])
21+ elif nargs == 3 :
22+ for volume in volume_list :
23+ if volume .get ('volume_name' ) and sys .argv [2 ] == volume ["volume_name" ]:
24+ print (volume [sys .argv [1 ]])
25+ break
26+ else :
27+ if sys .argv [1 ] == "state" :
28+ print ('down' )
29+ else :
30+ print ()
31+
32+ else :
33+ print ('Wrong arguments' )
34+
You can’t perform that action at this time.
0 commit comments