Class: Nomad::Node
Instance Attribute Summary
Attributes inherited from Request
Instance Method Summary collapse
-
#drain(node_id, enable = true, **options) ⇒ NodeEvaluation
Toggle drain mode for the node.
-
#evaluate(node_id, **options) ⇒ NodeEvaluation
Create a new evaluation for the given node.
-
#list(**options) ⇒ String
Get the address and port of the current leader for this region.
-
#read(node_id, **options) ⇒ NodeItem?
Get detailed information about the node.
Methods inherited from Request
Constructor Details
This class inherits a constructor from Nomad::Request
Instance Method Details
#drain(node_id, enable = true, **options) ⇒ NodeEvaluation
Toggle drain mode for the node.
72 73 74 75 76 |
# File 'lib/nomad/api/node.rb', line 72 def drain(node_id, enable = true, **) url = "/v1/node/#{CGI.escape(node_id)}/drain?enable=#{enable}" json = client.post(url, ) return NodeEvaluation.decode(json) end |
#evaluate(node_id, **options) ⇒ NodeEvaluation
Create a new evaluation for the given node.
57 58 59 60 |
# File 'lib/nomad/api/node.rb', line 57 def evaluate(node_id, **) json = client.post("/v1/node/#{CGI.escape(node_id)}/evaluate", ) return NodeEvaluation.decode(json) end |
#list(**options) ⇒ String
Get the address and port of the current leader for this region
23 24 25 26 |
# File 'lib/nomad/api/node.rb', line 23 def list(**) json = client.get("/v1/nodes", ) return json.map { |item| NodeItem.decode(item) } end |
#read(node_id, **options) ⇒ NodeItem?
Get detailed information about the node.
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/nomad/api/node.rb', line 36 def read(node_id, **) json = client.get("/v1/node/#{CGI.escape(node_id)}", ) 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 |