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

icon_rs_api_client_v1.png

Table of Contents

right_api_client

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 = 'greg.doe@example.com'         # 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 = RightApi::Client.new(:email => 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.

 

screen-server-alloc_v1.png

You must to post a comment.
Last modified
15:20, 6 Oct 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.