Adapter request and response for the Script adapter


The Script adapter does not use an action. You can include a <script> element that contains the entire script to be executed, or a <script-path> element that contains the path and the name of the script to be executed. When you use a context item as an input for an adapter request, you must enclose the adapter request in the <request-data> elements. However, when you create a static request, <request-data> is not required and the adapter request starts with the <adapterName-adapter-request> element.

Warning

Note

Starting with the 20.12.02 release, the Script adapter can also execute a request when the adapter is enabled on a peer that is compliant with the Internet Protocol version 6 (IPv6).

BMC recommends that you do not include empty elements in the adapter request because they might cause errors. The following table describes the elements of a Script adapter request elements.The [confluence_table-plus] macro is a standalone macro and it cannot be used inline.
 

The following figure shows an XML template for the Script adapter request with the <script> element.

XML template of the Script adapter request with the <script> element

<script-request>
 <script-type></script-type>
 <parameters></parameters>
 <return-values></return-values>
 <script></script>
</script-request>

The following figure shows an XML template for the Script adapter request with the <script-path> element.

XML template of the Script adapter request with the <script-path> element

<script-request>
 <script-type></script-type>
 <parameters></parameters>
 <return-values></return-values>
 <script-path></script-path>
</script-request>

The following figure shows an XML sample of the Script adapter request with the <script> element as Jython. Use the adapter request XML when you create a custom process by using the Call Adapter activity in BMC Atrium Orchestrator Development Studio.

XML sample of the Script adapter request with the <script> element as Jython

<script-request>
 <script-type>Jython</script-type>
 <parameters>
   <a>3</a>
   <b>4</b>
   <d>5</d>
   <e>7</e>
 </parameters>
 <return-values>
   <value>c</value>
   <value>f</value>
 </return-values>
 <script><![CDATA[c=a+b;f=d+e]]></script>
</script-request>

The following figure shows an XML sample of the Script adapter request with the <script> element as Perl. Use the adapter request XML when you create a custom process by using the Call Adapter activity in BMC Atrium Orchestrator Development Studio.

XML sample of the Script adapter request with the <script> element as Perl

<script-request>
 <script-type>Perl</script-type>
 <parameters>
   <var1>This is a test</var1>
 </parameters>
 <return-values>
   <value>out</value>
 </return-values>
 <script><![CDATA[($out)=$var1=~/\w+ \w+ \w+ (\w+)/;]]></script>
</script-request>

The following figure shows an XML sample of the Script adapter request with the <script-path> element that contains the path and the name of the script to be executed. Use the adapter request XML when you create a custom process by using the Call Adapter activity in BMC Atrium Orchestrator Development Studio.

XML sample of the Script adapter request with <script-path> element

<script-request>
 <script-type>Jython, Perl or Ruby</script-type>
 <parameters>
   <a>3</a>
   <b>4</b>
   <d>5</d>
   <e>7</e>
 </parameters>
 <return-values>
   <value>c</value>
   <value>f</value>
 </return-values>
 <script-path>/usr/scripts/named_script</script-path>
</script-request>

The following figure shows an XML sample of the Script adapter request when the adapter supports Language Enablement (LE) and uses Jython scripts.

XML sample of the Script adapter request when the adapter supports LE and uses Jython scripts

ScriptLE_JythonlRequest.gif

The following figure shows an XML sample of the Script adapter request when the adapter supports LE and uses Perl scripts.

XML sample of the Script adapter request when the adapter supports LE and uses Perl scripts

ScriptLE_PerlRequest.gif

The Script adapter returns an adapter response that contains return values specified in the adapter request. The attribute for each value specifies the data type. The following table describes the elements of the Script adapter response.The [confluence_table-plus] macro is a standalone macro and it cannot be used inline.

The following figure shows an XML sample for Script adapter response with the <script> element as Jython.

XML sample of the Script adapter response with the script element as Jython 

<return-values>
 <c type="scalar">7</c>
 <f type="scalar">12</f>
</return-values>

The following figure shows an XML sample for Script adapter response with the <script> element as Perl.

XML sample of the Script adapter response with the script element as Perl

<return-values>
 <out type="scalar">test</out>
</return-values>

The following figure shows an XML sample of the Script adapter response when the adapter supports LE and uses Jython scripts.

XML sample of the Script adapter response when the adapter supports LE and uses Jython scripts

JythonREsponse.gif

The following figure shows an XML sample of the Script adapter request when the adapter supports LE and uses Perl scripts.

XML sample of the Script adapter response when the adapter supports LE and uses Perl scripts

Perl_Response.gif

The following figure shows an XML sample of the Script adapter request with the <script> element as Ruby, with scalar variables. Use the adapter request XML when you create a custom process by using the Call Adapter activity in BMC Atrium Orchestrator Development Studio. 

XML sample of the Script adapter request with the <script-type> element as Ruby

<script-request>
<script-type>Ruby</script-type>
<parameters>
 <a type="scalar-int">10</a>
 <b type="scalar-int">20</b>
 <d type="scalar-int">30</d>
 <e type="scalar-int">40</e>
</parameters>
<return-values>
<value>c</value>
<value>f</value>
</return-values>
<script><![CDATA[$c=$a+$b;$f=$d+$e]]></script>
</script-request>

The following figure shows an XML sample of the Script adapter response for Ruby script.

Adapter response for the Ruby script with scalar variables

[oo=
<return-values>
 <c type="scalar">30</c>
 <f type="scalar">70</f>
</return-values>

The following figure shows an XML sample of the adapter request for the Ruby script with the list variables.

XML sample of the Script adapter request with the list variables for Ruby

 <script-request>
<script-type>Ruby</script-type>
<parameters>
<servers type="array-string">
<value>www.gmail.com</value>
<value>www.yahoo.com</value>
<value>www.runbox.com</value>
</servers>
</parameters>
<return-values>
<value type="array">out</value>
</return-values>
<script><![CDATA[topTwo = [$servers[0],$servers[1]]; $out = topTwo]]></script>
<!-- <script-path>target/test-classes/RubyArray.rb</script-path> -->
</script-request>

 

The following figure shows the adapter response for Ruby script with list variables.

Adapter response for the Ruby script with list variables

[oo=
<return-values>
 <out type="array">
   <value>www.gmail.com</value>
   <value>www.yahoo.com</value>
 </out>
</return-values>]

The following figure shows an XML sample of the adapter request for the Ruby script with the map variables.

XML sample of the Script adapter request with the map variables for Ruby

<script-request>
<script-type>Ruby</script-type>
<parameters>
<var3 type="map-string">
<value key="1">"Automation"</value>
<value key="2">"Automation Test"</value>
<value key="3">"Script Adapter Automation"</value>
</var3>
</parameters>
<return-values>
<value>out</value>
</return-values>
<script><![CDATA[$out=$var3['1'];]]></script> 
</script-request>

The following figure shows the adapter response for Ruby script with map variables.

Adapter response for the Ruby script with map variables

[tt=
<return-values>
 <out type="scalar">"Automation"</out>
</return-values>]

 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*

BMC Atrium Orchestrator Content 20.16.02