Class: Fog::Compute::Brightbox::ServerGroup

Inherits:
Model
  • Object
show all
Defined in:
lib/fog/brightbox/models/compute/server_group.rb

Overview

A server group is a collection of servers

Certain actions can accept a server group and affect all members

Instance Attribute Summary

Attributes inherited from Model

#collection, #connection

Instance Method Summary collapse

Methods inherited from Model

#initialize, #inspect, #reload, #to_json, #wait_for

Methods included from Attributes::ClassMethods

#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes

Methods included from Attributes::InstanceMethods

#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #requires, #requires_one

Constructor Details

This class inherits a constructor from Fog::Model

Instance Method Details

#add_servers(server_identifiers) ⇒ Object

Add a server to the server group

Parameters:

identifiers

An array of identifiers for the servers to add to the group

Returns:

An excon response object representing the result

<Excon::Response: ...


43
44
45
46
47
48
49
50
51
# File 'lib/fog/brightbox/models/compute/server_group.rb', line 43

def add_servers(server_identifiers)
  requires :identity
  server_references = server_identifiers.map {|ident| {"server" => ident} }
  options = {
    :servers => server_references
  }
  data = connection.add_servers_server_group(identity, options)
  merge_attributes(data)
end

#saveObject



20
21
22
23
24
25
26
27
28
29
# File 'lib/fog/brightbox/models/compute/server_group.rb', line 20

def save
  requires :name
  options = {
    :name => name,
    :description => description
  }.delete_if {|k,v| v.nil? || v == "" }
  data = connection.create_server_group(options)
  merge_attributes(data)
  true
end