Hi,
I have created a custom forms (XAAS blueprint) in vRA automation 7.5, which runs a workflow in vRO that creates a Virtual Machine. The workflow is based on the "Create Simple Virtual Machine" workflow which I have customized to my needs. It is rather simple and only does a few changes to the machine before starting it. The MacAddress is generated automatically, but I would like to return the MacAddress, which I find using the code below:
//Return the MAC Address of the VM
var mac;
var deviceArray = VM.config.hardware.device;
for each (device in deviceArray) {
if (device instanceof VcVirtualVmxnet3) {
System.log(device.deviceInfo.label);
MacAddress = device.macAddress;
}
}
I trigger the workflow by using the vRA REST API call (from PowerShell)
https://vRA FQDN/catalog-service/api/consumer/entitledCatalogItems/{blueprint-id}/requests
Afterwards I use the same API to check when state have changed from "SUBMITTED" to "SUCCESSFUL".
Is there any way that I can return the MacAddress from the workflow to the PowerShell console that is running the REST API script?
Thx in advance Christian
If you want to see it on the GUI, you need to create an additional form in the XaaS designer for the output.
Then, after the deployment completed, you can find the output here:
I have not tried, but I believe this result should be available via API as well.
My first question to these types of things is always this: Why are you using XaaS to deploy a VM rather than the default Is as capabilities native to vRA? What's the use case or rationale?
I agree that I might not seem as the obvious choice, but we are not really going to use vRO for provisioning machines. We are only creating empty VMs, someone will then install operatingsystem on these machines and automatically convert them to a template using the workflow.
The actual machines will be created through vRA machine blueprint were the template described above will used for vRA cloning.
It works fine to request a machine through REST and also the get status back about the progress, but would be nice, if I someone could return the MAC address, some it could be picked up by the powershell script invoking the REST API call.
Maybe there is a smarter way.
If you want to see it on the GUI, you need to create an additional form in the XaaS designer for the output.
Then, after the deployment completed, you can find the output here:
I have not tried, but I believe this result should be available via API as well.
Thx alot xian for your input. I now got it working and I can definitely see the outputs under the request inputs tab .
I also got it working catalog request working with REST api, but it does not seem to hold the Submitted variables, only the Request form parameters. I will use a little bit more time to see, if there is a way. I would suppose there should be.
Again thx Christian
There you are via API:
$ curl -s -k -X GET --header "Content-Type:application/json" --header 'Accept: application/json' --header "Authorization: Bearer $token" 'https://vra.corp.local/catalog-service/api/consumer/requests/c638f786-1a61-4a94-ac07-65facf17d715/fo...' | jq '.values.entries[] | select (.key == "provider-arg_out_0") | .value.value'
"my workflow output"
Thx again - That was exactly what I needed.
I am still new to the vRA API. If I may trouble you a last time related to this topic. Where do you find good insight on the vRA API? I often find it rather difficult to find what I need. Seems that the description of the API sometimes is rather limited?
Christian
You can check the API documentation at https://code.vmware.com/apis/vrealize-automation
Another possibility to use the appliance itself: https://vra.corp.local/component-registry/services/docs#!/apis
Unfortunately not everything is documented. One good example is Solution Found for Updating Deployment Name/Description from vRO where /consumer/deployments/ is not found in the API docs so reverse engineering needed.
I found useful browser debug tools. In this case I opened the XaaS deployment and clicked History/Request Inputs. Developer tools reveal the following request:
So it is calling the catalog API with the above path. You need to adjust it to the API specification and you have the correct API call, and you can find the POST data as well (if there are any).