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.
-
#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(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
Constructor Details
#initialize(server_json) ⇒ Server
Returns a new instance of Server.
9 10 11 |
# File 'lib/rackspace_cloud/server.rb', line 9 def initialize(server_json) 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 |
#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
33 34 35 |
# File 'lib/rackspace_cloud/server.rb', line 33 def confirm_resize action_request('confirmResize' => nil) end |
#delete ⇒ Object
41 42 43 |
# File 'lib/rackspace_cloud/server.rb', line 41 def delete RackspaceCloud.request("/servers/#{@rackspace_id}", :method => :delete) end |
#hard_reboot ⇒ Object
21 22 23 |
# File 'lib/rackspace_cloud/server.rb', line 21 def hard_reboot action_request('reboot' => {'type' => 'HARD'}) end |
#ready? ⇒ Boolean
13 14 15 |
# File 'lib/rackspace_cloud/server.rb', line 13 def ready? @status == 'ACTIVE' end |
#reboot ⇒ Object
17 18 19 |
# File 'lib/rackspace_cloud/server.rb', line 17 def reboot action_request('reboot' => {'type' => 'SOFT'}) end |
#rebuild(new_image = nil) ⇒ Object
25 26 27 |
# File 'lib/rackspace_cloud/server.rb', line 25 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>
46 47 48 49 |
# File 'lib/rackspace_cloud/server.rb', line 46 def refresh populate(RackspaceCloud.request("/servers/#{@rackspace_id}")['server']) self end |
#resize(new_flavor) ⇒ Object
29 30 31 |
# File 'lib/rackspace_cloud/server.rb', line 29 def resize(new_flavor) action_request('resize' => {'flavorId' => new_flavor.to_i}) end |
#revert_resize ⇒ Object
37 38 39 |
# File 'lib/rackspace_cloud/server.rb', line 37 def revert_resize action_request('revertResize' => nil) end |