02-24-2016 05:27 AM - edited 03-01-2019 06:40 AM
Task Name | Manual IP Input and VM deployment with Post provisioning and roll back. Creates a IP pool of size = One IP address if more then 8 CPUs is chosen the user approval is required. |
Description | |
Prerequisites | Minimum UCSD version: 5.4.0.2 |
Category | Custom task |
Components | |
User Inputs | |
User Output |
Instructions for Regular Workflow Use:
Instructions for Regular Workflow Use:
Inspired by Ryan Criss and Abhishek Bhardwaj
The workflow:
Note if 8 CPU's is chosen then USER approval is required.
Creates a new IP pool of size = one IP address
Updated the VDC the VM is deployed into
Deletes the IP pool
Workflow Execution with out approval:
Input:
Subsequent workflow for VM creation:
Workflow execution when CPU = 8 is chosen and user approval is required:
Input:
User Approval E-mail:
Workflow input and changes marked for customer environment:
Workflow run:
The VDC set up:
The network policy in the VDC:
The Network Policy:
The VM network:
The Nic:
The result after a workflow run:
Resulting Policy creation:
How to find all the IP Pool Methods:
In the custom task click the Show Doc button:
The links get turned on:
Select from the new browser tab document the Private Cloud Static IP Pool:
The Methods will be displayed:
In this case all the set commands were needed.
Create IP Pool 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);
var ipAddress = input.IPAddress;
var subnetMask = input.SubnetMask;
var GW = input.Gateway;
var vlan = input.VLAN;
// Create IP Pool
var policyName = "Pool_" + ipAddress;
var policyDescription = "Pool policy for " + ipAddress;
var staticIPPool = ipAddress;
var pools = new PrivateCloudStaticIPPool();
pools.setStaticIpPool(staticIPPool);
pools.setSubnetMask(subnetMask);
pools.setVlanID(vlan);
pools.setGatewayIP(GW);
//> var policyObj = InfraPersistenceUtil.getPrivateCloudStaticIPPoolPolicy(6);
//
//> printObj(policyObj);
//properties = com.cloupia.service.cIM.inframgr.profiles.PrivateCloudStaticIPPoolPolicy@3a53152a
//[policyId=6,policyName=Coke,
//policyDescription=Coke,
//staticIPPools=com.cloupia.service.cIM.inframgr.forms.wizard.FormManagedList@27d33d49,
//ipPoolInfoStr=eCIsInNsInZsYW5JRCI6IjEwIiwidW2tlIn1dfQ==,dn
//DetachedState={18[OID]com.cloupia.service.cIM.inframgr.profiles.PrivateCloudStaticIPPoolPolicy,,
//{0, 1, 2, 3},{}}]
//methods = setPolicyName getPolicyName getPolicyId setPolicyId
//getPolicyDescription setPolicyDescription setIpPoolInfoStr
//getIpPoolInfoStr setPoolDef getPoolDef getStaticIPPools setStaticIPPools
Delete IP Pool 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);
var policyId = input.IPPoolPolicyID;
// Delete 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);
}
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;
logger.addInfo("staticIpPolicyIdentity: "+staticIpPolicyIdentity);
} else {
throw new Exception("Static IP Pool policy "+policyName+" not created.");
}
output.PoolName = policyName;
output.PoolID = policyId;
output.IPPoolPolicySelector = staticIpPolicyIdentity;
This workflow was inspired by these posting:
IP Pool Creation
UCSD - Add VM Kernel Port Group to DvSwitch with Static IP
My Application
UCSD - Application Stack with Custom Button
Vm Deployment with Post Provisioning and Rollback
UCSD - Multi VM Provisioning with Post Provisioning and Rollback Example / Multi VM shutdown
Possible enhancements
A loop could be wrapped around this workflow to provision many VM's
UCSD Power off many VM's via Loop and possible schedule
Reading IP's from a CSV file and feeing them to the loop
UCSD - Random Read CSV file / Create VLAN(s) from CSV file Example
Is there a concern with multiple users modifying a network policy simultaneously? If I have two users request server builds at nearly the same time, will both VMs be provisioned with the second network policy?
Yes that could be a problem. Then you have to go to to example #123 on the community site. I build them VDC's with a $ attached to all policy names to avoid the described situation.
-
Orf Gelbrich
Check out UCS Director Workflow INDEX<https://communities.cisco.com/docs/DOC-56419> on Cisco Communities Site
Hi Orf,
Regarding this workflow - I keep getting "Cannot allocate IP Address - Static pool exhausted" - If I set the pool to allow IP Overlap and restart the workflow it goes through although I get a Mismatch in the IP Address for the nic(s) warning in the VM Provision Engine Config part of the build - the portgroup is an ACI generated one. Any ideas?
Regards
Phil
Do you roll back you workflow in order for the IP to be released?
under Policies -> virtual -> Network -> Global IP usage do you see the IP there allocated?
How long to do you keep deleted VM info?
Administration -> system -> system parameters?
Ahh yes I see them in there and the System params were the default 60 days. I see that there is a built in remove reserved IP task - I will look into that to use as a clean up before the provisioning - look for it and execute so that I can be sure that it's not been reserved - thanks a lot Orf as always! (been pulling my hair out on that one)
Orderly roll back cleans up the IP reservation as well.
Orf Gelbrich
Check out UCS Director Workflow INDEX<https://communities.cisco.com/docs/DOC-56419> on Cisco Communities Site (Twitter @UCSDGURU)
eek - there are all sorts of problems with this - the built in task to remove the reservation has a table you select from - this concatenates a series of variables into a string e.g. 626@StaticIPPool/11/10.85.32.6/3@Group - looking up the metadata report there is no way to get all of that info from it.
I tried cloning this workflow task but it only has an ipaddress input and there is no way to work out how to build that string.
I rolled back an old workflow and it said that it undoes the reservation but I guess I have deleted the static pool now as I am creating it and then deleting it in the workflow and so the number for that (626 I expect in my example above) is no longer there and so the rollback doesn't work.
I can run the built in task - but as the type of the input is set to Gen Text (when actually it is a table called RESERVED_IPADDRESS_LIST) which when selected produces the string 626@StaticIPPool/11/10.85.32.6/3@Group there is no way to reproduce this and map a master task input to this sub task.
I have to edit the task each time, not map it and then click the select button to show the table - to clear out all of the reservations made.
Actually - I realise that perhaps the data for Reservations is retrievable from Organizations -> Reservations as that has more columns and a combination of those columns may enable me to build up the string - rolling back works well though so I may be ok for now.
I am not sure what the issues are here. Usually in custom tasks you can build variables like this
Var b=”I am here”;
Var a= “hello ” + b + “ and you are there”;
Would result in a having as values = “hello I am here and you are there”
Orf Gelbrich
Check out UCS Director Workflow INDEX<https://communities.cisco.com/docs/DOC-56419> on Cisco Communities Site (Twitter @UCSDGURU)
Make sure this is set in the catalog
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: