VMware Cloud Community
kitplummer
Contributor
Contributor

How to get to Deployment ID from Request ID with CloudClient?

I'm trying to do some basic automation by using the CloudClient.  I've pretty much resolved this issue using a Python wrapper around the REST interface, but I'd rather not support that path if I can do the same with the supported tooling.

I'm able to login, fetch a request template, and submit the request.  I obviously can retrieve the request ID.  But I get pretty solidly stuck here, not knowing how to get the associated deployment ID.  From what I can tell, the request information never has the deployment info.  Is there a simply query to get the deployed details via the request ID, or other ID in the request details?

TIA.

Tags (2)
0 Kudos
3 Replies
qc4vmware
Virtuoso
Virtuoso

This is what I do from within vRO so you should be able to do pretty easily map out the REST api equivalent.  Basically get the resources provisioned by the request and look for the item that is the deployment.

var resourceTypeRef = resourceTypeRef || "Virtual Machine";

var hosts = Server.findAllForType("vCACCAFE:VCACHost");

var resources = new Array();

for each (var host in hosts) {

var requestService = host.createCatalogClient().getCatalogConsumerRequestService();

var resources = requestService.getResourcesProvisionedByRequest(requestId,null).getContent();

if (resources) break;

}

//Loop through results

//Only return vms for now

var vms = new Array();

var deployments = new Array();

for (var i = 0; i < resources.length; i++){

System.debug("Id: " + resources[i].id);

System.debug("Name: " + resources[i].name);

System.debug("resourceTypeRef Label: " + resources[i].resourceTypeRef.getLabel());

System.debug("resourceTypeRef Id: " + resources[i].resourceTypeRef.getId());

if (resources[i].resourceTypeRef.getLabel() === "Deployment") deployments.push(resources[i]);

if (resources[i].resourceTypeRef.getLabel() === "Virtual Machine") vms.push(resources[i]);

}

var resOut = new Array();

if (resourceTypeRef.toUpperCase() === "DEPLOYMENT" ) resOut = deployments;

if (resourceTypeRef.toUpperCase() === "VIRTUAL MACHINE" ) resOut = vms;

if (resOut.length > 1) throw "Too many matches(" + resOut.length + ") for catalog resourceTypeRef " + resourceTypeRef + "for requestId : " + requestId;

return resOut[0];

0 Kudos
kitplummer
Contributor
Contributor

Yep.  So...is it possible to get the resources with CloudClient?

I'm getting closer to an understanding that somehow resources resource isn't bubbled up via the CloudClient from the API.  I'm finding it difficult to believe that this is true...somebody please tell me that I'm just missing it, and this isn't a level of incomprehensible ridiculousness.

0 Kudos
Ukusic
Enthusiast
Enthusiast

Did you found out how to do this?

0 Kudos