Hi,
I'm using the VCloud 1.5 plug-in to intercept some Blocking Tasks on the AMQP bus and apply some policy checks before allowing vApps to be deployed or captured in a catalog. The blocking task for the Add to Catalog comes accross as a vAppTemplate-owned blocking task. From there I can get the vdcCaptureTemplate task which has a reference to the originating vApp in its Params, but I am having trouble figuring out the right way to extract the vApp reference from the Task Params. Specifically, the VclTask class contains a getParams(Object) method call, but if i try something like:
var vApp = sourceTask.getParams(VclEntityType.VAPP);
it errors out saying: "Cannot convert vcloud:vapp to com.vmware.vmo.plugin.vcloud.model.VCloudExtensible"
This makes it look like I am supposed to send in an actual instantiated VclVApp object, but it doesn't look like the plug-in exposes a Constructor to simply create an empty VclVApp object without actually requesting an actual vApp from the VDC.
I know the Vapp reference is there in the Params because the xmlDump shows it:
<ns6:Params xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns6:CaptureVAppParamsType">
<ns6:Source type="application/vnd.vmware.vcloud.vApp+xml" name="PJTest_RHEL2" href="https://server.domain.com/api/vApp/vapp-5bb091c5-b8d0-4990-b54c-7369718b7958"/>
</ns6:Params>
Any help or ideas would be greatly appreciated.
I think that in your case it should be a VclCaptureVAppParams constructor, not a vApp one.
Christophe.
Here is what I did to get a vAppTemplate from a vApp instantiation blocking task. It may help you with adapting with the right constructir if it exists.
if (blockingTask != null) {
var task = vcdHost.getEntityByReference(VclEntityType.TASK, blockingTask.getTask());
System.log("task.href : " + task.href);
var instantiateVAppParams = task.getParams(new VclInstantiateVAppParams());
var vAppTemplateReference = instantiateVAppParams.source;
var vAppTemplate = vcdHost.getEntityByReference(VclEntityType.VAPP_TEMPLATE ,vAppTemplateReference);
//vAppTemplate Info
var vAppTemplateName = vAppTemplate.name;
var vAppTemplateDescription = vAppTemplate.description;
var vAppTemplateSize = vAppTemplate.vAppTemplateSize;
}
Thanks, I had tried this as well, which is when I found out that there is no Constructor exposed for VclVApp:
So:
var vApp = sourceTask.getParams(new VclVApp());
results in:
"Unable to create object : VclVApp : com.vmware.vmo.plugin.vcloud.model.VApp"
I don't really want to create a real vApp in the VCD just to point to it as an Object type, but maybe as a work-around I can query for one and use it as a reference...
I think that in your case it should be a VclCaptureVAppParams constructor, not a vApp one.
Christophe.
Yup, I see it now, and that works perfectly. Thank you for the pointer!