VMware {code} Community
narayani
Contributor
Contributor

Create a new Virtual machine.

I am using the v-cloud Api  version 1.5 to create a new virtual machine,I am unable to crate the new virtual machine,Iam able to create clone of a existing virtual machine.

I am using the below requset xml to create a new VM.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<RecomposeVAppParams name="vAppName">
    <SourcedItem sourceDelete="false">
        <Source type="application/vnd.vmware.vcloud.vm+xml" name="vmName" href="https://vcloud/api/vApp/vm-05f22b9c-503e-4f62-9383-79a7e4835690"/>
    </SourcedItem>
</RecomposeVAppParams>

Please help me out how we can create anew virtual machine using that API.

Thanks

Mayank sharma.

0 Kudos
9 Replies
admin
Immortal
Immortal

What is the error?

0 Kudos
narayani
Contributor
Contributor

We didn't get any error in response. But with this code i am not able to create a new VM . I want to Create a new Virtual Machine with Different Configuration. Please help me out

0 Kudos
admin
Immortal
Immortal

I am not sure if you can create a NEW VM with the API. You can reconfigure existing VMs.

One thing that comes to my mind is to create a Template with very simple VM that you will then use to create other types of VMs.

You will have to add this simple VM to a vApp and then reconfigure it to suit your needs. You will be able to change the VirtualHardwareSection, OperatingSystemSection, NetworkConnectionSection and GuestCustomizationSection. To create the template you can start with a vApp with one VM,

reconfigure that VM (so it will have very simple configuration) and then capture that vApp to a Template. Hope this helps.

0 Kudos
anouarzh
Contributor
Contributor

Hi Nayarani,

How did you manage to clone a VM inside an existing vAPP. May I see your POST?

0 Kudos
narayani
Contributor
Contributor

Ok. Thanks for your help .

Is there is any Single Request URL by which we can configure or change all the links of vm (like cpu,memory) ?

0 Kudos
admin
Immortal
Immortal

You can modify the VirtualHardwareSection at once:

<Link rel="edit" type="application/vnd.vmware.vcloud.virtualHardwareSection+xml" href="https://<ip>/api/vApp/vm-9b3ad0ef-0535-4edc-b593-7f85c2bdb749/virtualHardwareSection/"/>

Retrieve a VM and inspect its links. Read the API Documentation for more information - "Configuring vApps and Virtual Machines" on page 86.

0 Kudos
narayani
Contributor
Contributor

Thanks for your help.

Can u please help me in creating a new Vapp template. How can i create a simple Vapp template using simple VM configurations? From where i can get ovf package for creating a simple vapp template?

0 Kudos
admin
Immortal
Immortal

Just instantiate some template. Then remove all VMs from the vApp except one. Remove the networking from the VM.

Then capture this vApp back to a template and you will have pretty simple template. Then you can instantiate it and reconfigure  the VM in the vApp according to your needs. You will also be able to add new VMs from the template that you created. Look for examples in the api documentation.

0 Kudos
kirilk
VMware Employee
VMware Employee

There is a bit weird way to create VMs using vCloud APIs:

Preparation

1. Create a diskless VM inside a vApp

2. Turn vApp into template

3. Instantiate the template in to new vApp with single VM and no disks. OR use recompose to add new VM to existing vApp Or compose to add the VM into new vApp (I am not sure if you can add same VM many times in one call)

4. Add disks and update HW settings to suit your need.

If you want to strat off wihtout the preparation

1. Download the vApp OVF file using API

2. Check the OVf for any vmdl references there should be none.

3. Instead of steps #1 and #2 above upload the OVF file as template.

0 Kudos