
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
02-23-2016 04:34 AM - edited 03-01-2019 06:40 AM
Task Name | Add a VM Kernel port group with static IP |
Description | |
Prerequisites | Minimum UCSD version: 5.4.0.0 |
Category | Custom task |
Components | |
User Inputs | |
User Output |
Instructions for Regular Workflow Use:
Instructions for Regular Workflow Use:
- Download the attached .ZIP file below to your computer. *Remember the location of the saved file on your computer.
- Unzip the file on your computer. Should end up with a .WFD file.
- Log in to UCS Director as a user that has "system-admin" privileges.
- Navigate to "Policies-->Orchestration" and click on "Import".
- Click "Browse" and navigate to the location on your computer where the .WFD file resides. Choose the .WFD file and click "Open".
- Click "Upload" and then "OK" once the file upload is completed. Then click "Next".
- Click the "Select" button next to "Import Workflows". Click the "Check All" button to check all checkboxes and then the "Select" button.
- Click "Submit".
- 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:
The Task Comments:
The Task Input:
The task output:
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);
}