RightScale API Gem

A client library for the RightScale API.

RightScale's API Docs

Usage Examples

Stopping a Server

RightScaleAPI. user, pass
 = RightScaleAPI::Account.get id
foo_server = .servers.find {|s| s.nickname == 'foo'}
foo_server.stop

Spinning up a new server with an elastic ip associated at launch

RightScaleAPI. user, pass
 = RightScaleAPI::Account.get id

ip = .create_ec2_elastic_ip :nickname => 'foo'

foo_template = .server_templates.find {|s| s.nickname == 'foo template'}
foo_deployment = .deployments.find {|d| d.nickname == 'foo deployment'}
foo_security_group = .ec2_security_groups.find { |s| s.aws_group_name == 'foo security group' }

#since there is no index for ssh keys, you need to find their id through the UI and get them directly(ugh).
foo_ssh_key =  .get_ec2_ssh_key("1234567890")

server = .create_server :nickname => 'foo',
              :server_template => foo_template,
          :deployment => foo_deployment,
          :ec2_ssh_key => foo_ssh_key,
          :ec2_security_groups => foo_security_group

#we do this as an update, because rightscale's api doesn't let you set this on create (as of May 2010)
server.update :associate_eip_at_launch => true, 
              :ec2_elastic_ip => ip
server.start