Skip to content

Instantly share code, notes, and snippets.

@codyde
Last active February 12, 2018 03:05
Show Gist options
  • Save codyde/9387d57b77bb52d74de5493a2db257d0 to your computer and use it in GitHub Desktop.
Save codyde/9387d57b77bb52d74de5493a2db257d0 to your computer and use it in GitHub Desktop.
XaaS Workflow Sample - vRealize Automation Blog
if (busGroup === null) {
busGroup = "Humblelab"
}
osCatalogName = "Ubuntu Server 16.04"
var BusinessGroups = vCACCAFEEntitiesFinder.findBusinessGroups(cafeHost , busGroup)
System.log(BusinessGroups)
var BusGroupID = BusinessGroups[0].id;
System.log(BusGroupID)
var CatalogItems = vCACCAFEEntitiesFinder.findCatalogItems(cafeHost, osCatalogName);
System.log(CatalogItems)
System.log(osCatalogName)
if (CatalogItems != null) {
for each (catItem in CatalogItems) {
if (catItem.getOrganization().getSubtenantRef() == BusGroupID)
{
System.log("Catalog " + osCatalogName + " Found");
catalogItem = catItem;
break;
}
}
}else{
throw "Catalog Item [" + osCatalogName + "] not found for Business Group [" + busGroup +"]";
}
var catRequest = vCACCAFERequestsHelper.getProvisioningRequestForCatalogItem(catalogItem) // Get the provisioning request data
var catRequestData = vCACCAFERequestsHelper.getProvisioningRequestData(catRequest); // Get Request Data from the previsioning request, in JSON format
var catRequestJSON = JSON.parse(catRequestData)
if (Network == "Common"){
catRequestJSON.Ubuntu1604.data["VirtualMachine.Network0.Name"] = "Common-VLAN"
} else if (Network == "Web"){
catRequestJSON.Ubuntu1604.data["VirtualMachine.Network0.Name"] = "Web-VLAN"
} else if (Network == "DB"){
catRequestJSON.Ubuntu1604.data["VirtualMachine.Network0.Name"] = "DB-VLAN"
}
catRequestJSON.Ubuntu1604.data.cpu = inputCPU
catRequestJSON.ubuntu1604.data.memory = inputMemory*1024
if (Environment == "Production"){
catRequestJSON.Ubuntu1604.data["Vrm.DataCenter.Location"] = "Sacramento"
catRequestJSON.Ubuntu1604.data["Vrm.DataCenter.Policy"] = "Exact"
} else if (Environment == "Development") {
catRequestJSON.Ubuntu1604.data["Vrm.DataCenter.Location"] = "Los Angeles"
catRequestJSON.Ubuntu1604.data["Vrm.DataCenter.Policy"] = "Exact"
}
System.log("Converting request data to JSON String")
vCACCAFERequestsHelper.setProvisioningRequestData(catRequest, JSON.stringify(catRequestJSON));
System.log("Submitting Catalog Request")
System.getModule("com.vmware.library.vcaccafe.request").requestCatalogItemWithProvisioningRequest(catalogItem, catRequest);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment