I am attempting to send the requestNumber property to a VCO workflow. Should I just surround the requestNumber attributes in quotes in VCAC designer? I am not foreign to sending VCAC props to VCO. I am sending over "__api.request.id", but trying to figure out what that references. I am trying to get the catalog request information. I want to be able to query by the requestNumber to check up on the request passed to VCO. I am not using ASD.
Thank you
While I await an answer, I decided to leverage the api.requested and insert all my requested machine properties into a SQL database. When all of my machines are built, I stamped a build.completion=yes on each of the VM's along with the api.requested. I can then email out the configurations by requestID and subsequent data obtained. I think it would be much cleaner if I passed the real catalog request ID to my VCO workflow and check the status that way.
-Stephen
Hi Stephen,
We are also struggling to get the request number.
Can you kindly share the solution if you have found any.
how are you calling and using api.requested
Thanks,
Naresh
+91 9900021200
Adding to this thread for any updates
Find attached my solution for the same issue. Unfortunatelly this is only working after the request is complete. Furthermore browsing through all requests is maybe not the best solution. Looking for someone who is finding a better solution.
CRs = vCACCAFEEntitiesFinder.getCatalogResources(vCACCAFEHost);
for each (CR in CRs)
{
if (CR.providerBinding.getBindingId() == vCACVm.virtualMachineID)
{
Req = vCACCAFEEntitiesFinder.getCatalogItemRequest(vCACCAFEHost ,CR.requestId);
vCACRequestNumber = Req.requestNumber;
break;
}
}
Here is a second idea: Easier... more efficient and working during the runtime. But I don't know if you like this solution more.
With a DB connection to the CAFE appliance database you can determine the requestnumber with a simple query.
var q = vCACCAFEDB.readCustomQuery("SELECT requestnumber FROM cat_request WHERE binding_id = '" + vCACVmProperties.get("__api.request.id") + "';");
vCACRequestNumber = q[0].getProperty("requestnumber");
After a little bit of noodling around, I came up with another way to accomplish this... This is the code straight out of the action I wrote to do this:
- Input: vCACCAFEHost (type: vCACCAFE:vCACHost)
- Input: vCACVm (type: vCAC:VirtualMachine)
- Return Type: Number
var vRACR = vCACCAFEEntitiesFinder.getCatalogItemRequests(vCACCAFEHost);
for each (cr in vRACR) {
if (cr.executionStatus.value() == "STARTED") {
var rd = cr.requestData.values();
for each (r in rd) { if (r.value == vCACVm.displayName) { return cr.requestNumber; } }
}
}
NOTE: The way I wrote this was to only check for requests that are running (i.e. the execution status check for those are started). This will work awesome for net-new VM requests, but reprovisioning will more or less tank out. It'd be possible to add in some additional handling to deal with that, but this was quick and dirty. Way easier than going to the database, for sure.
Side note: I only tested this with a single tenant, so I had the CAFE Host hard coded in the shell I used... there may be some trickiness involved if there are multiple tenants, as each one is going to be a separate vCACCAFE:vCACHost inventory object. Just thought I'd point that out. 🙂
I guess like many others I have been struggling to get request information into vCO. Using the answers above I have been able to extract the information from vCAC/vRA. However, along the way, I learned a few new tricks that I would like to share here. Note, some workflow attributes are used in this workflow, these are:
oAttVCACCAFEHost: Object vCACCAFE;VCACHost pointing to our vCAC server instance
oAttVCACVCACHost: Object vCAC:vCACHost pointing to our vCAC server instance
Also, this script iterates over all deployed resources. If you're interested in a single catalog resource, just create an input variable into the workflow and retrieve a single catalog resource using: vCACCAFEEntitiesFinder.findCatalogItems(oAttVCACCAFEHost, sInResource).
// *** Script start ***
var oResource, aResources, sResourceName, oRequest, sRequestId, sRequestNumber, iEntry, oProviderBinding, sBindingId, oProvider, sProviderId, sProviderName, oVM, sDescription, sReason;
// Obtain a list of deployed catalog resources (vCAC/vRA term for deployed servers)
aResources = vCACCAFEEntitiesFinder.getCatalogResources(oAttVCACCAFEHost);
// Single resource example:
// aResources = vCACCAFEEntitiesFinder.findCatalogItems(oAttVCACCAFEHost, sInResource);
System.log("Total elements: " + aResources.length);
System.log("Catalog resources:");
// Loop through the resource array
for (iEntry = 0; iEntry < aResources.length; iEntry++) {
sResourceName = aResources[iEntry].getName();
// Note, sRequestId is the request GUID passed as
// input parameter __asd_catalogRequestId by ASD.
// VMs also may have a property named:
// __api.request.id which seems to be related to
// request objects somehow.
sRequestId = aResources[iEntry].getRequestId();
// Obtain an object to the capacity provider for the resource. (F.e. vSphere)
oProviderBinding = aResources[iEntry].getProviderBinding();
// sBindingId is used to lookup objects associated with the resource
sBindingId = oProviderBinding.getBindingId();
// Collect objects related to the capacity provider
oProvider = oProviderBinding.getProviderRef();
sProviderId = oProvider.getId();
sProviderName = oProvider.getLabel();
// Using sBindingId, obtain the associated the vCACVM object
oVM = Server.findForType("vCAC:virtualmachine", sBindingId);
if (oVM !== null) {
if (sRequestId === null) {
// This most likely concerns a resource deployed by AppD.
// For resources deployed by AppD, no vCAC requests are logged!
} else {
// This is a resource which has been requested by vCAC.
// Let's obtain the vCAC request associated with this resource.
oRequest = vCACCAFEEntitiesFinder.getCatalogItemRequest(oAttVCACCAFEHost, sRequestId);
// Get the request number and other attributes.
sRequestNumber = oRequest.requestNumber;
sDescription = oRequest.description;
sReason = oRequest.reasons;
}
}
}
// *** Script end ***
Excellent!!! Thanks for sharing!
Coincidence...
I need this today. Thanks!
Another one for the mix.
var requestId = System.getContext().getParameter("__asd_catalogRequestId");
var req = vCACCAFEEntitiesFinder.getCatalogItemRequest(cafeHost , requestId);
System.log(req.requestNumber);
Hey Chris,
How did set up a connection to the cafe DB.
This search for the request ID is getting on my last nerve!
"With a DB connection to the CAFE appliance database you can determine the requestnumber with a simple query." --> How did you accomplish this?
var q = vCACCAFEDB.readCustomQuery("SELECT requestnumber FROM cat_request WHERE binding_id = '" + vCACVmProperties.get("__api.request.id") + "';");
vCACRequestNumber = q[0].getProperty("requestnumber");
"
How do we get the requestID or number of failed Catalog requests based on payload?
Failed Payload properties:
{taskType=PROVISION, subtenant=92c2bd1a-********, completionDetails=The following component requests failed: some failed reason...
....
...
requestId=c25eef16-2*********, success=false, deploymentId=68238be4-************, blueprintId=test, tenant=testTenent, requestStatus=FAILED}
'__asd_requestInstanceId'
'__asd_catalogRequestId'
'__asd_targetResourceId'
'__asd_correlationId'
'__asd_requestTraceId'
'__asd_requestTraceId'