class OvirtSDK4::TemplatesService

Constants

ADD
LIST

Public Instance Methods

add(template, opts = {}) click to toggle source

Creates a new template.

This requires the `name` and `vm` elements. Identify the virtual machine with the `id` `name` attributes.

source

POST /ovirt-engine/api/templates


With a request body like this:

source,xml

<template>

<name>mytemplate</name>
<vm id="123"/>

</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.

source,xml

<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 [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 24437
def add(template, opts = {})
  internal_add(template, Template, ADD, opts)
end
list(opts = {}) click to toggle source

Returns the list of virtual machine templates.

For example:

source

GET /ovirt-engine/api/templates


Will return the list of virtual machines and virtual machine templates.

@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 24485
def list(opts = {})
  internal_get(LIST, opts)
end
service(path) click to toggle source

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 24507
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
template_service(id) click to toggle source

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 24496
def template_service(id)
  TemplateService.new(self, id)
end
to_s() click to toggle source

Returns an string representation of this service.

@return [String]

# File lib/ovirtsdk4/services.rb, line 24523
def to_s
  "#<#{TemplatesService}:#{absolute_path}>"
end