UCSD Provision Multiple Bare Metal Servers At OneTime

Version 1

    There are two workflows. One standard workflow for bare metal provisioning of CentOS on UCS Blade with Local Disk for booting (first one listed below). The second workflow which is used to launch the first workflow has a custom task to submit the first workflow n number of times (second one listed below).

     

    This has been tested with UCSD version 5.2 and 5.3. Workflow exported with 5.4.

     

     

    In this example the bare metal workflow only has one parameter for input called Hostname. If you have more parameters then you need to add them to the custom task in the launcher workflow. Also the Workflow name in hard coded in this task. See line in bold below.

     

    mportPackage(com.cloupia.model.cIM);

    importPackage(java.util);

    importPackage(java.lang);

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

     

    var delaySecondsBetweenInvocation = 30;

    var qty = input.BMcount;

    logger.addInfo("Quanity = "+qty);

    var childSrIdArray = [];

    var workflowName = "Provision CentOS 60 Local Boot";

    var ctrs = 0;

    for (var ctr = 0; ctr < qty; ctr = ctr + 1)

    {

     

    var userId = ctxt.getUserId();

    var userProfile = ctxt.getAPI().userAPIGetMyLoginProfile();

    var email = userProfile.getEmail();

    logger.addInfo("user id is "+userId);

    logger.addInfo("email address is "+email);

     

    var list = new APINameValueList();

     

    list.addNameValue("Hostname",input.Hostname);

     

    logger.addInfo("Hostname = "+input.Hostname);

     

     

    var params = list;

     

    logger.addInfo("list = "+list);

    logger.addInfo(ctr+1+"  BM Creating.........");

    var srId = ctxt.getAPI().userAPISubmitWorkflowServiceRequest(workflowName,params,-1);

     

    childSrIdArray[ctr] = srId;

      // Allow some delay between provisioning

       sleep();

    logger.addInfo("---------------"+ctr+1+"  BM Created Successfully-----------");

    ctrs++;

    }

    function sleep()

    {

                  var milliseconds = delaySecondsBetweenInvocation * 1000;

                  Thread.sleep(milliseconds);

    }

    for (var i=0; i<childSrIdArray.length; i++)

    {

                    var childSrId = childSrIdArray[i];

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

                    if (status == 0)

                    {

                                    logger.addInfo("Provisioned SR ID  ="+ childSrId+ " successfully.");

                    } else {

                                    logger.addError("SR ID  ="+ childSrId+ " failed");

                    }

    }

     

    logger.addInfo("Total number of BM Created: "+ctrs);