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 > Instances > List Inputs for Current and Next Instance

List Inputs for Current and Next Instance

List all the Inputs for both the "current" and "next" instance.  Capture the inputs to an XML file for later comparison.

icon_curl_v1.png   icon_powershell_v1.png

Table of Contents

 

Curl

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

Example Call

Note:  Two invokations of the API.  XML output saved in a file named <ThisScriptName>_Current.xml and <ThisScriptName>_Next.xml

#!/bin/sh -e
CLOUD="2112"
CURRENT="734PUMJGR7QNF"          # Set Current instance ID.  Get from the API, listing/showing a Server or Instance.
NEXT="B469CS55K5VRQ"             # Set the Next instance ID.  Also obtained from the API.
curl -i -H X_API_VERSION:1.5 -b mycookie \
-X GET https://my.rightscale.com/api/clouds/$CLOUD/instances/$CURRENT/inputs.xml > $0_Current.xml
curl -i -H X_API_VERSION:1.5 -b mycookie \
-X GET https://my.rightscale.com/api/clouds/$CLOUD/instances/$NEXT/inputs.xml > $0_Next.xml

Sample Output

Note:  The example script above saves all output to an XML file.  A sample output file is shown below (without HTTP headers).

<?xml version="1.0" encoding="UTF-8"?>
<inputs>
  <input>
    <value>text:any</value>
    <name>sys_firewall/rule/ip_address</name>
  </input>
  <input>
    <value>ignore:$ignore</value>
    <name>rightscale/process_match_list</name>
  </input>
  <input>
    <value>text:tcp</value>
    <name>sys_firewall/rule/protocol</name>
  </input>
  <input>
    <value>ignore:$ignore</value>
    <name>logging/remote_server</name>
  </input>
  <input>
    <value>ignore:$ignore</value>
    <name>rightscale/process_list</name>
  </input>                                                                      
  <input>
    <value>text:time.rightscale.com, ec2-us-east.time.rightscale.com, ec2-us-wes
t.time.rightscale.com</value>
    <name>sys_ntp/servers</name>
  </input>
  <input>
    <value>text:enable</value>
    <name>sys_firewall/rule/enable</name>
  </input>
  <input>
    <value>text:</value>
    <name>sys_firewall/rule/port</name>
  </input>
  <input>
    <value>text:/mnt/ephemeral/swapfile</value>
    <name>sys/swap_file</name>
  </input>
  <input>
    <value>text:0.5</value>
    <name>sys/swap_size</name>
  </input>
  <input>
    <value>text:UTC</value>
    <name>rightscale/timezone</name>
  </input>
  <input>
    <value>text:enabled</value>
    <name>sys_firewall/enabled</name>
  </input>
</inputs>

Supplemental

Some might find running a simple diff command on the Current and Next XML output files helpful.  The following will display differences in the Inputs for the Current and Next server instances.

$ diff Current.xml Next.xml           # Where "Current" and "Next" are the actual full file names to be compared.

Note that this will report differences in the date, runtime, cookie and request.  Perhaps not elegant, but that can be easily stripped away with the following command pipeline.  What is left are legitimate input differences.

$ diff Current.xml Next.xml | grep -v Date | grep -v Runtime | grep -v Cookie | grep -v Request

 

PowerShell

Prerequisite:  Example assumes you have previously authenticated and your session cookie for subsequent requests is in 'cookieContainer'.

Example Call - Current

#get cookie container from authentication $cookieContainer

$CLOUD = '2175'            # Set the Cloud ID
$CURRENT = '34NM8MNFGPE45' # Set Current instance ID. Get from the API,listing/showing a Server or Instance.
                           # For example, See the "List All Servers in a Deployment" example.
                           
$webRequest = [System.Net.WebRequest]::Create("https://my.rightscale.com/api/clouds/$CLOUD/instances/$CURRENT/inputs.xml")
$webRequest.Method = "GET"
$webRequest.CookieContainer = $cookieContainer
$webRequest.Headers.Add("X_API_VERSION", "1.5");

[System.Net.WebResponse] $listInstanceTypesResponse = $webRequest.GetResponse()
$listInstanceTypesResponseStream = $listInstanceTypesResponse.GetResponseStream()
$listInstanceTypesResponseStreamReader = New-Object System.IO.StreamReader -argumentList $listInstanceTypesResponseStream
[string]$listInstanceTypesResponseString = $listInstanceTypesResponseStreamReader.ReadToEnd()
write-host $listInstanceTypesResponseStrin

Sample Output - Current

<?xml version="1.0" encoding="UTF-8"?>
<inputs>
  <input>
    <value>text:UTC</value>
    <name>SYS_TZINFO</name>
  </input>
  <input>
    <value>env:RS_INSTANCE_UUID</value>
    <name>SERVER_UUID</name>
  </input>
  <input>
    <value>env:RS_SKETCHY</value>
    <name>SKETCHY</name>
  </input>
  <input>
    <value>ignore:$ignore</value>
    <name>MON_PROCESSMATCH</name>
  </input>
  <input>
    <value>ignore:$ignore</value>
    <name>MON_PROCESSES</name>
  </input>
  <input>
    <value>text:disable</value>
    <name>SECURITY_UPDATES</name>
  </input>
</inputs>

Example Call - Next

#get cookie container from authentication $cookieContainer

$CLOUD = '2175'        # Set the Cloud ID.
$NEXT ='3PLSU71PF2BJS' # Set the Next instance ID. Also obtained from the API.  See the List All Servers in a Deployment.

$webRequest = [System.Net.WebRequest]::Create("https://my.rightscale.com/api/clouds/$CLOUD/instances/$NEXT/inputs.xml")
$webRequest.Method = "GET"
$webRequest.CookieContainer = $cookieContainer
$webRequest.Headers.Add("X_API_VERSION", "1.5");

[System.Net.WebResponse] $listInstanceTypesResponse = $webRequest.GetResponse()
$listInstanceTypesResponseStream = $listInstanceTypesResponse.GetResponseStream()
$listInstanceTypesResponseStreamReader = New-Object System.IO.StreamReader -argumentList $listInstanceTypesResponseStream
[string]$listInstanceTypesResponseString = $listInstanceTypesResponseStreamReader.ReadToEnd()
write-host $listInstanceTypesResponseString

Sample Output - Next

Note that the Next Instance Input values have been altered from the Current Instance (previous example).  See sshd and crond in bold below.

<?xml version="1.0" encoding="UTF-8"?>
<inputs>
  <input>
    <value>env:RS_SKETCHY</value>
    <name>SKETCHY</name>
  </input>
  <input>
    <value>env:RS_INSTANCE_UUID</value>
    <name>SERVER_UUID</name>
  </input>
  <input>
    <value>ignore:$ignore</value>
    <name>MON_PROCESSMATCH</name>
  </input>
  <input>
    <value>text:sshd crond</value>
    <name>MON_PROCESSES</name>
  </input>
  <input>
    <value>text:disable</value>
    <name>SECURITY_UPDATES</name>
  </input>
  <input>
    <value>text:UTC</value>
    <name>SYS_TZINFO</name>
  </input>
</inputs>

You must to post a comment.
Last modified
15:09, 9 Oct 2013

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.