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, #service

Instance Method Summary collapse

Methods inherited from Model

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

Methods included from Attributes::ClassMethods

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

Methods included from Fog::Core::DeprecatedConnectionAccessors

#connection, #connection=, #prepare_service_value

Methods included from Attributes::InstanceMethods

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

Constructor Details

This class inherits a constructor from Fog::Model

Instance Method Details

#add_servers(identifiers) ⇒ Fog::Compute::ServerGroup

Adds specified servers to this server group

Parameters:

  • identifiers (Array)

    array of server identifier strings to add

Returns:

  • (Fog::Compute::ServerGroup)


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

def add_servers(identifiers)
  requires :identity
  options = {
    :servers => server_references(identifiers)
  }
  data = service.add_servers_server_group identity, options
  merge_attributes data
end

#destroyObject



80
81
82
83
84
# File 'lib/fog/brightbox/models/compute/server_group.rb', line 80

def destroy
  requires :identity
  service.destroy_server_group(identity)
  true
end

#move_servers(identifiers, destination_group_id) ⇒ Fog::Compute::ServerGroup

Moves specified servers from this server group to the specified destination server group

Parameters:

  • identifiers (Array)

    array of server identifier strings to move

  • destination_group_id (String)

    destination server group identifier

Returns:

  • (Fog::Compute::ServerGroup)


70
71
72
73
74
75
76
77
78
# File 'lib/fog/brightbox/models/compute/server_group.rb', line 70

def move_servers(identifiers, destination_group_id)
  requires :identity
  options = {
    :servers => server_references(identifiers),
    :destination => destination_group_id
  }
  data = service.move_servers_server_group identity, options
  merge_attributes data
end

#remove_servers(identifiers) ⇒ Fog::Compute::ServerGroup

Removes specified servers from this server group

Parameters:

  • identifiers (Array)

    array of server identifier strings to remove

Returns:

  • (Fog::Compute::ServerGroup)


56
57
58
59
60
61
62
63
# File 'lib/fog/brightbox/models/compute/server_group.rb', line 56

def remove_servers(identifiers)
  requires :identity
  options = {
    :servers => server_references(identifiers)
  }
  data = service.remove_servers_server_group identity, options
  merge_attributes data
end

#saveObject



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

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

#serversObject



32
33
34
35
36
37
# File 'lib/fog/brightbox/models/compute/server_group.rb', line 32

def servers
  srv_ids = server_ids.map { |srv| srv["id"] }
  srv_ids.map do |srv_id|
    service.servers.get(srv_id)
  end
end