_images/righteous.jpg

righteous: A Python Rightscale API/CLI

Release v0.2.1

righteous is a Python client implementation of the RightScale API for EC2 instance management.

https://secure.travis-ci.org/michaeljoseph/righteous.png

righteous provides an API and CLI to create, start/stop, delete, remove and introspect RightScale EC2 Servers. This library implements RightScale API 1.0 and has only been tested with EC2 instances using ServerTemplates and managed in a Deployment.

Configuration

Create a file called ~/.righteous with the following customised contents:

[auth]
username: username@domain.com
password: password
account_id: 123

[server-defaults]
default_deployment_id: 45623
ec2_security_groups_href: https://my.rightscale.com/api/acct/123/ec2_security_groups/789
ec2_availability_zone: us-east-1a
ec2_ssh_key_href: https://my.rightscale.com/api/acct/123/ec2_ssh_keys/998
cloud_id: 1
server_template_href: https://my.rightscale.com/api/acct/123/ec2_server_templates/74732
instance_type: m1.small
m1.small: https://my.rightscale.com/api/acct/123/ec2_server_templates/74732
m1.large: https://my.rightscale.com/api/acct/123/ec2_server_templates/117240

CLI

righteous
Interact with the RightScale Server API.

Usage:
  righteous [options] list
  righteous [options] create <environment> <instance-type> (<server-template-key>=<server-template-value>)...
  righteous [options] stop <environment>...
  righteous [options] status <environment>...
  righteous [options] delete <environment>...
  righteous --version

Options:
  -c FILE --config=FILE        Specify the configuration file location, default is ~/.righteous
  -v --verbose                 Show debug output
  -h --help                    Show this screen.

API

righteous.init(username, password, account_id, **kwargs)

Initialises righteous configuration

Parameters:
  • username – String of a Rightscale username
  • password – String of the user’s password
  • account_id – String of the Rightscale account_id
Params kwargs:

Key word arguments for additional configuration

righteous.login(username=None, password=None, account_id=None)

Logins to RightScale and stores the auth cookie for future requests

Parameters:
  • username – (optional) String representing the username to login with
  • password – (optional) String representing the password to login with
  • account_id – (optional) String of the Rightscale account_id
righteous.list_servers(deployment_id=None)

Lists servers in a deployment

Returns JSON

Parameters:deployment_id – (optional) String representing Deployment to list servers from
righteous.find_server(nickname)

Finds a server based on nickname

Parameters:nickname – (optional) String representing the nickname of the server to lookup
righteous.server_info(server_href, nickname=None)

Detailed server information

Parameters:
  • server_href – URL representing the server to query
  • nickname – (optional) String representing the nickname of the server
righteous.server_settings(server_href, nickname=None)

Current server settings

Parameters:
  • server_href – URL representing the server to query settngs from
  • nickname – (optional) String representing the nickname of the server
righteous.create_and_start_server(nickname, instance_type, create_server_parameters=None, server_template_parameters=None)

Creates and starts a server. Returns a tuple of operation status, href of the created, started server

Parameters:
  • nickname – String representing the nickname of the server
  • instance_type – String of the EC2 instance type
  • create_server_parameters – (optional) Dictionary of server creation parameters
  • server_template_parameters – (optional) Dictionary of ServerTemplate parameters
righteous.stop_server(server_href, nickname=None)

Stops a server.

Parameters:
  • server_href – URL representing the server to stop
  • nickname – (optional) String representing the nickname of the server
righteous.delete_server(server_href, nickname=None)

Deletes a server from RightScale

Parameters:
  • server_href – URL representing the server to delete
  • nickname – (optional) String representing the nickname of the server
Fork me on GitHub