@@ -536,7 +536,6 @@ class Agent(object):
536536 takes on the burden of registering with the Catalog and performing
537537 anti-entropy to recover from outages.
538538 """
539- # TODO: join, force-leave
540539 def __init__ (self , agent ):
541540 self .agent = agent
542541 self .service = Consul .Agent .Service (agent )
@@ -619,6 +618,44 @@ def maintenance(self, enable, reason=None):
619618 '/v1/agent/maintenance' ,
620619 params = params )
621620
621+ def join (self , address , wan = False ):
622+ """
623+ This endpoint instructs the agent to attempt to connect to a
624+ given address.
625+
626+ *address* is the ip to connect to.
627+
628+ *wan* is either 'true' or 'false'. For agents running in server
629+ mode, 'true' causes the agent to attempt to join using the WAN
630+ pool. Default is 'false'.
631+ """
632+
633+ params = {}
634+
635+ if wan :
636+ params ['wan' ] = 1
637+
638+ return self .agent .http .get (
639+ lambda x : x .code == 200 ,
640+ '/v1/agent/join/%s' % address ,
641+ params = params )
642+
643+ def force_leave (self , node ):
644+ """
645+ This endpoint instructs the agent to force a node into the left
646+ state. If a node fails unexpectedly, then it will be in a failed
647+ state. Once in the failed state, Consul will attempt to reconnect,
648+ and the services and checks belonging to that node will not be
649+ cleaned up. Forcing a node into the left state allows its old
650+ entries to be removed.
651+
652+ *node* is the node to change state for.
653+ """
654+
655+ return self .agent .http .get (
656+ lambda x : x .code == 200 ,
657+ '/v1/agent/force-leave/%s' % node )
658+
622659 class Service (object ):
623660 def __init__ (self , agent ):
624661 self .agent = agent
0 commit comments