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.5 > Examples > Server Array > Create Server Array

Create Server Array

Create a Server Array in a specified deployment.

Table of Contents

Curl

Prerequisite:  Example assumes you have previously authenticated, and your valid session cookie is in 'mycookie'.

Example Calls

Single Cloud and Datacenter

The following example will create a server array for a single cloud using a single default datacenter/zone. The script below should be copied and pasted into a Bash script file and made executable if needed (chmod +x /path/to/script.sh). You will want to replace the Deployment ID, ServerTemplate ID, Cloud ID, Instance Type ID, and MCI (MultiCloud Image) ID with the IDs from your own account.

 

Note:  A "\" character has been added to allow a single curl command to continue for several lines in the editor. This is for readability sake.  The shell will interpret the script's curl command as a single line.

#!/bin/sh -e
DEPLOYMENT="310625001"  # Deployment to add Server Array to
ST="246686001"          # Set the ServerTemplate the Server Array will be based on
CLOUD="232"            # Specify the Cloud to add the Server Array to
ITYPE="80"             # Set the Instance Type for this Sever Array, this cloud, ...
MCI="240699001"         # Set MultiCloud Image (MCI)
   
curl -i -H X_API_VERSION:1.5 -b mycookie -X POST \
-d server_array[name]=my_array_server \
-d server_array[description]=my_app_server_description \
-d server_array[deployment_href]=/api/deployments/$DEPLOYMENT \
-d server_array[array_type]=alert \
-d server_array[state]=disabled \
-d server_array[instance][server_template_href]=/api/server_templates/$ST \
-d server_array[instance][cloud_href]=/api/clouds/$CLOUD \
-d server_array[instance][multi_cloud_image_href]=/api/multi_cloud_images/$MCI \
-d server_array[elasticity_params][alert_specific_params][decision_threshold]=51 \
-d server_array[elasticity_params][bounds][min_count]=2 \
-d server_array[elasticity_params][bounds][max_count]=3 \
-d server_array[elasticity_params][pacing][resize_calm_time]=5 \
-d server_array[elasticity_params][pacing][resize_down_by]=1 \
-d server_array[elasticity_params][pacing][resize_up_by]=1 \
https://my.rightscale.com/api/server_arrays
Multiple Datacenters within a Single Cloud

The following example will create a server array for a single cloud using two datacenters for the server allocation policy. Each datacenter will accept a max of 3 instances with a 50% weight, and the total max for the array is 6 instances. The script below should be copied and pasted into a Bash script file and made executable if needed (chmod +x /path/to/script.sh). You will want to replace the Deployment ID, ServerTemplate ID, Cloud ID, Instance Type ID, MCI (MultiCloud Image) ID and Datacenter IDs with the IDs from your own account.

 

Note:  A "\" character has been added to allow a single curl command to continue for several lines in the editor. This is for readability sake. The shell will interpret the script's curl command as a single line.

#!/bin/sh -e

DEPLOYMENT="310625001"  # Deployment to add Server Array to
ST="246686001"          # Set the ServerTemplate the Server Array will be based on
CLOUD="232"            # Specify the Cloud to add the Server Array to
ITYPE="80"             # Set the Instance Type for this Sever Array, this cloud, ...
MCI="240699001"         # Set MultiCloud Image (MCI)
DC1="9GFSQIVUU642M"     # Set first datacenter for server allocation policy, see datacenters in API 1.5 reference for more info
DC2="2MNLNDTP253CB"     # Set second datacenter for server allocation policy, see datacenters in API 1.5 reference for more info

curl -v -i -H "X-API-VERSION:1.5" -b myCookie -X POST \
-d "server_array[name]=Test Array Multi-Datacenter" \
-d "server_array[description]=Testing Multiple datacenters in an array via API 1.5" \
-d "server_array[deployment_href]=/api/deployments/$DEPLOYMENT" \
-d "server_array[array_type]=alert" \
-d "server_array[state]=disabled" \
-d "server_array[instance][server_template_href]=/api/server_templates/$ST" \
-d "server_array[instance][cloud_href]=/api/clouds/$CLOUD" \
-d "server_array[instance][multi_cloud_image_href]=/api/multi_cloud_images/$MCI" \
-d "server_array[elasticity_params][alert_specific_params][decision_threshold]=51" \
-d "server_array[elasticity_params][bounds][min_count]=1" \
-d "server_array[elasticity_params][bounds][max_count]=6" \
-d "server_array[elasticity_params][pacing][resize_calm_time]=5" \
-d "server_array[elasticity_params][pacing][resize_down_by]=1" \
-d "server_array[elasticity_params][pacing][resize_up_by]=1" \
-d "server_array[datacenter_policy][][datacenter_href]=/api/clouds/$CLOUD/datacenters/$DC1" \
-d "server_array[datacenter_policy][][max]=3" \
-d "server_array[datacenter_policy][][weight]=50.0" \
-d "server_array[datacenter_policy][][datacenter_href]=/api/clouds/$CLOUD/datacenters/$DC2" \
-d "server_array[datacenter_policy][][max]=3" \
-d "server_array[datacenter_policy][][weight]=50.0" \
https://my.rightscale.com/api/server_arrays

Sample Output

Note: There is no XML/JSON content, just headers.

HTTP/1.1 201 Created
Server: nginx/1.0.15
Date: Mon, 19 Nov 2012 19:21:24 GMT
Content-Type: text/html; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
Status: 201 Created
Location: /api/server_arrays/214996001
X-Runtime: 528
X-Request-Uuid: 14936a5d6bd24baaae0d22ff7b16cede
Set-Cookie: rs_gbl=eNotkMuOgjAARf-la0n6AEpJZuEDFRRREZUVYdo62lhnUDqCxn8fTGZ3F_ecxXmCEvhAt6AHxA34T2Bu8gp8x3UxevVAzYGPiEOIgz3P7oGT6N4cUkcghC2CKbQQkthisOwWJogI5EmG7M5Xy3_WhfDNdnowGGfrH6VOKy2nw3k_XB3xdHefOkMaMa74YtKqx8LoUdXMImuQsVDBRT_kjTA2PrpV69XnUlOSXw9BoArdFttZss0y_jWA5rRMw-R3P5e5utBDXc7S8-RhNpjmh1E8ni_jrTbL82eUX4pxEB_tza7ScRKktyYhgu0y676vyiYKJDNcqPDjnaR5Jyk5_zaXGviUOfbr9QfiEVxu; domain=.rightscale.com; path=/; HttpOnly
Cache-Control: no-cache

See also

You must to post a comment.
Last modified
14:44, 29 Aug 2013

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.