File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed
Expand file tree Collapse file tree 2 files changed +30
-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 ConsulServiceHealth (action .ConsulBaseAction ):
6+ def run (self , service , tag = None ):
7+ index , nodes = self .consul .health .service (service , tag = tag )
8+ s = defaultdict (dict )
9+ for node in nodes :
10+ for check in node .get ('Checks' ):
11+ try :
12+ s [check .get ('Node' )][check .get ('Status' )].append (check .get ('CheckID' ))
13+ except KeyError :
14+ s [check .get ('Node' )][check .get ('Status' )] = []
15+ s [check .get ('Node' )][check .get ('Status' )].append (check .get ('CheckID' ))
16+ return s
Original file line number Diff line number Diff line change 1+ name : health_service
2+ runner_type : run-python
3+ description : " Query health status of a service in consul"
4+ enabled : true
5+ entry_point : " health_service.py"
6+ parameters :
7+ service :
8+ type : string
9+ description : " Service to query in Consul"
10+ required : true
11+ tag :
12+ type : string
13+ description : " Optional tags to query"
14+ required : false
You can’t perform that action at this time.
0 commit comments