UCSD Parallel Workflow Execution Example

Version 4
    Task NameParallel Workflow Execution Example (near parallel)
    Description
    1. Workflow Execution example
    Prerequisites
    1. Tested on 5.3.0.2
    CategoryWorkflow
    ComponentsvSphere 5.x
    User Inputs

    Instructions for Regular Workflow Use:

    1. Download the attached .ZIP file below to your computer. *Remember the location of the saved file on your computer.
    2. Unzip the file on your computer. Should end up with a .WFD file.
    3. Log in to UCS Director as a user that has "system-admin" privileges.
    4. Navigate to "Policies-->Orchestration" and click on "Import".
    5. Click "Browse" and navigate to the location on your computer where the .WFD file resides. Choose the .WFD file and click "Open".
    6. Click "Upload" and then "OK" once the file upload is completed. Then click "Next".
    7. Click the "Select" button next to "Import Workflows". Click the "Check All" button to check all checkboxes and then the "Select" button.
    8. Click "Submit".
    9. A new folder should appear in "Policies-->Orchestration" that contains the imported workflow. You will now need to update the included tasks with information about the specific environment.

     

    The Workflow:

     

    Screen Shot 2015-06-12 at 8.13.35 AM.png

     

    Workflow Input Parameters:

     

    Screen Shot 2015-06-12 at 8.13.45 AM.png

     

    Each workflow name and its variable and its variable content.

     

    The Execution of the workflow:

     

    Screen Shot 2015-06-12 at 8.16.01 AM.png

     

    The main Workflow and its Child Workflows (SR logs):

     

    Screen Shot 2015-06-12 at 8.20.41 AM.png

    The Code:

     

    importPackage(com.cloupia.model.cIM);

    importPackage(java.util);

    importPackage(java.lang);

    importPackage(java.io);

    importPackage(com.cloupia.lib.util);

    importPackage(com.cloupia.model.cIM);

    importPackage(com.cloupia.service.cIM.inframgr);

    importPackage(org.apache.commons.httpclient);

    importPackage(org.apache.commons.httpclient.cookie);

    importPackage(org.apache.commons.httpclient.methods);

    importPackage(org.apache.commons.httpclient.auth);

    importPackage(com.cloupia.model.cEvent.notify);

    importPackage(com.cloupia.lib.util.mail);

    importPackage(com.cloupia.fw.objstore);

    importPackage(com.cloupia.lib.util.managedreports);

     

     

    //

    // User Input Parameterts

    //

     

     

    var wfn1 = ctxt.getInput("WFN1");

    var wfi11 = ctxt.getInput("WFI11");

    var wfi12 = ctxt.getInput("WFI12");

    var wfv11 = ctxt.getInput("WFV11");

    var wfv12 = ctxt.getInput("WFV12");

     

     

    var wfn2 = ctxt.getInput("WFN2");

    var wfi21 = ctxt.getInput("WFI21");

    var wfi22 = ctxt.getInput("WFI22");

    var wfv21 = ctxt.getInput("WFV21");

    var wfv22 = ctxt.getInput("WFV22");

     

     

    var wfn3 = ctxt.getInput("WFN3");

    var wfi31 = ctxt.getInput("WFI31");

    var wfi32 = ctxt.getInput("WFI32");

    var wfv31 = ctxt.getInput("WFV31");

    var wfv32 = ctxt.getInput("WFV32");

     

     

    var delaySecondsBetweenInvocation = 5;

     

     

     

     

     

     

    function sleep()

    {

                  var milliseconds = delaySecondsBetweenInvocation * 1000;

                  Thread.sleep(milliseconds);

    }

    //

    //

     

     

     

     

     

     

     

     

    logger.addInfo("----------------------------------------------------------");

    logger.addInfo("My SR ID = "+ctxt.getSrId());

    var mySRID = ctxt.getSrId();

    logger.addInfo("params wfn1 = "+wfn1);

    logger.addInfo("params wfi11 = "+wfi11);

    logger.addInfo("params wfi12 = "+wfi12);

    logger.addInfo("params wfv11 = "+wfv11);

    logger.addInfo("params wfv12 = "+wfv12);

    logger.addInfo("----------------------------------------------------------");

    logger.addInfo("params wfn2 = "+wfn2);

    logger.addInfo("params wfi21 = "+wfi21);

    logger.addInfo("params wfi22 = "+wfi22);

    logger.addInfo("params wfv21 = "+wfv21);

    logger.addInfo("params wfv22 = "+wfv22);

    logger.addInfo("----------------------------------------------------------");

    logger.addInfo("params wfn3 = "+wfn3);

    logger.addInfo("params wfi31 = "+wfi31);

    logger.addInfo("params wfi32 = "+wfi32);

    logger.addInfo("params wfv31 = "+wfv31);

    logger.addInfo("params wfv32 = "+wfv32);

    //

    // Information

    //

    // If you are using : var childSrId= ctxt.getAPI().userAPISubmitWorkflowServiceRequest(“Task_Y”,

    // params,ctxt.getSrId()); // takes it as parent SR Id

    // userAPISubmitWorkflowServiceRequest API maintains a parent-child relationship.

    // The child SRs it generates won’t be visible to the Service Request logs

    // If you need to make  the child SR visible then use the API like :

    // userAPISubmitWorkflowServiceRequest(“Task_Y”, params, -1);

     

     

    //

    // Call New Service Request for workflow 1

    //

    logger.addInfo("-------------------Provsion Workflow 1---------------------------------");

    var params = util.createNameValueList();

    params.addNameValue(util.createNameValue(wfv11, wfi11));

    params.addNameValue(util.createNameValue(wfv12, wfi12));

    //var childSrId1= ctxt.getAPI().userAPISubmitWorkflowServiceRequest(wfn1, params, ctxt.getSrId());

    var childSrId1= ctxt.getAPI().userAPISubmitWorkflowServiceRequest(wfn1, params, -1);

    logger.addInfo("childSrId 1 = "+childSrId1);

    logger.addInfo("Sleeping for a bit (5 sec...");

    sleep();

     

     

     

     

    //

    // Call New Service Request for workflow 2

    //

    logger.addInfo("-------------------Provsion Workflow 2---------------------------------");

    var params = util.createNameValueList();

    params.addNameValue(util.createNameValue(wfv21, wfi21));

    params.addNameValue(util.createNameValue(wfv22, wfi22));

    //var childSrId2= ctxt.getAPI().userAPISubmitWorkflowServiceRequest(wfn2, params, ctxt.getSrId());

    var childSrId2= ctxt.getAPI().userAPISubmitWorkflowServiceRequest(wfn2, params, -1);

    logger.addInfo("childSrId 2 = "+childSrId2);

    logger.addInfo("Sleeping for a bit (5 sec...");

    sleep();

     

     

     

     

    //

    // Call New Service Request for workflow 3

    //

    logger.addInfo("-------------------Provsion Workflow 3---------------------------------");

    var params = util.createNameValueList();

    params.addNameValue(util.createNameValue(wfv31, wfi31));

    params.addNameValue(util.createNameValue(wfv32, wfi32));

    //var childSrId3= ctxt.getAPI().userAPISubmitWorkflowServiceRequest(wfn3, params, ctxt.getSrId());

    var childSrId3= ctxt.getAPI().userAPISubmitWorkflowServiceRequest(wfn3, params, -1);

    logger.addInfo("childSrId 3 = "+childSrId3);

    logger.addInfo("Sleeping for a bit (5 sec...");

    sleep();

     

     

     

     

    logger.addInfo("-------------------Waiting for Workflow 1 to Finish---------------------");

    var status = ctxt.waitForCompletion(childSrId1, 1800000);             

    logger.addInfo("-------------------Done Waiting for Child Workflow to Finish----------");

    if (status == 0)

    {

         logger.addInfo("Provisioned Workflow 1  ="+ childSrId1+ " successfully.");

    } else {

         logger.addError("SR ID  ="+ childSrId1+ " Failed");

    }

     

     

     

     

     

     

    logger.addInfo("-------------------Waiting for Workflow 2 to Finish---------------------");

    var status = ctxt.waitForCompletion(childSrId2, 1800000);             

    logger.addInfo("-------------------Done Waiting for Child Workflow to Finish----------");

    if (status == 0)

    {

         logger.addInfo("Provisioned Workflow 2  ="+ childSrId2+ " successfully.");

    } else {

         logger.addError("SR ID  ="+ childSrId2+ " Failed");

    }

     

     

     

     

     

     

    logger.addInfo("-------------------Waiting for Workflow 3 to Finish---------------------");

    var status = ctxt.waitForCompletion(childSrId3, 1800000);             

    logger.addInfo("-------------------Done Waiting for Child Workflow to Finish----------");

    if (status == 0)

    {

         logger.addInfo("Provisioned Workflow 3  ="+ childSrId3+ " successfully.");

    } else {

         logger.addError("SR ID  ="+ childSrId3+ " Failed");

    }

     

     

     

     

    Workflow execution log:

     

    Service Request ID: 5088

    Workflow Inputs:

    - WFN1

    - WFI11

    - WFI12

    - WFV11

    - WFV12

    - WFN2

    - WFI21

    - WFI22

    - WFV21

    - WFV22

    - WFN3

    - WFI31

    - WFI32

    - WFV31

    - WFV32

     

     

     

     

    Jun 12, 2015 13:05:13 UTC Request submitted

    Jun 12, 2015 13:05:17 UTC Executing workflow item number 1

    Jun 12, 2015 13:05:17 UTC Completed workflow item number 1, with status Completed

    Jun 12, 2015 13:05:23 UTC Executing workflow item number 2

    Jun 12, 2015 13:05:23 UTC Trigger context executeWorkFlowStep called

    Jun 12, 2015 13:05:23 UTC Executing custom action Call 3 workflows (ExecuteCloupiaScript)

    Jun 12, 2015 13:05:23 UTC Executing custom action Call 3 workflows (ExecuteCloupiaScript)

    Jun 12, 2015 13:05:26 UTC Executing cloupia script: Call Workflows

    Jun 12, 2015 13:05:26 UTC ----------------------------------------------------------

    Jun 12, 2015 13:05:26 UTC My SR ID = 5088

    Jun 12, 2015 13:05:26 UTC params wfn1 = TestWorkflow1

    Jun 12, 2015 13:05:26 UTC params wfi11 = Happy

    Jun 12, 2015 13:05:26 UTC params wfi12 = 4th of July

    Jun 12, 2015 13:05:26 UTC params wfv11 = A1

    Jun 12, 2015 13:05:26 UTC params wfv12 = A2

    Jun 12, 2015 13:05:26 UTC ----------------------------------------------------------

    Jun 12, 2015 13:05:26 UTC params wfn2 = TestWorkflow2

    Jun 12, 2015 13:05:26 UTC params wfi21 = Happy

    Jun 12, 2015 13:05:26 UTC params wfi22 = Labor Day

    Jun 12, 2015 13:05:26 UTC params wfv21 = A1

    Jun 12, 2015 13:05:26 UTC params wfv22 = A2

    Jun 12, 2015 13:05:26 UTC ----------------------------------------------------------

    Jun 12, 2015 13:05:26 UTC params wfn3 = TestWorkflow3

    Jun 12, 2015 13:05:26 UTC params wfi31 = Happy

    Jun 12, 2015 13:05:26 UTC params wfi32 = Birthday

    Jun 12, 2015 13:05:26 UTC params wfv31 = A1

    Jun 12, 2015 13:05:26 UTC params wfv32 = A2

    Jun 12, 2015 13:05:26 UTC -------------------Provsion Workflow 1---------------------------------

    Jun 12, 2015 13:05:27 UTC childSrId 1 = 5089

    Jun 12, 2015 13:05:27 UTC Sleeping for a bit (5 sec...

    Jun 12, 2015 13:05:32 UTC -------------------Provsion Workflow 2---------------------------------

    Jun 12, 2015 13:05:33 UTC childSrId 2 = 5090

    Jun 12, 2015 13:05:33 UTC Sleeping for a bit (5 sec...

    Jun 12, 2015 13:05:38 UTC -------------------Provsion Workflow 3---------------------------------

    Jun 12, 2015 13:05:40 UTC childSrId 3 = 5091

    Jun 12, 2015 13:05:40 UTC Sleeping for a bit (5 sec...

    Jun 12, 2015 13:05:45 UTC -------------------Waiting for Workflow 1 to Finish---------------------

    Jun 12, 2015 13:05:55 UTC Workflow with SR-ID 5089 is complete

    Jun 12, 2015 13:05:55 UTC -------------------Done Waiting for Child Workflow to Finish----------

    Jun 12, 2015 13:05:55 UTC Provisioned Workflow 1 =5089 successfully.

    Jun 12, 2015 13:05:55 UTC -------------------Waiting for Workflow 2 to Finish---------------------

    Jun 12, 2015 13:06:05 UTC Workflow with SR-ID 5090 is complete

    Jun 12, 2015 13:06:05 UTC -------------------Done Waiting for Child Workflow to Finish----------

    Jun 12, 2015 13:06:05 UTC Provisioned Workflow 2 =5090 successfully.

    Jun 12, 2015 13:06:05 UTC -------------------Waiting for Workflow 3 to Finish---------------------

    Jun 12, 2015 13:06:15 UTC Workflow with SR-ID 5091 is complete

    Jun 12, 2015 13:06:15 UTC -------------------Done Waiting for Child Workflow to Finish----------

    Jun 12, 2015 13:06:15 UTC Provisioned Workflow 3 =5091 successfully.

    Jun 12, 2015 13:06:15 UTC Completed cloupia script Call Workflows

    Jun 12, 2015 13:06:15 UTC Task #1 (Call 3 workflows (ExecuteCloupiaScript)) completed successfully in 52 seconds

    Jun 12, 2015 13:06:15 UTC Input/Output values for Task #1 (Call 3 workflows (ExecuteCloupiaScript)):

    Jun 12, 2015 13:06:15 UTC [Local Input: Label = Call Workflows]

    Jun 12, 2015 13:06:15 UTC [Local Input: Script = importPackage(com.cloupia.model.cIM); importPackage(java.util); importPackage(java.lang); importPackage(java.io); importPackage(com.cloupia.lib.util); importPackage(com.cloupia.model.cIM); importPackage(com.cloupia.service.cIM.inframgr); importPackage(org.apache.commons.httpclient); importPackage(org.apache.commons.httpclient.cookie); importPackage(org.apache.commons.httpclient.methods); importPackage(org.apache.commons.httpclient.auth); importPackage(com.cloupia.model.cEvent.notify); importPackage(com.cloupia.lib.util.mail); importPackage(com.cloupia.fw.objstore); importPackage(com.cloupia.lib.util.managedreports); // // User Input Parameterts // var wfn1 = ctxt.getInput('WFN1'); var wfi11 = ctxt.getInput('WFI11'); var wfi12 = ctxt.getInput('WFI12'); var wfv11 = ctxt.getInput('WFV11'); var wfv12 = ctxt.getInput('WFV12'); var wfn2 = ctxt.getInput('WFN2'); var wfi21 = ctxt.getInput('WFI21'); var wfi22 = ctxt.getInput('WFI22'); var wfv21 = ctxt.getInput('WFV21'); var wfv22 = ctxt.ge

    Jun 12, 2015 13:06:15 UTC [Local Input: Undo Script = ]

    Jun 12, 2015 13:06:15 UTC Completed workflow item number 2, with status Completed

    Jun 12, 2015 13:06:16 UTC Executing workflow item number 3

    Jun 12, 2015 13:06:16 UTC Completed workflow item number 3, with status Completed