VMware {code} Community
macadameane
Contributor
Contributor
Jump to solution

How do I create a VM from a template using vSphere Automation Rest API?

Apologies if this discussion is in the wrong category.

 

In vSphere 6.7, I have created some predefined Linux VMs in vSphere and have converted them to templates. The rest/vcenter/vm-template/library-items path allows deployment of a library item to a VM. I created a library and cloned my templates into the library. These always clone as OVF templates.

 

When running the call in postman, I get an error back stating has type 'ovf', but needs to be of type 'vm-template'. How do I achieve this? I haven't figured out a way to either retrieve the original templates as library items (to obtain an item id) or to explicitly add new templates to a library in a way that isn't OVF.

 

Thanks!

Tags (3)
Reply
0 Kudos
1 Solution

Accepted Solutions
jburen
Expert
Expert
Jump to solution

OK. If I were you I would ask the admin what your permissions are so you can make sure you have the correct ones. Permissions to create templates and content libraries are not enough.

Consider giving Kudos if you think my response helped you in any way.

View solution in original post

7 Replies
jburen
Expert
Expert
Jump to solution

The documentation says this: When you clone a virtual machine from the vCenter Server inventory to the content library, you can choose what type of content library item to create. You can choose to create a library item of either the VM Template type or OVF Template type.

Consider giving Kudos if you think my response helped you in any way.
Reply
0 Kudos
macadameane
Contributor
Contributor
Jump to solution

In vSphere 6.7, I do not see this option.  I have attached the clone context menu.  When selecting a VM, I get the options, "Clone to Template" and "Clone to Virtual Machine".  Neither of these give options for a content library.

When I select a template in vSphere, I get a "Clone to Library" option.  This lets me select a library, but not a type of template.

Reply
0 Kudos
jburen
Expert
Expert
Jump to solution

Very strange! In my home lab, I have vCenter 7.0.1 and in the Actions of a VM I have three options: Clone to Virtual Machine, Clone to Template, and Clone as Template to Library. When I select this last option I can choose between VM Template or OVF.

I also tested this at my client with vCenter 6.7 and there I also have three options in both clients (FLEX and HTML5).

Are you sure you have the appropriate permissions? You should have the vApp - Export privilege to be able to perform "Export OVF Template" and "Clone to Template in Library" actions.

 

Consider giving Kudos if you think my response helped you in any way.
Reply
0 Kudos
macadameane
Contributor
Contributor
Jump to solution

Thanks for the reply. I don't manage the server, just use it.  I'm not sure what permissions I have, but I do know I can create templates and content libraries, I just cannot do it this way.

Reply
0 Kudos
jburen
Expert
Expert
Jump to solution

OK. If I were you I would ask the admin what your permissions are so you can make sure you have the correct ones. Permissions to create templates and content libraries are not enough.

Consider giving Kudos if you think my response helped you in any way.
macadameane
Contributor
Contributor
Jump to solution

I am able to Export to OVF, so I probably already have that permission.

Reply
0 Kudos
dthaele
Contributor
Contributor
Jump to solution

Hi,

Did you receive an answer to your basic question about to create a VM from a template using an automation API? I'm trying to understand how to do this also. I believe the VMCreateSpec format has to be followed, but I don't see where the VMtemplate can be specified?

If you have any insights to share it would be appreciated.

Thanks,

Dwayne

Reply
0 Kudos