This endpoint queries the agent for the known peers in the gossip pool. This endpoint is only applicable to servers. Due to the nature of gossip, this is eventually consistent.
https://developer.hashicorp.com/nomad/api-docs/agent#list-members
Example:
import nomad
my_nomad = nomad.Nomad(host='192.168.33.10')
members = my_nomad.agent.get_members()
for member in members["Members"]:
print (member["Name"])
This endpoint lists the known server nodes. The servers endpoint is used to query an agent in client mode for its list of known servers. Client nodes register themselves with these server addresses so that they may dequeue work. The servers endpoint can be used to keep this configuration up to date if there are changes in the cluster
https://developer.hashicorp.com/nomad/api-docs/agent#list-servers
Example:
import nomad
my_nomad = nomad.Nomad(host='192.168.33.10')
servers = my_nomad.agent.get_servers()
for server in servers:
print (server)
This endpoint queries the state of the target agent (self).
https://developer.hashicorp.com/nomad/api-docs/agent#query-self
Example:
import nomad
my_nomad = nomad.Nomad(host='192.168.33.10')
agent = my_nomad.agent.get_agent()
print (agent)
This endpoint updates the list of known servers to the provided list. This replaces all previous server addresses with the new list.
https://developer.hashicorp.com/nomad/api-docs/agent#update-servers
Example:
import nomad
my_nomad = nomad.Nomad(host='192.168.33.10')
r = my_nomad.agent.update_servers(['192.168.33.11', '10.1.10.200:4829'])
This endpoint introduces a new member to the gossip pool. This endpoint is only eligible for servers.
https://developer.hashicorp.com/nomad/api-docs/agent#join-agent
Example:
import nomad
my_nomad = nomad.Nomad(host='192.168.33.10')
r = my_nomad.agent.join_agent("server02")
This endpoint forces a member of the gossip pool from the "failed" state to the "left" state. This allows the consensus protocol to remove the peer and stop attempting replication. This is only applicable for servers.
https://developer.hashicorp.com/nomad/api-docs/agent#force-leave-agent
Exmaple:
import nomad
my_nomad = nomad.Nomad(host='192.168.33.10')
r = my_nomad.agent.force_leave("server02")
This endpoint returns whether or not the agent is healthy. When using Consul it is the endpoint Nomad will register for its own health checks.
When the agent is unhealthy 500 will be returned along with JSON response containing an error message.
https://developer.hashicorp.com/nomad/api-docs/agent#health
Example:
import nomad
my_nomad = nomad.Nomad(host='192.168.33.10')
r = my_nomad.agent.get_health()