Menu

STAF with cross platform capability

2015-06-04
2015-06-05
  • Deepshikha Masiwal

    Hi,

    I have a query regarding STAF capability on cross platform execution. Can STAF run on 2 different platforms like Windows and FREEBSD together?
    I am trying to trigger STAX job from windows machine and hit on FREEBSD platform. STAFProc is running on both the machines and trust level is also configured for either machines in STAF.cfg
    However, I am not able to ping the FREEBSD machine from Windows machine using STAF <ipaddress> ping ping command.
    Please suggest on the same.
    Thanks in advance.

     
  • Sharon Lucas

    Sharon Lucas - 2015-06-04

    Yes, STAF is designed for communication between systems on any of the operating systems supported by STAF.

    First, verify that the machines can communicate by doing a non-STAF ping from the FreeBSD syste to the Windows system and from the Windows system to the FreeBSD system?

    ping <ip-address or hostname>
    

    If they can't communicate, you need to first fix the network configuration of these systems before you can use STAF to communicate between the systems.

    If they can communicate over the network via a non-STAF PING, then what is the RC and error message from a STAF PING command (e.g. STAF <ip-address> PING PING)? If it is RC 16, see section "3.1.3 Explain RC 16 when attempting to send a STAF request to a remote machine" in the STAF FAQ at http://staf.sourceforge.net/current/STAFFAQ.htm#d0e934. It talks about possible issues such as a firewall is blocking communication via the STAF TCP/IP port and DNS configuration issues.

    Also, see section "3.1.4 Why can't my STAF machines communicate?" in the STAF FAQ at http://staf.sourceforge.net/current/STAFFAQ.htm#STAF%20machines%20can%27t%20communicate%20due%20to%20DNS%20issues

     
    • Deepshikha Masiwal

      Hi,

      Many thanks for your post. Our problem is solved now and we are able to ping via non-STAF and STAF over the network for both the machines. I had another query as I wanted to call .sh file lying on FREEBSD platform from Windows platform.
      Kindly suggest on the same as well.

      Many thanks.

       
  • Sharon Lucas

    Sharon Lucas - 2015-06-05

    You can use STAF's PROCESS service to do that. See section "8.13 Process Service" in the STAF User's Guide at http://staf.sourceforge.net/current/STAFUG.htm#HDRPROCSRV for more information.

    Note that your FreeBSD system would need to give STAF trust level 5 to the Windows system as a PROCESS START request requires trust level 5. You can do this by adding a line like the following to the /usr/local/staf/bin/STAF.cfg file on your FreeBSD system, replacing 9.99.999.999 with the IP address (or hostname) of your Windows system:

    SET TRUST LEVEL 5 MACHINE 9.99.999.999
    

    Or you can change the default trust level line in the STAF.cfg file to give trust level 5 by default to everyone. Note that whenever you change the STAF.cfg file you must shutdown STAF and restart STAFProc for the changes in the STAF.cfg file to take effect.

    Here's an example of a PROCESS START request that you could submit from your Windows system to run a shell script named /tests/MyTest.sh on your FREEBSD system and optionally wait for it to complete and return the stdout/stderr from the command:

    STAF freeBSD_IPAddr PROCESS START SHELL COMMAND "/tests/MyTest.sh" WAIT RETURNSTDOUT STDERRTOSTDOUT
    
     
  • Sharon Lucas

    Sharon Lucas - 2015-06-05

    To run your shell script on your FreeBSD system via a STAX job then you could write a STAX job that uses the <process> element to submit the PROCESS START request and submit a STAX EXECUTE request from your Windows system to do this. For example, if you have the STAX service registered on your Windows system and a STAX job named C:\tests\RunTest.xml on your Windows system, then you could submit a "STAF local STAX EXECUTE FILE C:/tests/RunTest.xml request" to run the STAX job, or use the STAX Monitor to run this STAX job.

    For example, here's a STAX job named RunTest.xml that runs a process on a specified system that you can customize to specify the IP address or hostname of your FreeBSD system and the shell script on the FreeBSD system that you want to run.

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <!DOCTYPE stax SYSTEM "stax.dtd">
    <stax>
      <defaultcall function="RunProcess" />
    
      <function name="RunProcess">
        <testcase name="'ShellScriptTest'">
          <sequence>
    
            <script>
              # Replace with IP address or hostname of your FreeBSD system
              machine = 'staf4g'
    
              # Replace with the location of your shell script
              command = '/tests/MyTest.sh'
            </script>
    
            <log message="1">
              'STAF %s PROCESS START SHELL COMMAND %s RETURNSTDOUT STDERRTOSTDOUT' % \
              (machine, command)
            </log>
    
            <process name="'Run Shell Script on %s' % (machine)">
              <location>machine</location>
              <command mode="'shell'">command</command>
              <stderr mode="'stdout'"/>
              <returnstdout/>
            </process>
    
            <if expr="RC == 0">
              <sequence>
                <tcstatus result="'pass'"/>
                <log message="1">
                  'Process Stdout/Stderr:\n%s' % (STAXResult[0][1])
                </log>
              </sequence>
              <else>
                <sequence>
                  <tcstatus result="'fail'"/>
                  <log message="1" level="'Error'">
                    'Process failed with RC=%s STAFResult=%s STAXResult=%s' % \
                    (RC, STAFResult, STAXResult)
                  </log>
                </sequence>
              </else>
            </if>
    
            <return>RC</return>
    
          </sequence>
        </testcase>
      </function>
    
    </stax>
    

    I attached a file containing this STAX job that you can download if desired.

    Here's the shell script named /tests/MyTest.sh on my FreeBSD system (staf4g) that this STAX job runs:

    # cat MyTest.sh
    #!/bin/sh
    echo "Start of MyTest.sh"
    echo "End of MyTest.sh"
    exit 0
    

    Here's an example of running this STAX job:

    C:\>STAF local STAX EXECUTE FILE C:\stax\RunTest.xml WAIT RETURNRESULT DETAILS
    Response
    --------
    {
      Job ID         : 6
      Start Date-Time: 20150605-10:22:09
      End Date-Time  : 20150605-10:22:19
      Status         : Normal
      Result         : 0L
      Job Log Errors : []
      Testcase Totals: {
        Tests : 1
        Passes: 1
        Fails : 0
      }
      Testcases      : [
        {
          Testcase Name   : ShellScriptTest
          Passes          : 1
          Fails           : 0
          Start Date-Time : 20150605-10:22:10
          Elapsed Time    : 00:00:09
          Starts          : 1
          Status Date-Time: 20150605-10:22:19
          Last Status     : pass
          Information     :
          Testcase Stack  : [
            ShellScriptTest
          ]
        }
      ]
    }
    

    And the STAX job generates a STAX Job User log (note the name of the log contains the Job ID of the STAX job provided in the output from the STAX EXECUTE request) and you can query to see what your STAX job logged via <log> elements, such as the process's stdout/stderr:

    C:\>STAF -verbose local LOG QUERY MACHINE {STAF/Config/MachineNickname} LOGNAME STAX_Job_6_User
    Response
    --------
    [
      {
        Date-Time: 20150605-10:22:10
        Level    : Info
        Message  : STAF staf4g PROCESS START SHELL COMMAND /tests/MyTest.sh RETURNSTDOUT STDERRTOSTDOUT
      }
      {
        Date-Time: 20150605-10:22:19
        Level    : Info
        Message  : Process Stdout/Stderr:
    Start of MyTest.sh
    End of MyTest.sh
    
      }
    ]
    
     
  • Sharon Lucas

    Sharon Lucas - 2015-06-05

    I attached the STAX job.

     

Log in to post a comment.