macadameane
Contributor
Contributor

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

Jump to solution

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)
0 Kudos
1 Solution

Accepted Solutions
jburen
Expert
Expert

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

6 Replies
jburen
Expert
Expert

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.
0 Kudos
macadameane
Contributor
Contributor

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.

0 Kudos
jburen
Expert
Expert

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.
0 Kudos
macadameane
Contributor
Contributor

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.

0 Kudos
jburen
Expert
Expert

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

macadameane
Contributor
Contributor

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

0 Kudos