Class CloudServers::Server
In: lib/cloudservers/server.rb
Parent: Object

Methods

Attributes

addresses  [R] 
adminPass  [RW] 
flavorId  [R] 
hostId  [R] 
id  [R] 
imageId  [R] 
metadata  [R] 
name  [R] 
progress  [R] 
status  [R] 

Public Class methods

This class is the representation of a single Cloud Server object. The constructor finds the server identified by the specified ID number, accesses the API via the populate method to get information about that server, and returns the object.

Will be called via the get_server or create_server methods on the CloudServers::Connection object, and will likely not be called directly.

  >> server = cs.get_server(110917)
  => #<CloudServers::Server:0x1014e5438 ....>
  >> server.name
  => "RenamedRubyTest"

Public Instance methods

Provides information about the backup schedule for this server. Returns a hash of the form {"weekly" => state, "daily" => state, "enabled" => boolean}

  >> server.backup_schedule
  => {"weekly"=>"THURSDAY", "daily"=>"H_0400_0600", "enabled"=>true}

Updates the backup schedule for the server. Takes a hash of the form: {:weekly => state, :daily => state, :enabled => boolean} as an argument. All three keys (:weekly, :daily, :enabled) must be provided or an exception will get raised.

  >> server.backup_schedule=({:weekly=>"THURSDAY", :daily=>"H_0400_0600", :enabled=>true})
  => {:weekly=>"THURSDAY", :daily=>"H_0400_0600", :enabled=>true}

After a server resize is complete, calling this method will confirm the resize with the Cloud Servers API, and discard the fallback/original image.

Returns true if the API call succeeds.

  >> server.confirm_resize!
  => true

Takes a snapshot of the server and creates a server image from it. That image can then be used to build new servers. The snapshot is saved asynchronously. Check the image status to make sure that it is ACTIVE before attempting to perform operations on it.

A name string for the saved image must be provided. A new CloudServers::Image object for the saved image is returned.

The image is saved as a backup, of which there are only three available slots. If there are no backup slots available, A CloudServers::Exception::CloudServersFault will be raised.

  >> image = server.create_image("My Rails Server")
  =>

Deletes the server from Cloud Servers. The server will be shut down, data deleted, and billing stopped.

Returns true if the API call succeeds.

  >> server.delete!
  => true

Removes the existing backup schedule for the server, setting the backups to disabled.

Returns true if the API call succeeds.

  >> server.disable_backup_schedule!
  => true

Returns a new CloudServers::Flavor object for the flavor assigned to this server.

  >> flavor = server.flavor
  => #<CloudServers::Flavor:0x1014aac20 @name="256 server", @disk=10, @id=1, @ram=256>
  >> flavor.name
  => "256 server"

Returns a new CloudServers::Image object for the image assigned to this server.

  >> image = server.image
  => #<CloudServers::Image:0x10149a960 ...>
  >> image.name
  => "Ubuntu 8.04.2 LTS (hardy)"

Makes the actual API call to get information about the given server object. If you are attempting to track the status or project of a server object (for example, when rebuilding, creating, or resizing a server), you will likely call this method within a loop until the status becomes "ACTIVE" or other conditions are met.

Returns true if the API call succeeds.

 >> server.refresh
 => true

Sends an API request to reboot this server. Takes an optional argument for the type of reboot, which can be "SOFT" (graceful shutdown) or "HARD" (power cycle). The hard reboot is also triggered by server.reboot!, so that may be a better way to call it.

Returns true if the API call succeeds.

  >> server.reboot
  => true

Sends an API request to hard-reboot (power cycle) the server. See the reboot method for more information.

Returns true if the API call succeeds.

  >> server.reboot!
  => true

Takes the existing server and rebuilds it with the image identified by the imageId argument. If no imageId is provided, the current image will be used.

This will wipe and rebuild the server, but keep the server ID number, name, and IP addresses the same.

Returns true if the API call succeeds.

  >> server.rebuild!
  => true
refresh()

Alias for populate

Resizes the server to the size contained in the server flavor found at ID flavorId. The server name, ID number, and IP addresses will remain the same. After the resize is done, the server.status will be set to "VERIFY_RESIZE" until the resize is confirmed or reverted.

Refreshes the CloudServers::Server object, and returns true if the API call succeeds.

  >> server.resize!(1)
  => true

After a server resize is complete, calling this method will reject the resized server with the Cloud Servers API, destroying the new image and replacing it with the pre-resize fallback image.

Returns true if the API call succeeds.

  >> server.confirm_resize!
  => true

Share IP between servers in Shared IP group. Takes a hash of the form: {:sharedIpGroupId => "1234", :ipAddress => "67.23.10.132", :configureServer => false} as an argument. The :sharedIpGroupId key is required. The :ipAddress key is required. The :configureServer key is optional and defaults to false.

  >> server.share_ip(:sharedIpGroupId => 100, :ipAddress => "67.23.10.132")
  => true

Unshare an IP address. Takes a hash of the form: {:ipAddress => "67.23.10.132"} as an argument. The :ipAddress key is required.

  >> server.unshare_ip(:ipAddress => "67.23.10.132")
  => true

Updates various parameters about the server. Currently, the only operations supported are changing the server name (not the actual hostname on the server, but simply the label in the Cloud Servers API) and the administrator password (note: changing the admin password will trigger a reboot of the server). Other options are ignored. One or both key/value pairs may be provided. Keys are case-sensitive.

Input hash key values are :name and :adminPass. Returns true if the API call succeeds.

  >> server.update(:name => "MyServer", :adminPass => "12345")
  => true
  >> server.name
  => "MyServer"

[Validate]