Class: RackspaceCloud::Server
- Inherits:
-
Object
- Object
- RackspaceCloud::Server
- Defined in:
- lib/rackspace_cloud/server.rb
Constant Summary collapse
- STATUS_VALUES =
%w{ACTIVE BUILD REBUILD SUSPENDED QUEUE_RESIZE PREP_RESIZE VERIFY_RESIZE PASSWORD RESCUE REBOOT HARD_REBOOT SHARE_IP SHARE_IP_NO_CONFIG DELETE_IP UNKNOWN}
Instance Attribute Summary collapse
-
#adminPass ⇒ Object
readonly
Returns the value of attribute adminPass.
-
#base ⇒ Object
readonly
Returns the value of attribute base.
-
#flavor ⇒ Object
readonly
Returns the value of attribute flavor.
-
#host_id ⇒ Object
readonly
Returns the value of attribute host_id.
-
#image ⇒ Object
readonly
Returns the value of attribute image.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#private_ips ⇒ Object
readonly
Returns the value of attribute private_ips.
-
#progress ⇒ Object
readonly
Returns the value of attribute progress.
-
#public_ips ⇒ Object
readonly
Returns the value of attribute public_ips.
-
#rackspace_id ⇒ Object
readonly
Returns the value of attribute rackspace_id.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
- #confirm_resize ⇒ Object
- #delete ⇒ Object
- #hard_reboot ⇒ Object
-
#initialize(base, server_json) ⇒ Server
constructor
A new instance of Server.
- #ready? ⇒ Boolean
- #reboot ⇒ Object
- #rebuild(new_image = nil) ⇒ Object
-
#refresh ⇒ Object
update this server’s status and progress by calling /servers/<id>.
- #resize(new_flavor) ⇒ Object
- #revert_resize ⇒ Object
- #share_ip_address(ip_address, shared_ip_address_group, configure_server = true) ⇒ Object
- #unshare_ip_address(ip_address) ⇒ Object
- #update_admin_password(new_password) ⇒ Object
- #update_server_name(new_name) ⇒ Object
Constructor Details
#initialize(base, server_json) ⇒ Server
Returns a new instance of Server.
9 10 11 12 |
# File 'lib/rackspace_cloud/server.rb', line 9 def initialize(base, server_json) @base = base populate(server_json) end |
Instance Attribute Details
#adminPass ⇒ Object (readonly)
Returns the value of attribute adminPass.
5 6 7 |
# File 'lib/rackspace_cloud/server.rb', line 5 def adminPass @adminPass end |
#base ⇒ Object (readonly)
Returns the value of attribute base.
3 4 5 |
# File 'lib/rackspace_cloud/server.rb', line 3 def base @base end |
#flavor ⇒ Object (readonly)
Returns the value of attribute flavor.
3 4 5 |
# File 'lib/rackspace_cloud/server.rb', line 3 def flavor @flavor end |
#host_id ⇒ Object (readonly)
Returns the value of attribute host_id.
4 5 6 |
# File 'lib/rackspace_cloud/server.rb', line 4 def host_id @host_id end |
#image ⇒ Object (readonly)
Returns the value of attribute image.
3 4 5 |
# File 'lib/rackspace_cloud/server.rb', line 3 def image @image end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/rackspace_cloud/server.rb', line 3 def name @name end |
#private_ips ⇒ Object (readonly)
Returns the value of attribute private_ips.
5 6 7 |
# File 'lib/rackspace_cloud/server.rb', line 5 def private_ips @private_ips end |
#progress ⇒ Object (readonly)
Returns the value of attribute progress.
4 5 6 |
# File 'lib/rackspace_cloud/server.rb', line 4 def progress @progress end |
#public_ips ⇒ Object (readonly)
Returns the value of attribute public_ips.
5 6 7 |
# File 'lib/rackspace_cloud/server.rb', line 5 def public_ips @public_ips end |
#rackspace_id ⇒ Object (readonly)
Returns the value of attribute rackspace_id.
4 5 6 |
# File 'lib/rackspace_cloud/server.rb', line 4 def rackspace_id @rackspace_id end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
3 4 5 |
# File 'lib/rackspace_cloud/server.rb', line 3 def status @status end |
Instance Method Details
#confirm_resize ⇒ Object
34 35 36 |
# File 'lib/rackspace_cloud/server.rb', line 34 def confirm_resize action_request('confirmResize' => nil) end |
#delete ⇒ Object
51 52 53 |
# File 'lib/rackspace_cloud/server.rb', line 51 def delete @base.request("/servers/#{@rackspace_id}", :method => :delete) end |
#hard_reboot ⇒ Object
22 23 24 |
# File 'lib/rackspace_cloud/server.rb', line 22 def hard_reboot action_request('reboot' => {'type' => 'HARD'}) end |
#ready? ⇒ Boolean
14 15 16 |
# File 'lib/rackspace_cloud/server.rb', line 14 def ready? self.refresh.status == 'ACTIVE' end |
#reboot ⇒ Object
18 19 20 |
# File 'lib/rackspace_cloud/server.rb', line 18 def reboot action_request('reboot' => {'type' => 'SOFT'}) end |
#rebuild(new_image = nil) ⇒ Object
26 27 28 |
# File 'lib/rackspace_cloud/server.rb', line 26 def rebuild(new_image=nil) action_request('rebuild' => {'imageId' => new_image ? new_image.to_i : image.to_i}) end |
#refresh ⇒ Object
update this server’s status and progress by calling /servers/<id>
64 65 66 67 |
# File 'lib/rackspace_cloud/server.rb', line 64 def refresh populate(@base.request("/servers/#{@rackspace_id}")['server']) self end |
#resize(new_flavor) ⇒ Object
30 31 32 |
# File 'lib/rackspace_cloud/server.rb', line 30 def resize(new_flavor) action_request('resize' => {'flavorId' => new_flavor.to_i}) end |
#revert_resize ⇒ Object
38 39 40 |
# File 'lib/rackspace_cloud/server.rb', line 38 def revert_resize action_request('revertResize' => nil) end |
#share_ip_address(ip_address, shared_ip_address_group, configure_server = true) ⇒ Object
42 43 44 45 |
# File 'lib/rackspace_cloud/server.rb', line 42 def share_ip_address(ip_address, shared_ip_address_group, configure_server = true) @base.request("/servers/#{@rackspace_id}/ips/public/#{ip_address}", :method => :put, :data => {'shareIp' => {'sharedIpGroupId' => shared_ip_address_group.to_i, 'configureServer' => configure_server}}) end |
#unshare_ip_address(ip_address) ⇒ Object
47 48 49 |
# File 'lib/rackspace_cloud/server.rb', line 47 def unshare_ip_address(ip_address) @base.request("/servers/#{@rackspace_id}/ips/public/#{ip_address}", :method => :delete) end |
#update_admin_password(new_password) ⇒ Object
59 60 61 |
# File 'lib/rackspace_cloud/server.rb', line 59 def update_admin_password(new_password) @base.request("/servers/#{@rackspace_id}", :method => :put, :data => {"server" => {"adminPass" => new_password}}) end |
#update_server_name(new_name) ⇒ Object
55 56 57 |
# File 'lib/rackspace_cloud/server.rb', line 55 def update_server_name(new_name) @base.request("/servers/#{@rackspace_id}", :method => :put, :data => {"server" => {"name" => new_name}}) end |