VMware Cloud Community
michael_stefani
Enthusiast
Enthusiast

Get Deployment in Orchestrator

There was a post a few weeks ago about changing the owner of the deployment which is essentially what we're trying to do.  Using XAAS to request a catalog item, but since we're hiding the real blueprints, a service account ends up as owner of the VMs.  The code to change the owner is working fine... but I'm curious what's the best way to get the deployment? 

In our XAAS request a put in a trigger and now have it waiting until completion before the workflow completes.  I was thinking about somehow pulling the request ID after it completes and then comparing that against every object in vRA.  That doesn't seem like the most efficient way to do it though.  Is there an easier way?  Thanks for any info,

Mike

Reply
0 Kudos
3 Replies
poorem
Enthusiast
Enthusiast

Hi Mike,

You probably won't be able to change the owner of the deployment until it reaches completion. But, if you've captured the request object (i.e. a vCACCAFE:CatalogItemRequest), you can use the vRA REST client to get the provisioned resources. I'm talking vRA7.x here though. What versions are you using?

Michael

poorem
Enthusiast
Enthusiast

Assuming that we're talking v7.x, you could use the following:

// Get resources from the vRA REST client

var catalogResources = new Array();

var restClient = vraHost.createCatalogClient();

var requestService = restClient.getCatalogConsumerRequestService();

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

// Validate that resources have been found

if (resources) {

  // Process provisioned resources and return matching deployments

  for each (resource in resources) {

  if (resource.resourceTypeRef.getLabel() == "Deployment") {

  System.log("Found deployment resource matching request id " + catalogItemRequest.id)

  catalogResources.push(resource);

  }

  else {

  System.log("Skipping catalog resource for component VM");

  }

  }

}

Inputs:

     vraHost (vCACCAFE:VCACHost)

     catalogItemRequest (vCACCAFE:CatalogItemRequest)

Outputs:

     catalogResources (Array/vCACCAFE:CatalogResource)

michael_stefani
Enthusiast
Enthusiast

So I have a waiting event in my XAAS request workflow that waits until the deployment is done (it's really there so that the request the user sees doesn't show complete before the real service based request is complete).  But since that waits until completion I have a workflow run after that.  I ended up just having it compare the request ID to the request IDs of all the resources of type deployment.  Seems to be working... not sure how efficient that will be when there's 1000s of deployments though.

Reply
0 Kudos