VMware Cloud Community
seizadi
Contributor
Contributor

How to get object using href for vCloud Director Plugin

I am trying to figure out how to get an object using href for vCloud Director, using the vCD plugin.

A sample for href is below:

href = "https://10.70.2.11/api/v1.0/vApp/vapp-a917163a-f5bc-424e-9c43-82025ff7d2bf";

I am trying to use the VclHost->getEntityByReference() to do this, the piece I am missing is how to create the VclReference object?

Thanks,

-Soheil

0 Kudos
2 Replies
cdecanini_
VMware Employee
VMware Employee

You need to create the object:

var myVclReference = new VclReference();

myVclReference.href = href;

myVclReference.name = "test"

myVclReference.type = "application/vnd.vmware.vcloud.vApp+xml";

vApp = vcdHost.getEntityByReference("vcloud:vapp",myVclReference);

Christophe.

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
seizadi
Contributor
Contributor

When I use the constructor in the answer I get error:

[2011-10-11 13:29:59.260] [I] Unable to create object : VclReference : com.vmware.vmo.plugin.vcloud.model.Reference

Also the attributes for VclReference are marked as read-only. I used the following constructor to create the VclReference and printed the attributes to make sure they were set properly.

var myVclReference = new VclReference(href, "vapphttpsvr1", "application/vnd.vmware.vcloud.vApp+xml");
System.log (myVclReference.href);
System.log (myVclReference.name);
System.log (myVclReference.type);

The call to get vapp fails and returns a null pointer for the vApp:

vapp = vcd.getEntityByReference("vcloud:vapp", myVclReference);

System.log (vapp.getReference().name);

I can walk the inventory tree and find the vApp using the href above. What is the next step in debugging this?

-Soheil

0 Kudos