Class: Fog::Compute::Brightbox::Server

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

Instance Attribute Summary

Attributes inherited from Model

#collection, #connection

Instance Method Summary collapse

Methods inherited from Model

#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

Constructor Details

#initialize(attributes = {}) ⇒ Server

Returns a new instance of Server.



31
32
33
34
35
# File 'lib/fog/compute/models/brightbox/server.rb', line 31

def initialize(attributes={})
  self.flavor_id  ||= 'typ-4nssg' # Nano
  self.image_id   ||= 'img-2ab98' # Ubuntu Lucid 10.04 server (i686)
  super
end

Instance Method Details

#activate_consoleObject



92
93
94
95
96
# File 'lib/fog/compute/models/brightbox/server.rb', line 92

def activate_console
  requires :identity
  response = connection.activate_console_server(identity)
  [response["console_url"], response["console_token"], response["console_token_expires"]]
end

#destroyObject



64
65
66
67
68
# File 'lib/fog/compute/models/brightbox/server.rb', line 64

def destroy
  requires :identity
  connection.destroy_server(identity)
  true
end

#flavorObject



70
71
72
73
# File 'lib/fog/compute/models/brightbox/server.rb', line 70

def flavor
  requires :flavor_id
  connection.flavors.get(flavor_id)
end

#imageObject



75
76
77
78
# File 'lib/fog/compute/models/brightbox/server.rb', line 75

def image
  requires :image_id
  connection.images.get(image_id)
end

#private_ip_addressObject



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

def private_ip_address
  interfaces.first
end

#public_ip_addressObject



84
85
86
# File 'lib/fog/compute/models/brightbox/server.rb', line 84

def public_ip_address
  cloud_ips.first
end

#ready?Boolean

Returns:

  • (Boolean)


88
89
90
# File 'lib/fog/compute/models/brightbox/server.rb', line 88

def ready?
  self.state == 'active'
end

#rebootObject



42
43
44
# File 'lib/fog/compute/models/brightbox/server.rb', line 42

def reboot
  false
end

#saveObject



98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/fog/compute/models/brightbox/server.rb', line 98

def save
  requires :image_id
  options = {
    :image => image_id,
    :server_type => flavor_id,
    :name => name,
    :zone => zone_id,
    :user_data => user_data
  }.delete_if {|k,v| v.nil? || v == "" }
  data = connection.create_server(options)
  merge_attributes(data)
  true
end

#shutdownObject



58
59
60
61
62
# File 'lib/fog/compute/models/brightbox/server.rb', line 58

def shutdown
  requires :identity
  connection.shutdown_server(identity)
  true
end

#snapshotObject



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

def snapshot
  requires :identity
  connection.snapshot_server(identity)
end

#startObject



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

def start
  requires :identity
  connection.start_server(identity)
  true
end

#stopObject



52
53
54
55
56
# File 'lib/fog/compute/models/brightbox/server.rb', line 52

def stop
  requires :identity
  connection.stop_server(identity)
  true
end