Skip to content

Commit b6d836a

Browse files
author
David Beahm
committed
Ability to put service into maintenance mode through PUT HTTP request
1 parent adfdc89 commit b6d836a

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

consulate/api/agent.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,21 @@ def deregister(self, service_id):
274274
"""
275275
return self._put_no_response_body(['deregister', service_id])
276276

277+
def maintenance(self, service_id, enable=True, reason=None):
278+
"""Place given service into "maintenance mode".
279+
280+
:param str service_id: The id for the service
281+
:param bool enable: Enable maintenance mode
282+
:param str reason: Reason for putting node in maintenance
283+
:rtype: bool
284+
285+
"""
286+
query_params = {'enable': enable}
287+
if reason:
288+
query_params['reason'] = reason
289+
return self._put_no_response_body(['maintenance', service_id],
290+
query_params)
291+
277292
def checks(self):
278293
"""Return the all the checks that are registered with the local agent.
279294
These checks were either provided through configuration files, or

0 commit comments

Comments
 (0)