VMware Cloud Community
stratoCumulus
Enthusiast
Enthusiast
Jump to solution

vRA 8.6 - Get resourceId from deployment.resource.action.pre inputProperties

Hi, 

Can someone explain how to get the resourceId from the deployment.resource.action.pre topic parameters so I can use it to update custom properties on the VM that a disk reconfigure was requested for? 

Some background:

I'm looking to replicate 7.6 functionality in 8.6, where I get the pre-reconfigure disk capacity, add it as a property to the VM, then read and compare the to the capacity when the reconfigure completes.

This is performed in 7.6 using subscriptions to the lifecycle state event topics EVENT.ReconfigureVM.Pending and EVENT.ReconfigureVM.Complete to trigger my workflows, and pass the payload inputs with the required data. 

So far in 8.6, I've figured out that I need to use a subscription to the deployment.resource.action.pre topic, but I'm having trouble getting the resourceId for the VM from the inputProperties parameters deployment.resource.action.pre provides. (For instance, I can easily get resourceId from compute.provision.pre topic in 8.6)

Also, is there documentation where I can find what event topic parameters actually are in context? I'm wondering what properties can be accessed using parameters in deployment.resource.action.pre that don't seem to line up with an API in vRA8 swagger ui page, like endpointId. API explorer was acceptable for this in 7.6 but in 8.6 it is not as helpful. 

Thanks!

Labels (6)
Reply
0 Kudos
1 Solution

Accepted Solutions
xian_
Expert
Expert
Jump to solution

You can use the IaaS API to fetch, machine ID is under _links property:

curl -s -k -H "Authorization: Bearer $access_token" 'https://vra8.corp.local/iaas/api/deployments/da34913c-f2d2-4c96-bc19-8d537be0d41b' | jq ._links.resources.hrefs


[
"/iaas/api/block-devices/ced64532-5009-4e21-ba40-b21cce34f5f1",
"/iaas/api/machines/a6bb6022-1e00-43ab-a9cd-f8a7217f2849"
]

 

View solution in original post

6 Replies
xian_
Expert
Expert
Jump to solution

You can use the IaaS API to fetch, machine ID is under _links property:

curl -s -k -H "Authorization: Bearer $access_token" 'https://vra8.corp.local/iaas/api/deployments/da34913c-f2d2-4c96-bc19-8d537be0d41b' | jq ._links.resources.hrefs


[
"/iaas/api/block-devices/ced64532-5009-4e21-ba40-b21cce34f5f1",
"/iaas/api/machines/a6bb6022-1e00-43ab-a9cd-f8a7217f2849"
]

 

stratoCumulus
Enthusiast
Enthusiast
Jump to solution

This worked great! Thanks very much for the quick response. I'm still getting used to version 8, apparently I was using the deployment ID with incorrect API for my needs. The "._links.resources.hrefs" part was particularly helpful. 

Reply
0 Kudos
lurims
Enthusiast
Enthusiast
Jump to solution

If I am running in vro using rest api directly how to pass the jq?

Reply
0 Kudos
stratoCumulus
Enthusiast
Enthusiast
Jump to solution

I use the vRA plugin in vRO.

I set up my vRA REST Host in resources, and then reference it in my script, passing the URL with the appropriate operation (eg GET) to the vRA Host and parse the response. 

 

Reply
0 Kudos
lurims
Enthusiast
Enthusiast
Jump to solution

Thanks, I too do the same thing.  But how to pass  | jq ._links.resources.hrefs in the URL?

Reply
0 Kudos
stratoCumulus
Enthusiast
Enthusiast
Jump to solution

I parse the api response as JSON. I can’t remember the exact syntax I used for this, so there may be some errors like needing to parse obj.content etc but this is the basic idea:

var obj = JSON.parse(response);

//access the links in the JSON

var references = obj._links.resources.hrefs;

for (var i in references){
     if(references[i].indexOf(‘machine’) > -1){            //parse the string to get machineId only here
     }
}