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

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

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Server

Returns a new instance of Server.



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

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

Instance Method Details

#destroyObject



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

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

#imageObject



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

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

#private_ip_addressObject



36
37
38
# File 'lib/fog/voxel/models/compute/server.rb', line 36

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

#public_ip_addressObject



40
41
42
# File 'lib/fog/voxel/models/compute/server.rb', line 40

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

#ready?Boolean

Returns:

  • (Boolean)


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

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

#rebootObject



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

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

#saveObject

Raises:

  • (Fog::Errors::Error)


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

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



50
51
52
# File 'lib/fog/voxel/models/compute/server.rb', line 50

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