This repository was archived by the owner on Apr 15, 2024. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1143,6 +1143,27 @@ def callback(response):
11431143 callback ,
11441144 '/v1/health/state/%s' % name , params = params )
11451145
1146+ def node (self , node , index = None ):
1147+ """
1148+ Returns a tuple of (*index*, *checks*)
1149+
1150+ *index* is the current Consul index, suitable for making subsequent
1151+ calls to wait for changes since this query was last run.
1152+
1153+ *nodes* are the nodes providing the given service.
1154+ """
1155+ params = {}
1156+ if index :
1157+ params ['index' ] = index
1158+
1159+ def callback (response ):
1160+ data = json .loads (response .body )
1161+ return response .headers ['X-Consul-Index' ], data
1162+
1163+ return self .agent .http .get (
1164+ callback ,
1165+ '/v1/health/node/%s' % node , params = params )
1166+
11461167 class Session (object ):
11471168 def __init__ (self , agent ):
11481169 self .agent = agent
Original file line number Diff line number Diff line change @@ -560,6 +560,13 @@ def test_health_state(self, consul_port):
560560 index , nodes = c .health .state ('any' )
561561 assert [node ['ServiceID' ] for node in nodes ] == ['' ]
562562
563+ def test_health_node (self , consul_port ):
564+ c = consul .Consul (port = consul_port )
565+ # grab local node name
566+ node = c .agent .self ()['Config' ]['NodeName' ]
567+ index , checks = c .health .node (node )
568+ assert node in [check ["Node" ] for check in checks ]
569+
563570 def test_session (self , consul_port ):
564571 c = consul .Consul (port = consul_port )
565572
You can’t perform that action at this time.
0 commit comments