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

Inherits:
Model
  • Object
show all
Defined in:
lib/fog/compute/models/voxel/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, #identity, #identity=, #merge_attributes, #new_record?, #requires

Constructor Details

#initialize(attributes = {}) ⇒ Server

Returns a new instance of Server.



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

def initialize(attributes={})
  super
end

Instance Method Details

#destroyObject



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

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

#imageObject



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

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

#private_ip_addressObject



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

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

#public_ip_addressObject



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

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

#ready?Boolean

Returns:

  • (Boolean)


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

def ready?
  status == 'SUCCEEDED'
end

#rebootObject



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

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

#saveObject

Raises:



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

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

  data = connection.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

#statusObject



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

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