I am getting error "com.vmware.vcloud.sdk.VCloudException: Resource not found" for vdc.instantiateVappTemplate API call with vCD server 5.1.I tried this with both vCD client 1.5 and 5.1. Please advise.
Following is the code snippet
InstantiateVAppTemplateParamsType parameters = new InstantiateVAppTemplateParamsType();
parameters.setName(vappName);
parameters.setSource(vappTemplate.getReference());
parameters.setInstantiationParams(networkParams);
vdc.instantiateVappTemplate(parameters);
Reqauest URI and body:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ns6:InstantiateVAppTemplateParams xmlns="http://www.vmware.com/vcloud/versions" xmlns:ns2="http://schemas.dmtf.org/ovf/envelope/1" xmlns:ns3="http://schemas.dmtf.org/wbem/wscim/1/common" xmlns:ns4="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData" xmlns:ns5="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" xmlns:ns6="http://www.vmware.com/vcloud/v1.5" xmlns:ns7="http://www.vmware.com/schema/ovf" xmlns:ns8="http://schemas.dmtf.org/ovf/environment/1" xmlns:ns9="http://www.vmware.com/vcloud/extension/v1.5" name="vApp_amit-2">
<ns6:InstantiationParams>
<ns6:NetworkConfigSection>
<ns2:Info/>
<ns6:NetworkConfig networkName="Network1">
<ns6:Configuration>
<ns6:ParentNetwork type="application/vnd.vmware.admin.network+xml" name="Network1" href="https://vCD5.1_Server/api/admin/network/44fea373-8c51-4403-b97e-3dbc4b770eda"/>
<ns6:FenceMode>bridged</ns6:FenceMode>
</ns6:Configuration>
</ns6:NetworkConfig>
</ns6:NetworkConfigSection>
</ns6:InstantiationParams>
<ns6:Source type="application/vnd.vmware.vcloud.vAppTemplate+xml" name="Win2008R2" id="urn:vcloud:vapptemplate:a47ada7e-24b6-457f-9578-f1d2f2304dec" href="https://vCD5.1_Server/api/vAppTemplate/vappTemplate-a47ada7e-24b6-457f-9578-f1d2f2304dec"/>
</ns6:InstantiateVAppTemplateParams>
Hi,
Instead of queryReferences() use the queryIdRecords() method.
ReferenceResult refRes = queryService.queryIdRecords(QueryRecordType.ADMINORGVDC);
for (RecordResult<QueryResultAdminOrgVdcRecordType> vr : refRes.getRecords()) {
if (vr.getName().equals(vdcName)) {
vdc = Vdc.getVdcById(admin, vr.getId());
}
This way you need not worry about whether the returned reference(containing href, mediatype and name) is User API/Admin API.
ORGVDC - Org/Tenant user query - This will work if you are a Org Admin/User.
ADMINORGVDC - System Admin user query - This will work if you are a System Admin.
Regards,
Rajesh Kamal.
Hi,
The instantiate vapptemplate operation is a user API operation(vdc). I see that you are doing it as an admin API operation(admin/vdc)
In the sample code snippet -
vdc.instantiateVappTemplate(parameters);
How did you get the vdc object. Can you also post the code snippet for that.
I think you created this using Vdc helper but with an admin vdc reference. It should have been with a vdc reference.
Regards,
Rajesh Kamal.
Thanks Rajesh for the reply. You are correct i am using QueryReferenceType.ADMINORGVDC as below. Through rest i could successfully deploy a vApp after changing the url as you suggested.
ReferenceResult refRes = queryService.queryReferences(QueryReferenceType.ADMINORGVDC);
for (ReferenceType vr : refRes.getReferences()) {
if (vr.getName().equals(vdcName)) {
vdc = Vdc.getVdcByReference(admin, vr);
}
Through SDK i changed the line as below, but it didnot provide any references in the result hence vApp deploy failed. Is there any configuration issue at vCD side? Any clue?
ReferenceResult refRes = queryService.queryReferences(QueryReferenceType.ORGVDC);
Thanks,
Amit
even through rest,
https://VCD-Server/api/query?type=orgVdc doesnot return any rentries.
Wheras https://10.128.238.12/api/query?type=adminOrgVdc return the expected entries.
In vCloud portal i can see VDCs present under the organization
Hi,
Instead of queryReferences() use the queryIdRecords() method.
ReferenceResult refRes = queryService.queryIdRecords(QueryRecordType.ADMINORGVDC);
for (RecordResult<QueryResultAdminOrgVdcRecordType> vr : refRes.getRecords()) {
if (vr.getName().equals(vdcName)) {
vdc = Vdc.getVdcById(admin, vr.getId());
}
This way you need not worry about whether the returned reference(containing href, mediatype and name) is User API/Admin API.
ORGVDC - Org/Tenant user query - This will work if you are a Org Admin/User.
ADMINORGVDC - System Admin user query - This will work if you are a System Admin.
Regards,
Rajesh Kamal.
Thanks alot Rajesh.It works.
Have one more query, is there any way to get the vCenter (UUID) information in which the vAPP got deploy? i got following query but it will provide all the vCenters registerd under the vCD.
https://vCD-server/api/query?type=virtualCenter
Thanks,
Amit