Class: RightScaleAPI::Server
- Inherits:
-
Account::SubResource
- Object
- Base
- Account::SubResource
- RightScaleAPI::Server
- Defined in:
- lib/right-scale-api/server.rb
Constant Summary collapse
- SETTINGS =
%w( ec2_ssh_key_href ec2_security_groups_href ec2_instance_type aki_image_href ari_image_href ec2_image_href vpc_subnet_href pricing max_spot_price locked ec2_availability_zone aws_platform dns_name private_dns_name ip_address private_ip_address aws_id cloud_id aws_product_codes )
Instance Attribute Summary
Attributes inherited from Account::SubResource
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.
-
#region ⇒ Object
returns the cloud region the server is in (:us_east,:us_west,:eu,:ap).
- #reload! ⇒ Object
- #reload_settings ⇒ Object
- #reset_settings ⇒ Object
-
#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, #collection_uri, create, #delete, #destroy, get, #get, #head, #initialize, #path, #post, #put, #send_request, #update, #uri
Constructor Details
This class inherits a constructor from RightScaleAPI::Base
Class Method Details
.opts_to_query_opts(opts) ⇒ Object
131 132 133 134 135 136 137 |
# File 'lib/right-scale-api/server.rb', line 131 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
124 125 126 127 128 129 |
# File 'lib/right-scale-api/server.rb', line 124 def attach_blank_volume opts device = opts.delete :device opts = {:ec2_availability_zone => ec2_availability_zone }.merge opts volume = account.create_ec2_ebs_volume opts attach_volume volume, device end |
#attach_volume(volume, device) ⇒ Object
Attach a volume to the server
106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/right-scale-api/server.rb', line 106 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
97 98 99 |
# File 'lib/right-scale-api/server.rb', line 97 def operational? state == 'operational' end |
#reboot ⇒ Object
Reboots the server
71 72 73 |
# File 'lib/right-scale-api/server.rb', line 71 def reboot post '/reboot' end |
#region ⇒ Object
returns the cloud region the server is in (:us_east,:us_west,:eu,:ap)
56 57 58 |
# File 'lib/right-scale-api/server.rb', line 56 def region RightScaleAPI::CLOUD_REGIONS.find{|k,v|v == cloud_id}.first end |
#reload! ⇒ Object
91 92 93 94 |
# File 'lib/right-scale-api/server.rb', line 91 def reload! super reload_settings end |
#reload_settings ⇒ Object
86 87 88 89 |
# File 'lib/right-scale-api/server.rb', line 86 def reload_settings reset_settings settings end |
#reset_settings ⇒ Object
82 83 84 |
# File 'lib/right-scale-api/server.rb', line 82 def reset_settings @settings = nil end |
#settings ⇒ Object
Server Settings for info: under Sub-resources on support.rightscale.com/15-References/RightScale_API_Reference_Guide/02-Management/02-Servers
78 79 80 |
# File 'lib/right-scale-api/server.rb', line 78 def settings @settings ||= get('/settings')['settings'] end |
#start ⇒ Object
Starts the server
61 62 63 |
# File 'lib/right-scale-api/server.rb', line 61 def start post '/start' end |
#stop ⇒ Object
Stops the server
66 67 68 |
# File 'lib/right-scale-api/server.rb', line 66 def stop post '/stop' end |