Note: Please go to to access the current RightScale documentation set. Also, feel free to Chat with us!
Home > Guides > RightScale API 1.5 > Examples > Server Array > Update the Datacenter Policy for a Server Array

Update the Datacenter Policy for a Server Array

Update the Datacenter Policy for a Server Array. This example illustrates how to define Server Allocation Policy settings (max and weight) individually for different datacenters.


Table of Contents


Example Call

The following example sets the maximum number of instances to 7 for the us-west-1a datacenter and to 3 for the us-west-1b datacenter. The instance allocation weighting is left unchanged at 50 percent for each datacenter. Note that the datacenter_href values used in the example are entered explicitly but can easily be queried and stored in a variable using a call similar to... @client.clouds(:id => 1).show.datacenters.index[0].show.href.

require 'rubygems'
require 'pp'                          # Require pretty print Ruby gem
require 'right_api_client'            # RightScale API client gem

user = ''         # Set user email address for using the Dashboard
acct = '1234'                         # Set the account ID
pass = 'SomePassword'                 # Set the password for the user.  Create client object so you can use the API.
@client = => user, :password => pass, :account_id => acct)
# Setup and authenticate above. Set and use additional variables below, display output, etc.
@client.server_arrays(:id => 244962003).show.update(:server_array => {:datacenter_policy => [{:weight=>'50.0', :datacenter_href=>'/api/clouds/3/datacenters/531RIVS8UVE2K', :max=>'7'},{:weight=>'50.0', :datacenter_href=>'/api/clouds/3/datacenters/5GQTD1L1BGD73', :max=>'3'}]})

Sample Output

The results of the example call above can be verified by examining the Info tab view for the server array in the dashboard as illustrated below.



You must to post a comment.
Last modified
15:20, 6 Oct 2014


This page has no custom tags.


This page has no classifications.



© 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.