Automic Workload Automation

 View Only
  • 1.  workflow do while

    Posted Jan 13, 2020 09:29 AM
    Hi all,

    I have to monitor the end of a task via API REST.

    I can test the task and put its status in a variable.

    But I would need to be able to run this control task until the launched task is finished.

    I would actually need a worflow while that doesn't exist....

    Any idea how best to do that?

    Thanx


  • 2.  RE: workflow do while

    Posted Jan 13, 2020 01:22 PM
    @kay.koll provided me with a PowerShell script that uses the API REST to monitor a UC4 task until it finishes.  Is this the sort of solution you are searching for? ​​​​

    ------------------------------
    Pete
    ------------------------------



  • 3.  RE: workflow do while

    Posted Jan 13, 2020 05:46 PM
    Would an Event.DB do the trick?

    I haven't tried this, but I believe you could select your status variable from dual, compare it, and rerun your task until you got the result you wanted...?

    ------------------------------
    Reed Byers
    Programmer/Analyst
    Oregon State University
    ------------------------------



  • 4.  RE: workflow do while

    Broadcom Employee
    Posted Jan 14, 2020 01:57 AM
    it is much simpler.
    The REST call which executes your Task returns the Automic runid. Use this RunID in a follow up call to check the status of the Task execution. You have to check periodically the Task status until it has finished.  You find all details in the REST documentation.
    I could send you a PowerShell example which does this. Send me a private message.

    ------------------------------
    Sr. Solution Architect
    Broadcom
    ------------------------------



  • 5.  RE: workflow do while

    Posted Jan 14, 2020 02:14 AM
    "You have to check periodically the Task status until it has finished. "
    That's exactly my problem ! I'll try to be clearer with my poor English....

    I have a job that is executed via a WEB API command (on another system than AE).
    I can only control the end of this job through another WEB API.

    So I have to run this control WEB API several times to know when the job is finished.

    Hence my question how can I run this job until I have the expected value?
    I started working on an event time but it forces me to script to kill the event when the right value is found. I don't find it very clean.

    I hope I made myself clearer! :)


  • 6.  RE: workflow do while

    Broadcom Employee
    Posted Jan 14, 2020 02:51 AM
    Sorry, I am not sure if I understand you correctly.  Just to make sure. Your WEB API uses REST ?

    Let me describe how to execution and check Task status
    Execute an Automic Job/Workflow
    content-typeapplication/json
    AuthorizationBasic <username> <password>

    {
        "object_name""JOBS.10.ASYNC.LONG.RUNNER"  
    }

    It returns 
    { "run_id": 1091008 }

    In order to retrieve the Job Status you to call
    content-typeapplication/json
    AuthorizationBasic <username> <password>

    {
    }

    It returns following status information
    {
      "name": "JOBS.10.ASYNC.LONG.RUNNER",
      "type": "JOBS",
      "queue": "QUEUE.DATABASE",
      "run_id": 1086005,
      "status": 1550,
      "status_text": "Active",
      "activation_time": "2020-01-14T07:38:02Z",
      "start_time": "2020-01-14T07:38:02Z",
      "agent": "WIN01",
      "platform": "WINDOWS",
      "parent": 0,
      "user": "<user>",
      "estimated_runtime": 22,
      "title": "10 Ping - Waiting",
      "alias": "JOBS.10.ASYNC.LONG.RUNNER"
    }

    Check for the 'Status' code.  The 'status' code of a running Automic Job  lower 1572 and not 1701.

    Alternatively you could create in Automic a Job which informs your solution that the Automic Workflow has ended. You have to add this Job as the last task in your Automic Workflow,

    ------------------------------
    Sr. Solution Architect
    Broadcom
    ------------------------------



  • 7.  RE: workflow do while

    Posted Jan 14, 2020 03:25 AM
    My problem is not how to query my WEB API (which is not AE's) but how to query it on a regular basis until the expected result.

    It could be any other one job asynchronous not necessarily a WEB API.



  • 8.  RE: workflow do while
    Best Answer

    Posted Jan 14, 2020 11:58 AM
    We have a group that does exactly this.  They kick off their REST process and then have a second job that checks the status of that process and if still running it returns TRUE in a variable.  It will then check in the PostConditions the status of that variable and if it is still TRUE, it will restart the job after 5 minutes.  Once it sees the status as FALSE, it will then end.  

    In the screenshot below, they also check the status of the job to make sure it runs as expected and other things, but the important section is highlighted.




  • 9.  RE: workflow do while

    Posted Jan 14, 2020 03:41 AM
    Good idea I didn't know that this object could also control automic variables
    I'm gonna try to do something with that.!


  • 10.  RE: workflow do while

    Posted Jan 15, 2020 06:59 AM
    To stop an event properly when a condition is met you can use something like this :

    :IF <condition ok>
    :    SET &cancelid# = CANCEL_UC_OBJECT( &$ACTIVATOR_RUNID#,"ENDED_OK")
    :ENDIF

    Condition is whatever you need to test, variable value, status of an object, return code of a job, value of an SQLI variable, etc ...

    With this the event ends normally and can trigger a successor without generating an error. If condition is not met (your job is not finished), event run a new cycle and do the check once more and so on. Just eventually have an exit condition of the event at some point but this time in error if the condition is not met after a defined period  i.e.

    Regards.

    Alain