class Nomad::Node
Public Instance Methods
drain(node_id, enable = true, **options)
click to toggle source
Toggle drain mode for the node.
@example
Nomad.node.drain("abcd1234", true) #=> #<NodeEvaluation ...> Nomad.node.drain("abcd1234", false)
@param [String] node_id The node ID to drain @param [Boolean] enable whether to enable or disable drain mode
@return [NodeEvaluation]
# File lib/nomad/api/node.rb, line 72 def drain(node_id, enable = true, **options) url = "/v1/node/#{CGI.escape(node_id)}/drain?enable=#{enable}" json = client.post(url, options) return NodeEvaluation.decode(json) end
evaluate(node_id, **options)
click to toggle source
Create a new evaluation for the given node.
@example
Nomad.node.evaluate("abcd1234")
@param [String] node_id The ID of the node
@return [NodeEvaluation]
# File lib/nomad/api/node.rb, line 57 def evaluate(node_id, **options) json = client.post("/v1/node/#{CGI.escape(node_id)}/evaluate", options) return NodeEvaluation.decode(json) end
list(**options)
click to toggle source
Get the address and port of the current leader for this region
@example
Nomad.node.list #=> [#<Node ...>]
@option [String] :prefix
an optional prefix to filter nodes
@return [String]
# File lib/nomad/api/node.rb, line 23 def list(**options) json = client.get("/v1/nodes", options) return json.map { |item| NodeItem.decode(item) } end
read(node_id, **options)
click to toggle source
Get detailed information about the node.
@param [String] node_id The ID of the ndoe
@example
Nomad.node.read("abcd1234") #=> #<Node ...>
@return [NodeItem, nil]
# File lib/nomad/api/node.rb, line 36 def read(node_id, **options) json = client.get("/v1/node/#{CGI.escape(node_id)}", options) return NodeItem.decode(json) rescue Nomad::HTTPError => e # This is really jank, but Nomad doesn't return a 404 and returns a 500 # instead, so we have to inspect the output. if e.errors.any? { |err| err.include?("node lookup failed") } return nil else raise end end