Skip to content

rackerlabs/ruby-cloudservers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

83 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rackspace Cloud Servers

Deprecation Notice

This project is deprecated. New projects should use fog instead.

Description

This is a Ruby interface into the Rackspace Cloud Servers service. Cloud Servers from The Rackspace Cloud put you in complete control of your hosting infrastructure. Each Cloud Server is a fully-customizable, pay by the hour, virtualized Windows or Linux server instance that you launch, maintain, and control with full root access.

*Note that in version 0.2.0 the connection style changed, from positional arguments to a hash of options*

Installation

This source is available on Github and the gem is available on Gemcutter. To install it, do

gem sources -a http://gemcutter.org/ (Newer Ruby Gems have this already)

sudo gem install cloudservers

To use it in a Rails application, add the following information to your config/environment.rb

config.gem "cloudservers"

Examples

See the class definitions for documentation on specific methods and operations.

require 'rubygems'
require 'cloudservers'

# Log into the Cloud Servers
cs = CloudServers::Connection.new(:username => USERNAME, :api_key => API_KEY)

# Log into the Cloud Servers UK
cs = CloudServers::Connection.new(:username => USERNAME, :api_key => API_KEY, :auth_url => CloudServers::AUTH_UK)

# Get a listing of all current servers
>> cs.servers
=> [{:name=>"RenamedRubyTest", :id=>110917}]

# Access a specific server
>> server = cs.server(110917)
>> server.name
=> "RenamedRubyTest"

# or...
server_manager.find(110917)

# See what type of server this is
>> server.flavor.name
=> "256 server"
>> server.image.name
=> "Ubuntu 8.04.2 LTS (hardy)"

# Soft-reboot the server
>> server.reboot
=> true

# Create a new 512MB CentOS 5.2 server.  The root password is returned in the adminPass method.
>> image = cs.get_image(8)
=> #<CloudServers::Image:0x1014a8060 ...>, status"ACTIVE"
>> image.name
=> "CentOS 5.2"
>> flavor = cs.get_flavor(2)
=> #<CloudServers::Flavor:0x101469130 @disk=20, @name="512 server", @id=2, @ram=512>
>> flavor.name
=> "512 server"
>> newserver = cs.create_server(:name => "New Server", :imageId => image.id, :flavorId => flavor.id)
=> #<CloudServers::Server:0x101433f08 ....
>> newserver.status
=> "BUILD"
>> newserver.progress
=> 0
>> newserver.adminPass
=> "NewServerMbhzUnO"
>> newserver.refresh
=> true
>> newserver.progress
=> 12

# Delete the new server
>> newserver.delete!
=> true

Authors

By H. Wade Minter <minter@lunenburg.org>, Mike Mayo <mike.mayo@rackspace.com>, and Dan Prince <dan.prince@rackspace.com>

License

See COPYING for license information.