Quantcast
Channel: VMware Communities : All Content - All Communities
Viewing all articles
Browse latest Browse all 179681

unable to create VM via vcloud API

$
0
0

Hi,

 

I have an Ubuntu template in a public catalog and I was not able to instantiate an isolated VM from it via vCloud API.

Obs: I am testing against a vCloud 9.7 instance.

 

1- instantiateVmFromTemplate API

My first attempt was to call the instantiateVmFromTemplate API with very simple XML like this:

POST https://vcd01/api/vdc/c78e7423-ef80-4d50-bbea-3d58cf188ab9/action/instantiateVmFromTemplate

'Accept: application/*+xml;version=32.0'

'Content-Type: application/vnd.vmware.vcloud.instantiateVmTemplateParams+xml'

<InstantiateVmTemplateParams xmlns="http://www.vmware.com/vcloud/v1.5" xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1" name="myUbuntu02">

    <SourcedVmTemplateItem>

        <Source href="https://vcd01/api/vAppTemplate/vappTemplate-f835057c-2138-436f-9f34-3e3008d82030" id="urn:vcloud:vapptemplate:f835057c-2138-436f-9f34-3e3008d82030"/>

    </SourcedVmTemplateItem>

</InstantiateVmTemplateParams>

 

The response was HTTP Status 400 and response XML with:

majorErrorCode="400"

message="Wrong resource type null, expected application/vnd.vmware.vcloud.vm+xml"

minorErrorCode="BAD_REQUEST"

 

2- createVM API

So I tried the createVM API again with very simple XML payload like this:

POST https://vcd01/api/vdc/c78e7423-ef80-4d50-bbea-3d58cf188ab9/action/createVm

'Accept: application/*+xml;version=32.0'

'Content-Type: application/vnd.vmware.vcloud.CreateVmParams+xml'

<CreateVmParams xmlns="http://www.vmware.com/vcloud/v1.5" xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1" xmlns:environment_1="http://schemas.dmtf.org/ovf/environment/1" name="myUbuntu01">

    <Description>created by cloud-server</Description>

    <CreateVm name="myUbuntu01"/>

</CreateVmParams>

 

The response was HTTP Status 400 and response XML with:

majorErrorCode="400"

message="[ ec1f6a9e-c519-4ae5-8d6b-ad289282e1ad ] The value for Number of CPUs must be above zero. You provided &lt;null&gt;."

minorErrorCode="BAD_REQUEST"

 

The odd part of this response is that I could not see a request parameter to fill in this information.

 

3- instantiateVAppTemplate API

Than I tried instantiateVAppTemplate API with success:

POST https://vcd01/api/vdc/c78e7423-ef80-4d50-bbea-3d58cf188ab9/action/instantiateVAppTemplate

'Accept: application/*+xml;version=32.0'

'Content-Type: application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml'

<vcloud:InstantiateVAppTemplateParams xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1" xmlns:vcloud="http://www.vmware.com/vcloud/v1.5"

        deploy="true" name="apiTest" powerOn="false">

    <vcloud:Description>my last test</vcloud:Description>

    <vcloud:Source href="https://vcd01/api/vAppTemplate/vappTemplate-f835057c-2138-436f-9f34-3e3008d82030" id="urn:vcloud:vapptemplate:f835057c-2138-436f-9f34-3e3008d82030"/>

</vcloud:InstantiateVAppTemplateParams>

 

For this one I had a HTTP Status OK and the vAPP+VM were created.

 

Conclusion

As I need to reproduce via API the vCloud web interface behaviour where we can launch a new isolated VM from an existing template (Virtual Machines -> New VM -> from template models -> select template), can anyone see what I am doing wrong?

Or it looks like a vCloud API application bug?


Viewing all articles
Browse latest Browse all 179681

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>