Returning Customers — Login
Call 1.866.720.0208 or contact us
Sometimes the best way to learn is by studying some real world examples to see how things work and hopefully understand how you can apply it for your own purposes. The examples below cover some common use cases of the RightScale API and if you're savvy, you'll also be able to deconstruct them to extract specific code snippets for accomplishing more specific tasks.
The examples are written in Bourne shell or Bash. RestConnection examples are also available.
All the Bash/cURL examples in this section resided in rs_api_examples. Each example sources configuration from ~/.rightscale, logs into the API then performs the required API calls.
For RightScale Servers and Server Array instances, import the Install & configure rs_api_examples RightScript from the MultiCloud Marketplace.
Add this to your ServerTemplates or use as an Any Script. Inputs are provided for your RightScale credentials (skip the configuration section below).
You can get started within minutes by importing the RightScale/EC2 API Toolbox from the MultiCloud Marketplace, adding it to a deployment, filling in the missing inputs for your credentials, then launching the server. Once operational, you'll find that each command in the package, e.g. rs-login.sh is available in the shell's path.
This is ideal for any unix-like desktop or virtual machine that is not attached to RightScale.
#!/bin/sh -e install_dir="$HOME/bin" # non-root #install_dir=/usr/bin # root mkdir -p "$install_dir" cd /tmp git clone git://github.com/flaccid/rs_api_examples.git cp -vR /tmp/rs_api_examples/bin/* "$install_dir"/ chmod +x "$install_dir"/rs-*.sh rm -Rf /tmp/rs_api_examples
Add to user's shell profile
for f in "$HOME"/{.bash_profile,.bash_login,.profile}; do
if [[ -f $f ]]; then
echo "PATH+=':$install_dir'" >> "$f"; break;
fi
done
Or, add to current shell path
PATH+=":$install_dir"
rs-config-api.sh # <follow the prompts>
Note, your RightScale account ID can be found after 'acct/' in URLs when browsing my.rightscale.com, e.g. https://my.rightscale.com/acct/1234/dashboard;overview.
#!/bin/sh -e rs_api_version=1.0 rs_api_account_id=1234 rs_api_user=john@smith.com rs_api_password=foobar mkdir -p "$HOME/.rightscale" cat <<EOF> "$HOME/.rightscale/rs_api_config.sh" rs_api_version=$rs_api_version rs_api_cookie="$HOME/.rightscale/rs_api_cookie.txt" EOF cat <<EOF> "$HOME/.rightscale/rs_api_creds.sh" rs_api_account_id=$rs_api_account_id rs_api_user="$rs_api_user" rs_api_password="$rs_api_password" EOF
rs-login.sh
rs-switch-accounts.sh 1234 # where 1234 is the account ID