Module: Spice::Connection::Nodes

Included in:
Spice::Connection
Defined in:
lib/spice/connection/nodes.rb

Instance Method Summary collapse

Instance Method Details

#create_node(params = Mash.new) ⇒ Object


29
30
31
32
33
# File 'lib/spice/connection/nodes.rb', line 29

def create_node(params=Mash.new)
  node = Spice::Node.new(params)
  post("/nodes", node.attrs)
  get_node(node.name)
end

#node(name) ⇒ Spice::Node Also known as: get_node

Retrieve a single client

Examples:

Retrieve the node named “app.example.com”

Spice.node("app.example.com")

Parameters:

  • name (String)

    The node name

Returns:

Raises:


22
23
24
25
# File 'lib/spice/connection/nodes.rb', line 22

def node(name)
  attributes = get("/nodes/#{name}")
  Spice::Node.get_or_new(attributes)
end

#nodes(options = Mash.new) ⇒ Array<Spice::Node>

A collection of nodes

Examples:

Retrieve all nodes that have the role “base”

Spice.nodes(:q => "roles:base")

Retrieve nodes with role “base” in the “production” environment

Spice.nodes(:q => "roles:base AND environment:production")

Parameters:

  • options (Hash) (defaults to: Mash.new)

    An options hash that is passed to Search#search

Returns:

See Also:


12
13
14
# File 'lib/spice/connection/nodes.rb', line 12

def nodes(options=Mash.new)
  search('node', options)
end

#update_node(params = Mash.new) ⇒ Object

def create_node


35
36
37
38
39
40
# File 'lib/spice/connection/nodes.rb', line 35

def update_node(params=Mash.new)
  node = get_node(params[:name])
  node.attrs.update Spice::Node.new(params)
  put("/nodes/#{node.name}", node.attrs)
  get_node(node.name)
end