Class: Fog::Compute::Voxel::Server
- Inherits:
-
Server
show all
- Defined in:
- lib/fog/voxel/models/compute/server.rb
Instance Attribute Summary
Attributes inherited from Server
#private_key, #private_key_path, #public_key, #public_key_path, #username
Attributes inherited from Model
#collection, #connection
Instance Method Summary
collapse
Methods inherited from Server
#scp, #scp_download, #ssh, #ssh_port, #sshable?
Methods inherited from Model
#inspect, #reload, #symbolize_keys, #to_json, #wait_for
#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes
#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #requires, #requires_one
Constructor Details
#initialize(attributes = {}) ⇒ Server
Returns a new instance of Server.
18
19
20
21
|
# File 'lib/fog/voxel/models/compute/server.rb', line 18
def initialize(attributes={})
self.image_id ||= '55' super
end
|
Instance Method Details
#destroy ⇒ Object
23
24
25
26
27
|
# File 'lib/fog/voxel/models/compute/server.rb', line 23
def destroy
requires :id
connection.voxcloud_delete(id)
true
end
|
#image ⇒ Object
29
30
31
32
|
# File 'lib/fog/voxel/models/compute/server.rb', line 29
def image
requires :image_id
connection.images.get(image_id)
end
|
#private_ip_address ⇒ Object
38
39
40
|
# File 'lib/fog/voxel/models/compute/server.rb', line 38
def private_ip_address
ip_assignments.select {|ip_assignment| ip_assignment['type'] == 'internal'}.first
end
|
#public_ip_address ⇒ Object
42
43
44
|
# File 'lib/fog/voxel/models/compute/server.rb', line 42
def public_ip_address
ip_assignments.select {|ip_assignment| ip_assignment['type'] == 'external'}.first
end
|
#ready? ⇒ Boolean
34
35
36
|
# File 'lib/fog/voxel/models/compute/server.rb', line 34
def ready?
self.state == 'SUCCEEDED'
end
|
#reboot ⇒ Object
46
47
48
49
50
|
# File 'lib/fog/voxel/models/compute/server.rb', line 46
def reboot
requires :id
connection.devices_power(id, :reboot)
true
end
|
#save ⇒ Object
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
# File 'lib/fog/voxel/models/compute/server.rb', line 56
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
|
#state ⇒ Object
52
53
54
|
# File 'lib/fog/voxel/models/compute/server.rb', line 52
def state
@state ||= connection.voxcloud_status(id).body['devices'].first['status']
end
|