cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
3750
Views
0
Helpful
0
Comments
Orf Gelbrich
Cisco Employee
Cisco Employee
Task NameAdd a VM Kernel port group with static IP
Description

Prerequisites

Minimum UCSD version: 5.4.0.0

CategoryCustom task
Components
User Inputs

User Output

Instructions for Regular Workflow Use:

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.

A big thank you goes to:  Ryan Criss and Abhishek Bhardwaj

The workflow file contains a custom workflow task:

Screen Shot 2016-02-23 at 6.28.24 AM.png

The Task Comments:

Screen Shot 2016-02-23 at 6.29.17 AM.png

The Task Input:

Screen Shot 2016-02-23 at 6.29.30 AM.png

The task output:

Screen Shot 2016-02-23 at 6.29.41 AM.png

The Code:

importPackage(java.util);

importPackage(java.lang);

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

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

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

importPackage(com.cloupia.lib.cIaaS.vmware);

//----------------------------------------------------------------------------------------

//

// Author: Ryan Criss (rcriss@cisco.com)

//

// Workflow Task Name: Add VMkernel Port to DVS with Static IP

//

// Version: 1.0

//

// Description:

// This custom task adds a VMkernel Port to the DVS with a Static IP

//

// Inputs:

// hostNode: The ESX host you would like to add a VMkernel port to

// dvPortGroupName: The DV port group used for the new VMkernel Port

// ipAddress: The IP address of the new VMkernel Port

// subnetMask: The subnet mask of the new VMkernel Port

// mtuSize: The MTU size of the new VMkernel Port

// vmotion: Is this new VMkernel Port enabled for vMotion

//

// Outputs:

// OUTPUT_VMWARE_HOST_NODE_IDENTITY

// OUTPUT_VMWARE_DV_PORT_GROUP_IDENTITY

// OUTPUT_IP_POOL_POLICY_ID

// OUTPUT_DV_PORT_GROUP_NAME

// OUTPUT_STATIC_POOL_IP

// OUTPUT_STATIC_POOL_IPS_ALLOCATED

// OUTPUT_VMWARE_HOST_NODE_IDENTITY

// OUTPUT_MTU_SIZE

//

//----------------------------------------------------------------------------------------

//----------------------------------------------------------------------------------------

//                                 ### FUNCTIONS ###

//----------------------------------------------------------------------------------------

// None

//----------------------------------------------------------------------------------------

//                                 ### MAIN PROGRAM ###

//----------------------------------------------------------------------------------------

////////////////////////////////////////

// Setup Inputs

////////////////////////////////////////

var hostNode = input.hostNode;

var dvPortGroupName = input.dvPortGroupName;

var ipAddress = input.ipAddress;

var subnetMask = input.subnetMask;

var mtuSize = input.mtuSize;

var vmotion = input.vmotion;

////////////////////////////////////////

// Create Temporary IP Pool

////////////////////////////////////////

var policyName = ipAddress;

var policyDescription = "Temporary policy for " + ipAddress;

var staticIPPool = ipAddress;

var pools = new PrivateCloudStaticIPPool();

pools.setStaticIpPool(staticIPPool);

pools.setSubnetMask(subnetMask);

var poolsList = new FormManagedList();

poolsList.getList().add(pools);

var policy = new PrivateCloudStaticIPPoolPolicy();

policy.setPolicyName(policyName);

policy.setPolicyDescription(policyDescription);

policy.setStaticIPPools(poolsList);

var def= new StaticIPPoolDef();

def.setIpPools(policy.getStaticIPPools().getList());

var defStr = VMWareUtils.getPrivateCloudStaticIPPoolDefStr(def);

policy.setIpPoolInfoStr(defStr);

var result = InfraPersistenceUtil.persistPrivateCloudStaticIPPoolPolicy(policy);

if(result){

  logger.addInfo("Static IP Pool Policy  "+policyName+"  created successfully.");

  var policyObj = InfraPersistenceUtil.getPrivateCloudStaticIPPoolPolicy(policyName);

  var policyId = policyObj.getPolicyId();

  logger.addInfo("Policy Id: "+policyId);

  var staticIpPolicyIdentity = policyId + "@" + policyName;

} else {

  throw new Exception("Static IP Pool policy "+policyName+"  not created.");

}

////////////////////////////////////////

// Create VMKernel Port on DVS

////////////////////////////////////////

var task = ctxt.createInnerTaskContext("Add VMKernel Port On DVSwitch");

task.setInput("Host Node", hostNode);

task.setInput("DVPortGroup Name", dvPortGroupName);

task.setInput("Network Type", "IPv4");

task.setInput("Select IP Address Type", "1");

task.setInput("Static IP Pool", staticIpPolicyIdentity);

task.setInput("MTU Size", mtuSize);

task.setInput("Enable vMotion", vmotion);

// Now execute the task. If the task fails, then it will throw an exception

task.execute();

// Now copy the outputs of the inner task for use by subsequent tasks

output.OUTPUT_VMWARE_HOST_NODE_IDENTITY = task.getOutput("OUTPUT_VMWARE_HOST_NODE_IDENTITY");

// Type of following output: VMwareDVPortgroupIdentity

output.OUTPUT_VMWARE_DV_PORT_GROUP_IDENTITY = task.getOutput("OUTPUT_VMWARE_DV_PORT_GROUP_IDENTITY");

// Type of following output: VMWareIPPoolPolicy

output.OUTPUT_IP_POOL_POLICY_ID = task.getOutput("OUTPUT_IP_POOL_POLICY_ID");

// Type of following output: dvPortGroupName

output.OUTPUT_DV_PORT_GROUP_NAME = task.getOutput("OUTPUT_DV_PORT_GROUP_NAME");

// Type of following output: StaticPoolIP

output.OUTPUT_STATIC_POOL_IP = task.getOutput("OUTPUT_STATIC_POOL_IP");

// Type of following output: gen_text_input

output.OUTPUT_STATIC_POOL_IPS_ALLOCATED = task.getOutput("OUTPUT_STATIC_POOL_IPS_ALLOCATED");

// Type of following output: gen_text_input

output.OUTPUT_MTU_SIZE = task.getOutput("OUTPUT_MTU_SIZE");

////////////////////////////////////////

// Delete Temporary IP Pool

////////////////////////////////////////

try{

  InfraPersistenceUtil.deletePrivateCloudStaticIPPoolPolicy(policyId);

} catch(e){

  logger.addError("Error occurred while deleting the static ip pool policy with id: "+policyId);

  logger.addError(e);

}

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