atuli
Contributor
Contributor

convert string to vCAC:vCACHost type

Jump to solution

Hi All,


I have a customer who wants to trigger a vCO flow from an external source using the vCO REST API. One of the arguments sent to the vCO workflow which will be triggered, is the vCAC Host name.

My question is - since the arguments comes in as String from the REST call, how do I convert it in to a vCAC:vCACHost object so as to be used in a script within my flow.


Thanks.

0 Kudos
1 Solution

Accepted Solutions
cdecanini_
VMware Employee
VMware Employee

Your customer can either pass a string representation of the object to the REST API as described in this tutorial.

Otherwise they can pass a string containing the host id and get the matching vCACHost object in the workflow like this:

var vCACHosts = Server.findAllForType("vCACHost");

for each (var vCACHost in vCACHosts) {

  if (vCACHosts.id==histId) {

   var matchingHost = vCACHosts;

  break;

  }

}

If there were a lot of hosts then I would recommend using the entityManager to filter by ID and then converting the entities back to object with the getInventoryObject() method as described in this article.

1 problem, 3 solutions Smiley Happy

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you! Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator for vCenter Orchestrator tips and tutorials - @vCOTeam on Twitter

View solution in original post

0 Kudos
2 Replies
cdecanini_
VMware Employee
VMware Employee

Your customer can either pass a string representation of the object to the REST API as described in this tutorial.

Otherwise they can pass a string containing the host id and get the matching vCACHost object in the workflow like this:

var vCACHosts = Server.findAllForType("vCACHost");

for each (var vCACHost in vCACHosts) {

  if (vCACHosts.id==histId) {

   var matchingHost = vCACHosts;

  break;

  }

}

If there were a lot of hosts then I would recommend using the entityManager to filter by ID and then converting the entities back to object with the getInventoryObject() method as described in this article.

1 problem, 3 solutions Smiley Happy

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you! Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator for vCenter Orchestrator tips and tutorials - @vCOTeam on Twitter
0 Kudos
atuli
Contributor
Contributor

Perfect, thanks

Always a good philosophy to have more answers than questions!

0 Kudos