Executing Jython scripts


The following table describes the adapter request elements for executing Jython scripts.

Adapter request elements for executing Jython scripts

Element

Definition

Required

<command>

Contains the name of the Jython script to execute

This element requires the executable-type attribute with a value of jython. Use the script-directory attribute to specify the directory path containing the Jython script files. You can also use this script-directory attribute to override the {{<script-directory> element in the adapter configuration.

Do not include spaces in the script directory path. The script directory must exist on the peer where the adapter is enabled and the script must have executable permissions.

Yes

<user-role>

Specifies the user role for executing the Jython script

This element can be used to override the <default-user-role> element in adapter configuration.

No

The following figure shows a sample adapter request for executing a Jython script:


<bladelogic-request>
 <request-data>
    <command executable-type="jython">depotgrp_getdbkey_args.jy</command>
 </request-data>
</bladelogic-request>

 

The following figure illustrates the adapter response for the Jython script:


<bladelogic-response>
 <metadata>
   <status>success</status>
 </metadata>
 <targets-output>
    <target-output>
      <metadata>
        <os-id>Windows 2003</os-id>
        <os-version>5.2</os-version>
        <os-arch>x86</os-arch>
        <status>success</status>
      </metadata>
      <commands-output>
        <command-output>
             <metadata>
               <command>C:\"Program Files"\BladeLogic\OM\bin\bljython.bat c:\demo\depotgrp_getdbkey_args.jy"</command>
               <line-count>1</line-count>
               <execution-milliseconds>4843</execution-milliseconds>
               <exit-code>0</exit-code>
               <status>success</status>
             </metadata>
             <output>
               <line index="1">DBKey:SBLGroupKey:1000002</line>
             </output>
        </command-output>
      </commands-output>
    </target-output>
 </targets-output>
</bladelogic-response>

The following figure illustrates another sample adapter request for executing a Jython script:


<bladelogic-request>
   <command executable-type="jython" timeout-secs="300" script-directory="/data/">test.jy</command>
</bladelogic-request>

 

The following figure shows the adapter response for the Jython script execution:


<bladelogic-response>
 <metadata>
   <status>success</status>
 </metadata>
 <targets-output>
   <target-output>
     <metadata>
       <os-id>Linux</os-id>
       <os-version>2.6.9-67.ELsmp</os-version>
       <os-arch>i386</os-arch>
       <status>success</status>
     </metadata>
     <commands-output>
       <command-output>
         <metadata>
           <command>/opt/bmc/BladeLogic/8.0/NSH/bin/bljython "/data1/test.jy"</command>
           <line-count>1</line-count>
           <execution-milliseconds>32</execution-milliseconds>
           <exit-code>0</exit-code>
           <status>success</status>
         </metadata>
         <output>
           <line index="1">ASP2</line>
         </output>
       </command-output>
     </commands-output>
   </target-output>
 </targets-output>
</bladelogic-response>