Class: Fog::Terremark::Shared::Server
- Defined in:
- lib/fog/terremark/models/shared/server.rb
Instance Attribute Summary
Attributes inherited from Model
Instance Method Summary collapse
- #destroy ⇒ Object
-
#ready? ⇒ Boolean
{ ‘0’ => ‘Being created’, ‘2’ => ‘Powered Off’, ‘4’ => ‘Powered On’}.
- #reboot ⇒ Object
- #save ⇒ Object
Methods inherited from Model
#_dump, _load, aliases, attribute, attributes, #attributes, #collection, identity, #identity, #initialize, #inspect, #merge_attributes, #new_record?, #reload, #requires, #to_json, #wait_for
Constructor Details
This class inherits a constructor from Fog::Model
Instance Method Details
#destroy ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/fog/terremark/models/shared/server.rb', line 14 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 |
#ready? ⇒ Boolean
{ ‘0’ => ‘Being created’, ‘2’ => ‘Powered Off’, ‘4’ => ‘Powered On’}
24 25 26 |
# File 'lib/fog/terremark/models/shared/server.rb', line 24 def ready? @status == '2' end |
#reboot ⇒ Object
28 29 30 31 32 |
# File 'lib/fog/terremark/models/shared/server.rb', line 28 def reboot requires :id connection.reset(@id) true end |
#save ⇒ Object
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/fog/terremark/models/shared/server.rb', line 34 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 |