Class: Fog::Brightbox::Compute::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 Method Summary collapse

Methods included from ModelHelper

#collection_name, #resource_name

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)


48
49
50
51
52
53
54
55
# File 'lib/fog/brightbox/models/compute/server_group.rb', line 48

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

#destroyObject



85
86
87
88
89
# File 'lib/fog/brightbox/models/compute/server_group.rb', line 85

def destroy
  requires :identity
  service.delete_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)


75
76
77
78
79
80
81
82
83
# File 'lib/fog/brightbox/models/compute/server_group.rb', line 75

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)


61
62
63
64
65
66
67
68
# File 'lib/fog/brightbox/models/compute/server_group.rb', line 61

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

#saveObject



27
28
29
30
31
32
33
34
35
# File 'lib/fog/brightbox/models/compute/server_group.rb', line 27

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



37
38
39
40
41
42
# File 'lib/fog/brightbox/models/compute/server_group.rb', line 37

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