Class: Fog::Compute::Voxel::Server

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

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Server

Returns a new instance of Server.



14
15
16
17
# File 'lib/fog/compute/voxel/models/server.rb', line 14

def initialize(attributes={})
  self.image_id ||= "55" # Ubuntu 10.04 LTS 64bit
  super
end

Instance Method Details

#destroyObject



19
20
21
22
23
# File 'lib/fog/compute/voxel/models/server.rb', line 19

def destroy
  requires :id
  service.voxcloud_delete(id)
  true
end

#imageObject



25
26
27
28
# File 'lib/fog/compute/voxel/models/server.rb', line 25

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

#private_ip_addressObject



34
35
36
# File 'lib/fog/compute/voxel/models/server.rb', line 34

def private_ip_address
  ip_assignments.select { |ip_assignment| ip_assignment["type"] == "internal" }.first
end

#public_ip_addressObject



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

def public_ip_address
  ip_assignments.select { |ip_assignment| ip_assignment["type"] == "external" }.first
end

#ready?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/fog/compute/voxel/models/server.rb', line 30

def ready?
  state == "SUCCEEDED"
end

#rebootObject



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

def reboot
  requires :id
  service.devices_power(id, :reboot)
  true
end

#saveObject

Raises:

  • (Fog::Errors::Error)


52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/fog/compute/voxel/models/server.rb', line 52

def save
  raise Fog::Errors::Error.new("Resaving an existing object may create a duplicate") if persisted?
  requires :name, :image_id, :processing_cores, :facility, :disk_size

  data = service.voxcloud_create({
    :disk_size => disk_size,
    :facility => facility,
    :hostname => name,
    :image_id => image_id,
    :processing_cores => processing_cores
  }).body

  merge_attributes(data["device"])

  true
end

#stateObject



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

def state
  @state ||= service.voxcloud_status(id).body["devices"].first["status"]
end