VMware Cloud Community
DavidHod
Contributor
Contributor
Jump to solution

Get vApp name from UUID

Hello,

I am trying to resolve some of the contents of an AMQP message we receive for a failure event. The names of some events are more helpful than the UUID. In particular, I'm looking to retrieve the vApp name (among other data) using the uuid provided. Here is a sample of the xml that is generated from the AMQP message:

<?xml version="1.0" encoding="UTF-8"?>

<vmext:Notification xmlns:vmext="http://www.vmware.com/vcloud/extension/v1.5" type="com/vmware/vcloud/event/task/complete" eventId="dfa10892-e93a-4b7d-8201-cbac0713fee3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.vmware.com/vcloud/extension/v1.5 http://172.16.254.25/api/v1.5/schema/vmwextensions.xsd">

    <vmext:Link rel="entityResolver" href="https://172.16.254.25/api/entity/"/>

    <vmext:EntityLink rel="entity" type="vcloud:task" name="vappDeploy" id="urn:vcloud:task:338bfbfa-09ee-49c3-8b49-883251099f5d"/>

    <vmext:EntityLink rel="down" type="vcloud:user" name="system" id="urn:vcloud:user:ac696d01-12d9-4763-9fd6-26a06b6a3778"/>

    <vmext:EntityLink rel="up" type="vcloud:org" name="ORG" id="urn:vcloud:org:3cde66f6-a81e-47a0-ace0-80725d158604"/>

    <vmext:EntityLink rel="task:owner" type="vcloud:vapp" id="urn:vcloud:vapp:94144a90-04f4-41c3-87a5-722d7b219634"/>

    <vmext:Timestamp>2013-07-31T16:36:28.170-04:00</vmext:Timestamp>

    <vmext:OperationSuccess>false</vmext:OperationSuccess>

</vmext:Notification>

And here is a JSON message that is also generated with the same event.

{"eventId":"dfa10892-e93a-4b7d-8201-cbac0713fee3","type":"com/vmware/vcloud/event/task/complete","operationSuccess":false,"timestamp":"2013-07-31 16:36:28.170","user":"urn:vcloud:user:ac696d01-12d9-4763-9fd6-26a06b6a3778","org":"urn:vcloud:org:3cde66f6-a81e-47a0-ace0-80725d158604","entity":"urn:vcloud:task:338bfbfa-09ee-49c3-8b49-883251099f5d","taskOwner":"urn:vcloud:vapp:94144a90-04f4-41c3-87a5-722d7b219634"}

I currently have some code in vCO that can extract the UUIDs. However, I cannot seem to figure out how to query VCloud for the object properties using the UUIDs.

Any examples on how to do this is greatly appreciated.

0 Kudos
1 Solution

Accepted Solutions
Burke-
VMware Employee
VMware Employee
Jump to solution

How about trying something like getting an object by ID... once you have the object, you can get whatever properties you like...

var vApp = Server.findForType("vCloud:VApp","urn:vcloud:vapp:94144a90-04f4-41c3-87a5-722d7b219634");

System.log("vApp Name: "+vApp.name);

I used the vApp id you showed in your post there... try this code out and see if it works...

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 vRealize Orchestrator tips and tutorials - @TechnicalValues on Twitter

View solution in original post

0 Kudos
6 Replies
Burke-
VMware Employee
VMware Employee
Jump to solution

How about trying something like getting an object by ID... once you have the object, you can get whatever properties you like...

var vApp = Server.findForType("vCloud:VApp","urn:vcloud:vapp:94144a90-04f4-41c3-87a5-722d7b219634");

System.log("vApp Name: "+vApp.name);

I used the vApp id you showed in your post there... try this code out and see if it works...

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 vRealize Orchestrator tips and tutorials - @TechnicalValues on Twitter
0 Kudos
DavidHod
Contributor
Contributor
Jump to solution

Hi Burke-

I tried your suggested code and got the following response:

Server error : ch.dunes.model.sdk.SDKFinderException: Unable to perform operation 'find('VApp', 'urn:vcloud:vapp:4cf39229-1570-4ce1-82de-74d2ab26c011')' on plugin 'vCloud' reason : 'null'

The ID is different since it's a new vApp. I have verified that the vApp exist both in vCloud and vCenter and the UUID matches.

Thanks.

0 Kudos
Burke-
VMware Employee
VMware Employee
Jump to solution

If that is a copy/paste, it seems you didn't use the correct method name - in my sample code, the method is: Server.findForType(<object type>,<object id>)

based on your error, it looks like you ran Server.find(....)...

either that OR your vCloud plug-in is returning null... not sure... If you browse your vCO Inventory, are you able to drill down through the vCloud plug-in and see the orgs, etc... ?

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 vRealize Orchestrator tips and tutorials - @TechnicalValues on Twitter
0 Kudos
Burke-
VMware Employee
VMware Employee
Jump to solution

Forgot to ask earlier... have you imported our Notifications Package (found on the Documents tab of this community) ? If not, you are missing out on a LOT of great sample code that helps deal with AMQP, notifications, object retrieval, etc...

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 vRealize Orchestrator tips and tutorials - @TechnicalValues on Twitter
0 Kudos
DavidHod
Contributor
Contributor
Jump to solution

Thanks Burke-

That worked perfectly. What I forgot to do was pass in the vCloud host object.

0 Kudos
Goran75
Contributor
Contributor
Jump to solution

Hi,

I have same problem here - cannot query vApp by id (Server error : ch.dunes.model.sdk.SDKFinderException: Unable to perform operation 'find('VApp', 'urn:vcloud:vapp:4c2744aa-357c-46f8-a28f-6c2fd7bae968')' on plugin 'vCloud').

Can you plese clarify "What I forgot to do was pass in the vCloud host object." Server.findForType doesnt require host object as parameter so how to include host object in this script?

Thank you

Goran

0 Kudos