Class: OvirtSDK4::TemplatesService
- Defined in:
- lib/ovirtsdk4/services.rb,
lib/ovirtsdk4/services.rb
Instance Method Summary collapse
-
#add(template, opts = {}) ⇒ Template
Creates a new template.
-
#list(opts = {}) ⇒ Array<Template>
Returns the list of virtual machine templates.
-
#service(path) ⇒ Service
Locates the service corresponding to the given path.
-
#template_service(id) ⇒ TemplateService
Returns a reference to the service that manages a specific virtual machine template.
Methods inherited from Service
Instance Method Details
#add(template, opts = {}) ⇒ Template
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 a virtual machine with the 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 from 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 the identifier 456, and, for that disk, you want to change the name to mydisk
the format to Copy On Write and make it sparse, send a request body like
this:
<template>
<name>mytemplate</name>
<vm id="123">
<disk_attachments>
<disk_attachment>
<disk id="456">
<name>mydisk</name>
<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>
The destination storage domain of the template can be customized, in one of two ways:
-
Globally, at the request level. The request must list the desired disk attachments to be created on the storage domain. If the disk attachments are not listed, the global storage domain parameter will be ignored.
<template> <name>mytemplate</name> <storage_domain id="123"/> <vm id="456"> <disk_attachments> <disk_attachment> <disk id="789"> <format>cow</format> <sparse>true</sparse> </disk> </disk_attachment> </disk_attachments> </vm> </template> -
Per each disk attachment. Specify the desired storage domain for each disk attachment. Specifying the global storage definition will override the storage domain per disk attachment specification.
<template> <name>mytemplate</name> <vm id="123"> <disk_attachments> <disk_attachment> <disk id="456"> <format>cow</format> <sparse>true</sparse> <storage_domains> <storage_domain id="789"/> </storage_domains> </disk> </disk_attachment> </disk_attachments> </vm> </template>
27020 27021 27022 |
# File 'lib/ovirtsdk4/services.rb', line 27020 def add(template, opts = {}) internal_add(template, Template, ADD, opts) end |
#list(opts = {}) ⇒ Array<Template>
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 is not guaranteed.
27074 27075 27076 |
# File 'lib/ovirtsdk4/services.rb', line 27074 def list(opts = {}) internal_get(LIST, opts) end |
#service(path) ⇒ Service
Locates the service corresponding to the given path.
27096 27097 27098 27099 27100 27101 27102 27103 27104 27105 |
# File 'lib/ovirtsdk4/services.rb', line 27096 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) ⇒ TemplateService
Returns a reference to the service that manages a specific virtual machine template.
27085 27086 27087 |
# File 'lib/ovirtsdk4/services.rb', line 27085 def template_service(id) TemplateService.new(self, id) end |