Creates a new template.
This requires the `name` and `vm` elements. To identify the virtual machine use the `vm.id` or `vm.name` attributes. For example, to create a template from virtual machine with identifier `123` send a request like this:
POST /ovirt-engine/api/templates
With a request body like this:
<template>
<name>mytemplate</name> <vm id="123"/>
</template>
The disks of the template can be customized, making some of their characteristics different to the disks of the original virtual machine. To do so use the `vm.disk_attachments` attribute, specifying the identifier of the disk of the original virtual machine and the characteristics that you want to change. For example, if the original virtual machine has a disk with identifier `456`, and, for that disk, you want to change the format to <<types/disk_format, _Copy On Write_>> and make the disk <<types/disk, sparse>>, send a request body like this:
<template>
<name>mytemplate</name> <vm id="123"> <disk_attachments> <disk_attachment> <disk id="456"> <format>cow</format> <sparse>true</sparse> </disk> </disk_attachment> </disk_attachments> </vm>
</template>
The template can be created as a sub version of an existing template.This requires the `name` and `vm` attributes for the new template, and the `base_template` and `version_name` attributes for the new template version. The `base_template` and `version_name` attributes must be specified within a `version` section enclosed in the `template` section. Identify the virtual machine with the `id` or `name` attributes.
<template>
<name>mytemplate</name> <vm id="123"/> <version> <base_template id="456"/> <version_name>mytemplate_001</version_name> </version>
</template>
@param template [Template] The information about the template or template version.
@param opts [Hash] Additional options.
@option opts [Boolean] :clone_permissions Specifies if the permissions of the virtual machine should be copied to the template.
If this optional parameter is provided, and its values is `true` then the permissions of the virtual machine (only the direct ones, not the inherited ones) will be copied to the created template. For example, to create a template from the `myvm` virtual machine copying its permissions, send a request like this: [source] ---- POST /ovirt-engine/api/templates?clone_permissions=true ---- With a request body like this: [source,xml] ---- <template> <name>mytemplate<name> <vm> <name>myvm<name> </vm> </template> ----
@option opts [Boolean] :seal Seal the template.
If this optional parameter is provided and its value is `true`, then the template is sealed after creation. Sealing erases all host-specific configuration from the filesystem: SSH keys, UDEV rules, MAC addresses, system ID, hostname etc., thus making easy to use the template to create multiple virtual machines without manual intervention. Currently sealing is supported only for Linux OS.
@option opts [Hash] :headers ({}) Additional HTTP headers.
@option opts [Hash] :query ({}) Additional URL query parameters.
@option opts [Integer] :timeout (nil) The timeout for this request, in seconds. If no value is explicitly
given then the timeout set globally for the connection will be used.
@option opts [Boolean] :wait (true) If `true` wait for the response.
@return [Template]
# File lib/ovirtsdk4/services.rb, line 27013 def add(template, opts = {}) internal_add(template, Template, ADD, opts) end
Returns the list of virtual machine templates.
For example:
GET /ovirt-engine/api/templates
Will return the list of virtual machines and virtual machine templates.
The order of the returned list of templates isn't guaranteed.
@param opts [Hash] Additional options.
@option opts [Boolean] :case_sensitive Indicates if the search performed using the `search` parameter should be performed taking case into
account. The default value is `true`, which means that case is taken into account. If you want to search ignoring case set it to `false`.
@option opts [Boolean] :filter Indicates if the results should be filtered according to the permissions of the user.
@option opts [Integer] :max Sets the maximum number of templates to return. If not specified all the templates are returned.
@option opts [String] :search A query string used to restrict the returned templates.
@option opts [Hash] :headers ({}) Additional HTTP headers.
@option opts [Hash] :query ({}) Additional URL query parameters.
@option opts [Integer] :timeout (nil) The timeout for this request, in seconds. If no value is explicitly
given then the timeout set globally for the connection will be used.
@option opts [Boolean] :wait (true) If `true` wait for the response.
@return [Array<Template>]
# File lib/ovirtsdk4/services.rb, line 27063 def list(opts = {}) internal_get(LIST, opts) end
Locates the service corresponding to the given path.
@param path [String] The path of the service.
@return [Service] A reference to the service.
# File lib/ovirtsdk4/services.rb, line 27085 def service(path) if path.nil? || path == '' return self end index = path.index('/') if index.nil? return template_service(path) end return template_service(path[0..(index - 1)]).service(path[(index +1)..-1]) end
Returns a reference to the service that manages a specific virtual machine template.
@param id [String] The identifier of the `template`.
@return [TemplateService] A reference to the `template` service.
# File lib/ovirtsdk4/services.rb, line 27074 def template_service(id) TemplateService.new(self, id) end
Returns an string representation of this service.
@return [String]
# File lib/ovirtsdk4/services.rb, line 27101 def to_s "#<#{TemplatesService}:#{absolute_path}>" end