ibm-cloudworkload-scheduler

How to use variables in the Application Lab interface to Workload Scheduler on Bluemix


I'm trying to use the Application Lab application on Bluemix's Workload Scheduler service but can't find any documentation on how to use it. Specifically, I need to run a RESTful URL once a day, with a timestamp of the previous run embedded in the URL. Creating variables in Application Lab seems pretty straightforward, but I can't figure out how to set or use them. Can someone point me in the right direction?


Solution

  • The update of the variables of the application lab via APIs is not yet available (it will be soon).

    There is another way of doing it that I can share with you. Follow these steps:

    Enable the cloud agent to run scripts

    You should open a ticket for that. By defaults the cloud agent is not enabled to run scripts but you can open a ticket to change this.

    Get the user credentials

    Open the service a take not of the user credentials. Click "Add credentials" if they are not present. enter image description here

    Open the Workload Editor

    The workload editor is a more powerful UI with respect to the Application Lab and enable complex scenarios.

    To open the Workload Designer, open the Application Lab, right click on a process and select "Launch Workload Designer".

    enter image description here

    Define the restful job

    Create a new restful job:

    enter image description here

    Then set the name and the workstations and check the flag "Variable resolution at runtime".

    enter image description here

    Then click on the "Action" pane and set the URI of the service. Add the ${TIMESTAMP} variable in the URI. For testing purposes I used this URI:

    http://echo.jsontest.com/title/ipsum/content/${TIMESTAMP}

    enter image description here

    Save this definition (use the floppy disk icon).

    Define the job that updates the variable

    Create an executable job:

    enter image description here

    Set the name, the workstation and the "Variable resolution at runtime" flag

    enter image description here

    Then open the "Task pane" and add the following in the script field:

    #/bin/sh -x
    #Set the following 3 variables from your credentials
    export USERNAME="xxxxxx@bluemix.net"
    export PASSWORD='xxxxxx' 
    export HOSTNAME=xxxxx.wa.ibmserviceengage.com
    
    #Replace "CC" with the letters of your tenant
    export VT=CCTIMESTAMP
    
    #MAIN STARTS HERE
    export TIMESTAMP=`date +%s`
    
    . /home/wauser/TWA/TWS/tws_env.sh
    
    echo "VARTABLE $VT MEMBERS TIMESTAMP \"$TIMESTAMP\" END" > /home/wauser/vt.txt
    
    composer -host $HOSTNAME  -protocol https -username "$USERNAME" -password $PASSWORD replace  /home/wauser/vt.txt
    

    enter image description here Save the job.

    Submit the job by clicking "Select Action" -> "Submit Job into current plan".

    enter image description here

    Define a job stream

    Click "New" -> "Job Stream"

    Define the name, the workstation and the variable table (replace CC with your two letters tenant id). The right click on and select add jobs:

    enter image description here

    Add the "TEST" and "UPDATETIMESTAMP" jobs (or the name you used).

    Right click on "UPDATETIMESTAMP" and select "Add dependencies" -> "Job in the same job stream" and then select "TEST".

    enter image description here

    Right click on "Run Cycles" and select "Add Run Cycle"

    enter image description here

    Open the "Rule" pane and select "Daily"

    enter image description here

    Open the "Time Restrictions" and set the time when the job stream has to start and check the flag "use as time dependency".

    enter image description here

    Save the job stream and you're done!