Class: RightScaleAPI::Server
- Inherits:
-
Account::SubResource
- Object
- Base
- Account::SubResource
- RightScaleAPI::Server
- Defined in:
- lib/right-scale-api/server.rb
Instance Attribute Summary
Attributes inherited from Account::SubResource
Attributes inherited from Base
Class Method Summary collapse
Instance Method Summary collapse
-
#attach_blank_volume(opts) ⇒ Object
creates a blank volume and attaches it to the server.
-
#attach_volume(volume, device) ⇒ Object
Attach a volume to the server.
-
#operational? ⇒ Boolean
(also: #running?)
Is the server operational.
-
#reboot ⇒ Object
Reboots the server.
-
#settings ⇒ Object
Server Settings for info: under Sub-resources on support.rightscale.com/15-References/RightScale_API_Reference_Guide/02-Management/02-Servers.
-
#start ⇒ Object
Starts the server.
-
#stop ⇒ Object
Stops the server.
Methods inherited from Account::SubResource
Methods inherited from Base
api_name, attributes, create, #delete, #destroy, get, #get, #head, #initialize, #post, #put, #reload!, #send_request, #update, #uri
Constructor Details
This class inherits a constructor from RightScaleAPI::Base
Class Method Details
.opts_to_query_opts(opts) ⇒ Object
81 82 83 84 85 86 87 |
# File 'lib/right-scale-api/server.rb', line 81 def self.opts_to_query_opts opts assoc_ip = opts.delete :associate_eip_at_launch if !assoc_ip.nil? opts[:associate_eip_at_launch] = assoc_ip ? 1 : 0 end super opts end |
Instance Method Details
#attach_blank_volume(opts) ⇒ Object
creates a blank volume and attaches it to the server
74 75 76 77 78 79 |
# File 'lib/right-scale-api/server.rb', line 74 def attach_blank_volume opts device = opts.delete :device opts = {:ec2_availability_zone => 'us-east-1a'}.merge opts #default to the server's avail zone volume = account.create_ec2_ebs_volume opts attach_volume volume, device end |
#attach_volume(volume, device) ⇒ Object
Attach a volume to the server
58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/right-scale-api/server.rb', line 58 def attach_volume volume, device if running? post '/attach_volume', :query => { :server => { :ec2_ebs_volume_href => volume.uri, :device => device } } else volume.attach_to_server self, device, 'boot' end end |
#operational? ⇒ Boolean Also known as: running?
Is the server operational
49 50 51 |
# File 'lib/right-scale-api/server.rb', line 49 def operational? state == 'operational' end |
#reboot ⇒ Object
Reboots the server
37 38 39 |
# File 'lib/right-scale-api/server.rb', line 37 def reboot post '/reboot' end |
#settings ⇒ Object
Server Settings for info: under Sub-resources on support.rightscale.com/15-References/RightScale_API_Reference_Guide/02-Management/02-Servers
44 45 46 |
# File 'lib/right-scale-api/server.rb', line 44 def settings get('/settings')['settings'] end |
#start ⇒ Object
Starts the server
27 28 29 |
# File 'lib/right-scale-api/server.rb', line 27 def start post '/start' end |
#stop ⇒ Object
Stops the server
32 33 34 |
# File 'lib/right-scale-api/server.rb', line 32 def stop post '/stop' end |