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

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

Instance Attribute Summary

Attributes inherited from Fog::Collection

#connection

Instance Method Summary collapse

Methods inherited from Fog::Collection

#clear, #create, #destroy, #initialize, #inspect, #load, model, #model, #new, #reload, #table, #to_json

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::Collection

Instance Method Details

#allObject



12
13
14
15
# File 'lib/fog/brightbox/models/compute/servers.rb', line 12

def all
  data = connection.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::Compute::Brightbox::Server



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

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 = connection.cloud_ips.allocate
  cip.map(server)
  cip.wait_for { mapped? }

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

#get(identifier) ⇒ Object



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

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