File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed
Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change 1+ from lib import action
2+ from collections import defaultdict
3+
4+
5+ class ConsulCheckHealth (action .ConsulBaseAction ):
6+ def run (self , service ):
7+ index , nodes = self .consul .health .checks (service = service )
8+ s = defaultdict (dict )
9+ for node in nodes :
10+ try :
11+ s [node .get ('CheckID' )][node .get ('Status' )].append (node .get ('Node' ))
12+ except KeyError :
13+ s [node .get ('CheckID' )][node .get ('Status' )] = []
14+ s [node .get ('CheckID' )][node .get ('Status' )].append (node .get ('Node' ))
15+ return s
Original file line number Diff line number Diff line change 1+ name : health_check
2+ runner_type : run-python
3+ description : " Query health status of a check in consul"
4+ enabled : true
5+ entry_point : " health_check.py"
6+ parameters :
7+ service :
8+ type : string
9+ description : " Service to query in Consul"
10+ required : true
11+
You can’t perform that action at this time.
0 commit comments