Skip to content
This repository was archived by the owner on Apr 15, 2024. It is now read-only.

Commit c9a97d2

Browse files
committed
Add node_meta to
1 parent 2a43a6a commit c9a97d2

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

consul/base.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1258,7 +1258,6 @@ def nodes(
12581258
for nodemeta_name, nodemeta_value in node_meta.items():
12591259
params.append(('node-meta', '{0}:{1}'.
12601260
format(nodemeta_name, nodemeta_value)))
1261-
12621261
return self.agent.http.get(
12631262
CB.json(index=True), '/v1/catalog/nodes', params=params)
12641263

@@ -1322,7 +1321,6 @@ def services(self,
13221321
for nodemeta_name, nodemeta_value in node_meta.items():
13231322
params.append(('node-meta', '{0}:{1}'.
13241323
format(nodemeta_name, nodemeta_value)))
1325-
13261324
return self.agent.http.get(
13271325
CB.json(index=True), '/v1/catalog/services', params=params)
13281326

@@ -1406,7 +1404,8 @@ def service(
14061404
consistency=None,
14071405
dc=None,
14081406
near=None,
1409-
token=None):
1407+
token=None,
1408+
node_meta=None):
14101409
"""
14111410
Returns a tuple of (*index*, *nodes*) of the nodes providing
14121411
*service* in the *dc* datacenter. *dc* defaults to the current
@@ -1431,6 +1430,9 @@ def service(
14311430
14321431
*token* is an optional `ACL token`_ to apply to this request.
14331432
1433+
*node_meta* is an optional meta data used for filtering, a
1434+
dictionary formatted as {k1:v1, k2:v2}.
1435+
14341436
The response looks like this::
14351437
14361438
(index, [
@@ -1462,6 +1464,10 @@ def service(
14621464
consistency = consistency or self.agent.consistency
14631465
if consistency in ('consistent', 'stale'):
14641466
params.append((consistency, '1'))
1467+
if node_meta:
1468+
for nodemeta_name, nodemeta_value in node_meta.items():
1469+
params.append(('node-meta', '{0}:{1}'.
1470+
format(nodemeta_name, nodemeta_value)))
14651471
return self.agent.http.get(
14661472
CB.json(index=True),
14671473
'/v1/catalog/service/%s' % service,
@@ -1531,7 +1537,6 @@ def service(self,
15311537
for nodemeta_name, nodemeta_value in node_meta.items():
15321538
params.append(('node-meta', '{0}:{1}'.
15331539
format(nodemeta_name, nodemeta_value)))
1534-
15351540
return self.agent.http.get(
15361541
CB.json(index=True),
15371542
'/v1/health/service/%s' % service,
@@ -1587,7 +1592,6 @@ def checks(
15871592
for nodemeta_name, nodemeta_value in node_meta.items():
15881593
params.append(('node-meta', '{0}:{1}'.
15891594
format(nodemeta_name, nodemeta_value)))
1590-
15911595
return self.agent.http.get(
15921596
CB.json(index=True),
15931597
'/v1/health/checks/%s' % service,

0 commit comments

Comments
 (0)