cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2983
Views
0
Helpful
3
Comments
Orf Gelbrich
Cisco Employee
Cisco Employee
Task NamePre and Post VM Provisioning via API Call
Description
Prerequisites
  1. Tested on 5.3
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.

Enable the Developer Menu (click on Admin):

Screen Shot 2015-05-18 at 11.13.01 AM.png

Check the check box:

Screen Shot 2015-05-18 at 11.13.08 AM.png

The API call in question:

Screen Shot 2015-05-18 at 11.12.53 AM.png

The API call Options:

Screen Shot 2015-05-18 at 11.13.26 AM.png

The workflow to import:

Screen Shot 2015-05-18 at 1.05.43 PM.png

The workflow input (the VDC and Catalog needs to be updated and the user and e-mail address):

Screen Shot 2015-05-18 at 1.06.27 PM.png

The questions upon executions:

Screen Shot 2015-05-18 at 1.06.54 PM.png

The workflow:

Screen Shot 2015-05-18 at 1.06.42 PM.png

The workflow Cloupia Script:

mportPackage(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 section

//

var vmName = ctxt.getInput("VM_Name");

var vmComment = ctxt.getInput("VM_Comment");

var vmCPU = ctxt.getInput("VM_CPU");

var vmMemory = ctxt.getInput("VM_Memory");

var catId = ctxt.getInput("VM_Catalog");

var vdcId = ctxt.getInput("VM_VDC");

var vmUser = ctxt.getInput("VM_USER");

var vmInputA1 = ctxt.getInput("VM_Post_Provisioning_Input_A1");

var vmInputA2 = ctxt.getInput("VM_Post_Provisioning_Input_A2");

//

//write everything to the SR log

//

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

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

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

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

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

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

//

//Convert the VDC and Catalog ID to a Name

//

var vdc = VDCUtil.getVDC(vdcId);

var vdcName = vdc.getVdcName();

var cat = VDCUtil.getVDCCatalogItem(catId);

var catName = cat.getCatalogItemName();

logger.addInfo("CatalogName: " + catName);

logger.addInfo("vdcName: " + vdcName);

//

// Set up the API call to provision a VM

//

var params = new APIProvisionParams();

params.setCatalogName(catName);

params.setVdcName(vdcName);

params.setUserID(vmUser);

params.setVmName(vmName);

params.setComments(vmComment);

params.setCores(vmMemory);

params.setMemoryMB(vmMemory);

//If Post Provision workflow has user inputs then the following code is required to pass user inputs to API.

//If the post provision workflow has only task inputs then skip the below code. It is not required to setPostProvWFUserInputs.

var nv1 = new APINameValue("A1",vmInputA1);

var nv2 = new APINameValue("A2",vmInputA2);

var list = new APINameValueList();

list.addNameValue(nv1);

list.addNameValue(nv2);

//Add this inputs list to provision params.

params.setPostProvWFUserInputs(list);

var childSrId = ctxt.getAPI().userAPIProvisionRequest(params);


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

if (status == 0)

{

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

} else {

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

}

The Catalog in question:

Screen Shot 2015-05-18 at 1.15.17 PM.png

The catalog details:

Screen Shot 2015-05-18 at 1.15.35 PM.png

The post provisioning workflow:

Screen Shot 2015-05-18 at 1.15.46 PM.png

The details of the post provisioning workflows:

Screen Shot 2015-05-18 at 1.17.49 PM.png

This workflow has 2 inputs:

Screen Shot 2015-05-18 at 1.18.06 PM.png

The workflow:

Screen Shot 2015-05-18 at 1.18.13 PM.png

The inputs:

Screen Shot 2015-05-18 at 1.18.22 PM.png

Comments
psivakum
Cisco Employee
Cisco Employee

In the "Set up the API call to provision a VM" section, please change the following in the script.


params.setCores(vmMemory); should be changed to params.setCores(vmCPU);


Note: In the existing script, memory input is getting passed as CPU input. hence, requesting to make the required changes after inporting the WF





Orf Gelbrich
Cisco Employee
Cisco Employee

You should use this one…

https://communities.cisco.com/docs/DOC-63923

psivakum
Cisco Employee
Cisco Employee

Thanks Orf. 

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community:

Quick Links

Review Cisco Networking for a $25 gift card