API: How to create a template via the API ?

Latest response

Hi

 

I've been all over the API doc but I can't find anywhere that describes how to create a template (i.e. the equiv. of the Make Template button) ?

 

Any clues ?

 

Thanks

Responses

Richard,

 

To create a template using the API you'll want to use the POST method on the api/templates collection.  You'll need to specify the template name and id of the source VM.  Here is an example using curl:

 

curl --cacert $rhevm_cert -u "$user:$password" -H "Content-Type: application/xml" -X POST -d "<template><name>TestTemplate</name><vm id='3564e03a-ef1c-439c-b92b-8a4907622516'/></template>" https://$rhevm_host/api/templates

 

Creating a template is documented in the API documentation in Example 14.2.

 

https://access.redhat.com/knowledge/docs/en-US/Red_Hat_Enterprise_Virtualization/3.0/html/REST_API_Guide/chap-REST_API_Guide-Templates.html

 

Tony

Genius!  Thanks Tony.  Couldn't see for looking.