Class: Fog::Brightbox::Compute::Servers

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

Instance Method Summary collapse

Instance Method Details

#allObject



9
10
11
12
# File 'lib/fog/brightbox/models/compute/servers.rb', line 9

def all
  data = service.list_servers
  load(data)
end

#bootstrap(options = {}) ⇒ Object

TODO:

Support uploading of arbitary SSH keys

Creates a server and maps an Cloud IP

By default the public SSH key you have registered with Brightbox is already made available in an AWS compatible metdata service.

Parameters:

  • options (Hash) (defaults to: {})

Options Hash (options):

  • name (String)

    Name for the server

  • flavor_id (String)

    Identifier for virtual hardware type to request

  • image_id (String)

    Identifier for image to use when creating

  • zone_id (String)

    Identifer for preferred zone to locate server in

  • server_groups (Array<String>)

    List of group identifiers for the server to join

Returns:

  • Fog::Brightbox::Compute::Server



31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/fog/brightbox/models/compute/servers.rb', line 31

def bootstrap(options = {})
  server = create(options)

  # Ensure server is now available
  server.wait_for { ready? }

  # To get a public IP address we need to map a cloud IP address
  cip = service.cloud_ips.allocate
  cip.map(server)
  cip.wait_for { mapped? }

  # Reload so the public IP is now available
  server.reload
end

#get(identifier) ⇒ Object



46
47
48
49
50
51
52
# File 'lib/fog/brightbox/models/compute/servers.rb', line 46

def get(identifier)
  return nil if identifier.nil? || identifier == ""
  data = service.get_server(identifier)
  new(data)
rescue Excon::Errors::NotFound
  nil
end