VMware Cloud Community
TGrissom
Contributor
Contributor

Get Deployment Data with Event Broker

I've been banging my head against this one for a bit now, and am just not running across the correct way of doing this. Hopefully some of you can help. I'm trying to get all data about a vRA deployment via the event broker and pass that across to a vRO workflow.

We are currently using the Machine Provisioning event subscription to grab all the relevant information about an individual VM during deployment for all sorts of useful tasks, but now we're needing to grab data about an entire deployment. To simplify for example sake, we have a blueprint that has two machines attached to a single load balancer. We want to kick off a workflow when this deployment is requested which can get the load balancer name, load balancer IP, and properties from the VMs so we can generate a hostname by combining this information and kick off a request to create a DNS entry for the load balancer.

How can we get all relevant information from a deployment via the event broker in the same way we can from an individual machine deployment?

Reply
0 Kudos
5 Replies
nsb24
VMware Employee
VMware Employee

There are other events registered that gives  deployment ID. You can subscribe to those events and once you have deployment ID, you can use deployment ID to get full deployment resource and its respective components using the following API: https://{{va-fqdn}}/catalog-service/api/consumer/resources?$filter=parentResource/id eq {{deployment-resource-guid}}'. You might have equivalent resources available to get components of a deployment within vRO.

pastedImage_0.png

Reply
0 Kudos
TGrissom
Contributor
Contributor

Thank you for the info. I had tried listening on the other event topics and was able to get the deployment ID, but I was strictly trying to use this information with the built in actions and object methods that were available in vRO to try and get the deployment information which wasn't getting me very far.

I'll give the API a try to see if that'll give me what I'm looking for.

Reply
0 Kudos
filosmith
Enthusiast
Enthusiast

If you have the deploymentId from the payload, you can get the catalog resource ID using the method provided by balatkaz in this post How to get resource action request information

With that deployment ID, you can get the resource with vCACCAFEEntitiesFinder.getCatalogResource(host, catalogResourceId); // host = vCACCAFE:VCACHost

and from there you can get all sorts of properties of the deployment.

Reply
0 Kudos
TGrissom
Contributor
Contributor

You both got me on the right track. I ended up using the vRO catalog client to do a GET to the rest api. I couldn't directly use any of the guids from the event data from vRO, but I was able use that to get a request ID I could feed to the API.

Here's what I ended up with:

var items = vCACCAFEEntitiesFinder.getCatalogResources(vCACHost);

for each (item in items) { 

  if (item.providerBinding.bindingId == deploymentId) {

    var requestId = item.requestId;

  } 

}

if (!requestId) {

  throw 'Could not get request ID.'

}

System.log('RequestID: ' + requestId);

var client = vCACHost.createCatalogClient();

var request = client.get('/consumer/requests/' + requestId);

var requestBody = request.getBodyAsJson();

var resources = client.get('/consumer/requests/' + requestId + '/resourceViews');

var resourceBody = resources.getBodyAsJson();

Thanks for the help.

Reply
0 Kudos
balawiz
Enthusiast
Enthusiast

filosmithTGrissom

The below code is not working for the items more than 100. How to filter and provide limits more than 100?

var items = vCACCAFEEntitiesFinder.getCatalogResources(vCACHost);

for each (item in items) {

  if (item.providerBinding.bindingId == deploymentId) {

    var requestId = item.requestId;

  }

}

Reply
0 Kudos