jdafoe

Perl Script to call a Process

Discussion created by jdafoe on May 24, 2012
Hello,

I wanted a way to call a process using a script so I'd be able to more easily call Process Automation flows and integrate them into other products and scripts. The problem I found was that CA Process Automation flows can only be started externally using web service calls (there's no binary that I know of to start a flow). When you call a flow using a web service call, there is no indication on the state of the process (i.e. we don;t wait for a return). Return values are important to interpret if a process flow actually executed correctly. To add return values, I wrapped two web service calls into a script.

The script calls executeProcess and then loops for a timeout period calling getProcessStatus. By doing this, we're able to call our script and WAIT for a return code which could then be used to make decisions based on the return.

./run_flow.pl -H https://itpamurl.domain.local:443 -u username -p password -f "/TestProcess" -t 180 -r step1 - r step2

Process started: ROID=68360

step1: Process has executed step1 successfully
step2: Process has executed step2 successfully
State: Completed
Result: 1

This will:
==> Call /TestProcess on the Orchestrator
==> Loop continuosly if the process state returned from the check is still running ( Running, Waiting ). Loop ends when process state returned is known to be completed ( Completed, Failed, Aborted, etc ) or script reachs timeout ( 180 seconds ).
==> Search for and print the Process.step1 and Process.step2 variable values. These vars can now be used in the flow to print progress ( sort of like "STDOUT" in traditonal scripts so we get feedback from the flow )
==> Give us a return code based on the process state

We can also supress all output with -s, if all we care about is return code:

./run_flow.pl -H https://itpamurl.domain.local:443 -u username -p password -f "/TestProcess" -t 180 -s



PROCESS STATES / EXIT CODE MAPPING
---------------------------
# Completed

0
#
# Timeout:
# Running

4
# Queued


5
# Inactive (Waiting)
6
#

# Failed:
#
Failed

7
#
Aborted

8
#
Blocked
9
#
Suspended

10
#
# Unexpected State

11
#
# Script error (Invalid Parameters)
1
# Failed to start process

2
# Failed to check process

3


Keep in mind the script has only had limited testing done so use at your own risk. My intention is to maybe help someone else out if they need something similar and share with the community to hopefully expand on this!

James

Attachments

Outcomes