Class: Fog::Terremark::Shared::Server
- Inherits:
-
Model
- Object
- Model
- Fog::Terremark::Shared::Server
show all
- Defined in:
- lib/fog/terremark/models/shared/server.rb
Instance Attribute Summary
Attributes inherited from Model
#connection
Instance Method Summary
collapse
Methods inherited from Model
#collection, #initialize, #inspect, #reload, #to_json, #wait_for
#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes
#_dump, #attributes, #identity, #identity=, #merge_attributes, #new_record?, #requires
Constructor Details
This class inherits a constructor from Fog::Model
Instance Method Details
#destroy ⇒ Object
16
17
18
19
20
21
22
23
|
# File 'lib/fog/terremark/models/shared/server.rb', line 16
def destroy
requires :id
data = connection.power_off(@id).body
task = connection.tasks.new(data)
task.wait_for { ready? }
connection.delete_vapp(@id)
true
end
|
#graceful_restart ⇒ Object
77
78
79
80
81
82
|
# File 'lib/fog/terremark/models/shared/server.rb', line 77
def graceful_restart
requires :id
shutdown
wait_for { off? }
power_on
end
|
#off? ⇒ Boolean
34
35
36
|
# File 'lib/fog/terremark/models/shared/server.rb', line 34
def off?
@status == '2'
end
|
#on? ⇒ Boolean
30
31
32
|
# File 'lib/fog/terremark/models/shared/server.rb', line 30
def on?
@status == '4'
end
|
#power_off ⇒ Object
49
50
51
52
53
54
55
56
57
58
|
# File 'lib/fog/terremark/models/shared/server.rb', line 49
def power_off
requires :id
begin
connection.power_off(@id)
rescue Excon::Errors::InternalServerError => e
raise e unless e.to_s =~ /because it is already powered off/
end
true
end
|
#power_on(options = {}) ⇒ Object
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/fog/terremark/models/shared/server.rb', line 38
def power_on(options = {})
requires :id
begin
connection.power_on(@id)
rescue Excon::Errors::InternalServerError => e
raise e unless e.to_s =~ /because it is already powered on/
end
true
end
|
#power_reset ⇒ Object
71
72
73
74
75
|
# File 'lib/fog/terremark/models/shared/server.rb', line 71
def power_reset
requires :id
connection.power_reset(@id)
true
end
|
#ready? ⇒ Boolean
{ ‘0’ => ‘Being created’, ‘2’ => ‘Powered Off’, ‘4’ => ‘Powered On’}
26
27
28
|
# File 'lib/fog/terremark/models/shared/server.rb', line 26
def ready?
@status == '2'
end
|
#save ⇒ Object
84
85
86
87
88
89
90
91
92
93
|
# File 'lib/fog/terremark/models/shared/server.rb', line 84
def save
requires :name
data = connection.instantiate_vapp(@name)
merge_attributes(data.body)
task = connection.deploy_vapp(@id)
task.wait_for { ready? }
task = connection.power_on(@id)
task.wait_for { ready? }
true
end
|
#shutdown ⇒ Object
60
61
62
63
64
65
66
67
68
69
|
# File 'lib/fog/terremark/models/shared/server.rb', line 60
def shutdown
requires :id
begin
connection.power_shutdown(@id)
rescue Excon::Errors::InternalServerError => e
raise e unless e.to_s =~ /because it is already powered off/
end
true
end
|