Note: Please go to docs.rightscale.com to access the current RightScale documentation set. Also, feel free to Chat with us!
Home > Guides > RightScale API 1.0 > RightScale API 1.0 Examples > Server Arrays > Create a Server Array

Create a Server Array

Creating a Server Array requires quite a few mandatory parameters. Additionally, there are several optional parameters that you might find useful. The example below includes both mandatory and optional parameters. It should help you figure out the complexities of this API call. As always, you can use rdoc to help determine the correct RightScale API call.

Curl Example

curl -H 'X-API-VERSION:1.0' -b <./mySavedCookies> --request POST 
-d 'cloud_id=1' 
-d 'server_array[nickname]=apiarrayuseast3' 
-d 'server_array[description]=apiarraydesc' 
-d 'server_array[deployment_href]=https://my.rightscale.com/api/acct/1234/deployments/21071' 
-d 'server_array[array_type]=alert' 
-d 'server_array[server_template_href]=https://my.rightscale.com/api/acct/1234/ec2_server_templates/22837' 
-d 'server_array[ec2_security_groups_href]=https://my.rightscale.com/api/acct/1234/ec2_security_groups/73684' 
-d 'server_array[ec2_ssh_key_href]=https://my.rightscale.com/api/acct/1234/ec2_ssh_keys/140658' 
-d 'server_array[active]=true' 
-d 'server_array[elasticity][min_count]=0' 
-d 'server_array[elasticity][max_count]=4' 
-d 'server_array[elasticity][decision_threshold]=52' 
-d 'server_array[parameters][SYS_TZINFO]=text:UTC' 
-d 'server_array[parameters][MON_PROCESSES]=text:collectd java' https://my.rightscale.com/api/acct/1234/server_arrays

Because this particular example is quite involved, it is included below in multi-line format for readability sake.

curl -H 'X-API-VERSION:1.0' -b <./mySavedCookies> --request POST 
-d 'cloud_id=1' 
-d 'server_array[nickname]=apiarrayuseast3' 
-d 'server_array[description]=apiarraydesc' 
-d 'server_array[deployment_href]=https://my.rightscale.com/api/acct/1234/deployments/21071' 
-d 'server_array[array_type]=alert' 
-d 'server_array[server_template_href]=https://my.rightscale.com/api/acct/1234/ec2_server_templates/22837' 
-d 'server_array[ec2_security_groups_href]=https://my.rightscale.com/api/acct/1234/ec2_security_groups/73684' 
-d 'server_array[ec2_ssh_key_href]=https://my.rightscale.com/api/acct/1234/ec2_ssh_keys/140658' 
-d 'server_array[active]=true' -d 'server_array[elasticity][min_count]=0' 
-d 'server_array[elasticity][max_count]=4' 
-d 'server_array[elasticity][decision_threshold]=52' -d 'server_array[parameters][SYS_TZINFO]=text:UTC' 
-d 'server_array[parameters][MON_PROCESSES]=text:collectd java' https://my.rightscale.com/api/acct/1234/server_arrays

Notice that this command specifies several optional parameters rather than omitting them and using the default values. For example, the elasticity parameters that set:

  • min count
  • max count
  • decision threshold

Bash Shell Script using Curl Example

#! /bin/bash -ex
#
# This is a template for use testing API functions.
# It relies on a file called user-details.sh to pull in the credentials. This file should contain similar to the following:
#
#USER="user.name@company.com"
#PASSWORD="MySecurePassword"
#ACCT="0000"
#

# This file should setup variables containing the username and password
source ./user-details.sh

# This line sets up the login cookies
curl -c <./mySavedCookies> -u "$USER:$PASSWORD" https://my.rightscale.com/api/acct/$ACCT/login?api_version=1.0

curl -b <./mySavedCookies> -X POST -H 'X-API-VERSION:1.0' \
  -d "cloud_id=2" \
  -d "server_array[nickname]=My Test Array tags set via api" \
  -d "server_array[description]=A test array where the voter tags are set via the api" \
  -d "server_array[deployment_href]=https://my.rightscale.com/api/acct/$ACCT/deployments/109926" \
  -d "server_array[array_type]=alert" \
  -d "server_array[ec2_security_groups_href]=https://my.rightscale.com/api/acct/$ACCT/clouds/2/ec2_security_groups/49346" \
  -d "server_array[server_template_href]=https://my.rightscale.com/api/acct/$ACCT/server_templates/122881" \
  -d "server_array[ec2_ssh_key_href]=https://my.rightscale.com/api/acct/$ACCT/clouds/2/ec2_ssh_keys/203982" \
  -d "server_array[voters_tag]=my-test-vote" \
  -d "server_array[elasticity][max_count]=5" \
  -d "server_array[elasticity][min_count]=1" \
  -d "server_array[elasticity][resize_up_by]=2" \
  -d "server_array[elasticity][resize_down_by]=1" \
  -d "server_array[elasticity][resize_calm_time]=10" \
  -d "server_array[elasticity][decision_threshold]=51" \
  -d "server_array[active]=false" \
"https://my.rightscale.com/api/acct/$ACCT/server_arrays"

 

You must to post a comment.
Last modified
09:49, 20 May 2014

Tags

This page has no custom tags.

Classifications

This page has no classifications.

Announcements

None


© 2006-2014 RightScale, Inc. All rights reserved.
RightScale is a registered trademark of RightScale, Inc. All other products and services may be trademarks or servicemarks of their respective owners.