Adapter request and response for the SSH adapter
The SSH adapter does not use an action. You must leave the adapter's Action field blank when configuring the activity properties for a Call Adapter activity in BMC Atrium Orchestrator Development Studio.
To configure an adapter request for communicating with a host that is not defined in the adapter configuration, you can designate a dynamic target by assigning values for the required configuration elements. These elements work as a set. You cannot retrieve partial information from the configuration node. You can omit the <targets> block from the adapter request. If a <targets> block is not provided, the default target from the adapter configuration is used.
When you use a context item as an input for an adapter request, you must enclose the adapter request in <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.
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 an adapter request for the SSH adapter:
Elements of an adapter request for SSH adapter
The following figure shows a sample XML template for the SSH adapter request.
XML template of the SSH adapter request
<ssh-request>
<prompts>
<prompt name =""></prompt>
</prompts>
<targets>
<target name=""/>
<target>
<host></host>
<port></port>
<user-name></user-name>
<password encryption-type=""></password>
<prompt></prompt>
<verify-os></verify-os>
<read-buffer-size></read-buffer-size>
<timeout-secs></timeout-secs>
<known-hosts-config></known-hosts-config>
<allow-unknown-hosts></allow-unknown-hosts>
<preferred-pk-algorithm></preferred-pk-algorithm>
<establish-connection-timeout-secs></establish-connection-timeout-secs>
<network-environment></network-environment>
<line-termination></line-termination>
</target>
<target>
<host></host>
<port></port>
<user-name></user-name>
<private-key-file></private-key-file>
<pass-phrase encryption-type-""></pass-phrase>
<prompt></prompt>
<timeout-secs></timeout-secs>
<known-hosts-config></known-hosts-config>
<allow-unknown-hosts></allow-unknown-hosts>
<preferred-pk-algorithm></preferred-pk-algorithm>
<establish-connection-timeout-secs></establish-connection-timeout-secs>
<network-environment></network-environment>
<line-termination></line-termination>
</target>
</targets>
<commands>
<command prompt=""></command>
<command timeout-secs=""></command>
<command></command>
</commands>
</ssh-request>
The following figure shows an XML sample for the SSH adapter request. 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 SSH adapter request
<ssh-request>
<targets>
<target>
<host>10.128.248.97</host>
<user-name>user-name1</user-name>
<password encryption-type="Plain">password for user-name1</password>
<allow-unknown-hosts>true</allow-unknown-hosts>
<prompt>#</prompt>
<verify-os>false</verify-os>
<read-buffer-size>1024</read-buffer-size>
<port>22</port>
<connection>
<name>sshtarget_connection</name>
<terminate-on-exit>false</terminate-on-exit>
<connection-initialize-commands>
<command prompt="MYPROMPT $">export PS1="MYPROMPT $"</command>
<command prompt="MYPROMPT $">pwd</command>
<command prompt="MYPROMPT $">cd Desktop</command>
</connection-initialize-commands>
</connection>
</target>
</targets>
<prompts>
<prompt name="first">login:</prompt>
<prompt name="second">root@10.128.248.106's password:</prompt>
<prompt name="third">#</prompt>
</prompts>
<commands>
<command>hostname</command>
<command prompt="second" ignore-exit-code="true">ssh root@10.128.248.106</command>
<command prompt="third" ignore-exit-code="true">root@123</command>
<command prompt="third" ignore-exit-code="true">ls</command>
</commands>
</ssh-request>
The following figure shows an XML sample for the SSH adapter request using the <use-pseudo-terminal> command.
XML sample of the SSH adapter request with <use-pseudo-terminal> command
<ssh-request>
<targets>
<target>
<host>server1</host>
<port>22</port>
<user-name>user</user-name>
<password>abc</password>
<use-pseudo-terminal>true</use-pseudo-terminal>
</target>
</targets>
<commands>
<command>type testFile.txt</command>
</commands>
</ssh-request>
The following figure shows an XML sample of the SSH adapter with CharSet.
XML sample of the SSH adapter request with CharSet
<ssh-request>
<targets>
<target>
<host>server1</host>
<port>22</port>
<user-name>user</user-name>
<password encryption-type="Plain">abc</password>
<allow-unknown-hosts>true</allow-unknown-hosts>
<character-set>Shift_JIS</character-set>
</target>
</targets>
<commands>
<command>type testFile.txt</command>
</commands>
</ssh-request>
The SSH adapter returns an adapter response that contains the details for the command executed by the adapter request:
The following table describes the elements of an SSH adapter response.
Elements of an SSH adapter response
The following figure shows the adapter response for the SSH adapter.
XML sample of the SSH adapter response
<ssh-command-output>
<metadata>
<status>success</status>
</metadata>
<targets-output>
<target-output host="10.128.248.97">
<metadata>
<os-id>Linux</os-id>
<os-version>2.6.9-42.ELsmp</os-version>
<status>success</status>
</metadata>
<commands-output>
<command-output>
<metadata>
<command>hostname</command>
<line-count>2</line-count>
<execution-milliseconds>16</execution-milliseconds>
<exit-code>0</exit-code>
<status>success</status>
</metadata>
<output>
<line index="1">realops-linux.abc.com</line>
<line index="2">[root@realops-linux ~]#</line>
</output>
</command-output>
<command-output>
<metadata>
<command>ssh root@10.128.248.106</command>
<line-count>1</line-count>
<execution-milliseconds>297</execution-milliseconds>
<exit-code>9999</exit-code>
<status>success</status>
</metadata>
<output>
<line index="1">root@10.128.248.106's password:</line>
</output>
</command-output>
<command-output>
<metadata>
<command>root@123</command>
<line-count>3</line-count>
<execution-milliseconds>22062</execution-milliseconds>
<exit-code>9999</exit-code>
<status>success</status>
</metadata>
<output>
<line index="1">Last login: Tue Apr 20 12:35:32 2010 from 10.128.248.86</line>
<line index="2">-bash: REPO: command not found</line>
<line index="3">[root@realops-sshclient ~]#</line>
</output>
</command-output>
<command-output>
<metadata>
<command>ls</command>
<line-count>16</line-count>
<execution-milliseconds>172</execution-milliseconds>
<exit-code>9999</exit-code>
<status>success</status>
</metadata>
<output>
<line index="1">[00m[00manaconda-ks.cfg[00m [00mprofile413456623[00m</line>
<line index="2">[01;34mDesktop[00m [00mprofile425614260[00m</line>
<line index="3">[00minstall.log[00m [00mprofile615033302[00m</line>
<line index="4">[00minstall.log.syslog[00m [01;31mtelnet-server-0.17-26.EL3.3.i386.rpm[00m</line>
<line index="5">[01;34mjava[00m [01;31mvsftpd-2.0.1-8.el4.i386.rpm[00m</line>
<line index="6">[01;32mjdk-6u16-solaris-i586.sh[00m [00mzprofile1104250438[00m</line>
<line index="7">[01;32mjdk-6u16-solaris-sparc.sh[00m [00mzprofile1429689734[00m</line>
<line index="8">[01;32mjdk-6u16-solaris-sparcv9.sh[00m [00mzprofile1632425172[00m</line>
<line index="9">[00mprofile1064777096[00m [00mzprofile1760702416[00m</line>
<line index="10">[00mprofile1178790592[00m [00mzprofile1877235460[00m</line>
<line index="11">[00mprofile1379315196[00m [00mzprofile2053475337[00m</line>
<line index="12">[00mprofile1647775163[00m [00mzprofile437787547[00m</line>
<line index="13">[00mprofile1835270538[00m [00mzprofile478856458[00m</line>
<line index="14">[00mprofile2042636870[00m [00mzprofile667791972[00m</line>
<line index="15">[00mprofile2068878841[00m [00mzprofile861707713[00m</line>
<line index="16">[m[root@realops-sshclient ~]#</line>
</output>
</command-output>
</commands-output>
</target-output>
</targets-output>
</ssh-command-output>