Class: OvirtSDK4::TemplateService

Inherits:
Service
  • Object
show all
Defined in:
lib/ovirtsdk4/services.rb,
lib/ovirtsdk4/services.rb

Instance Method Summary collapse

Methods inherited from Service

#inspect, #to_s

Instance Method Details

#cdroms_serviceTemplateCdromsService

Returns a reference to the service that manages the CD-ROMs that are associated with the template.

Returns:



25884
25885
25886
# File 'lib/ovirtsdk4/services.rb', line 25884

def cdroms_service
  @cdroms_service ||= TemplateCdromsService.new(self, 'cdroms')
end

#disk_attachments_serviceTemplateDiskAttachmentsService

Returns a reference to the service that manages a specific disk attachment of the template.

Returns:



25894
25895
25896
# File 'lib/ovirtsdk4/services.rb', line 25894

def disk_attachments_service
  @disk_attachments_service ||= TemplateDiskAttachmentsService.new(self, 'diskattachments')
end

#export(opts = {}) ⇒ Object

Exports a template to the data center export domain.

For example, send the following request:

POST /ovirt-engine/api/templates/123/export

With a request body like this:

<action>
  <storage_domain id="456"/>
  <exclusive>true<exclusive/>
</action>

Parameters:

  • opts (Hash) (defaults to: {})

    Additional options.

Options Hash (opts):

  • :exclusive (Boolean)

    Indicates if the existing templates with the same name should be overwritten.

    The export action reports a failed action if a template of the same name exists in the destination domain. Set this parameter to true to change this behavior and overwrite any existing template.

  • :storage_domain (StorageDomain)

    Specifies the destination export storage domain.

  • :headers (Hash) — default: {}

    Additional HTTP headers.

  • :query (Hash) — default: {}

    Additional URL query parameters.

  • :timeout (Integer) — default: 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.

  • :wait (Boolean) — default: true

    If true wait for the response.



25677
25678
25679
# File 'lib/ovirtsdk4/services.rb', line 25677

def export(opts = {})
  internal_action(:export, nil, EXPORT, opts)
end

#export_to_export_domain(opts = {}) ⇒ Object

Exports a template to an export domain.

Parameters:

  • opts (Hash) (defaults to: {})

    Additional options.

Options Hash (opts):

  • :exclusive (Boolean)

    Indicates if the existing templates with the same name should be overwritten.

    The export action reports a failed action if a template of the same name exists in the destination domain. Set this parameter to true to change this behavior and overwrite any existing template.

  • :storage_domain (StorageDomain)

    Specifies the destination export storage domain.

  • :headers (Hash) — default: {}

    Additional HTTP headers.

  • :query (Hash) — default: {}

    Additional URL query parameters.

  • :timeout (Integer) — default: 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.

  • :wait (Boolean) — default: true

    If true wait for the response.



25771
25772
25773
# File 'lib/ovirtsdk4/services.rb', line 25771

def export_to_export_domain(opts = {})
  internal_action(:export, nil, EXPORT_TO_EXPORT_DOMAIN, opts)
end

#export_to_path_on_host(opts = {}) ⇒ Object

Exports a template as an OVA file to a given path on a specified host.

Parameters:

  • opts (Hash) (defaults to: {})

    Additional options.

Options Hash (opts):

  • :directory (String)

    An absolute path of a directory on the host to generate the OVA file in.

  • :exclusive (Boolean)

    Indicates if the existing templates with the same name should be overwritten.

    The export action reports a failed action if a template of the same name exists in the destination domain. Set this parameter to true to change this behavior and overwrite any existing template.

  • :filename (String)

    The name of the OVA file.

    This is an optional parameter. If it is not specified, the name of the OVA file is determined according to the name of the template. It will conform to the following pattern: "<template name>.ova".

  • :host (Host)

    The host to generate the OVA file on.

  • :storage_domain (StorageDomain)

    Specifies the destination export storage domain.

  • :headers (Hash) — default: {}

    Additional HTTP headers.

  • :query (Hash) — default: {}

    Additional URL query parameters.

  • :timeout (Integer) — default: 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.

  • :wait (Boolean) — default: true

    If true wait for the response.



25815
25816
25817
# File 'lib/ovirtsdk4/services.rb', line 25815

def export_to_path_on_host(opts = {})
  internal_action(:export, nil, EXPORT_TO_PATH_ON_HOST, opts)
end

#get(opts = {}) ⇒ Template

Returns the information about this template or template version.

Parameters:

  • opts (Hash) (defaults to: {})

    Additional options.

Options Hash (opts):

  • :filter (Boolean)

    Indicates if the results should be filtered according to the permissions of the user.

  • :follow (String)

    Indicates which inner links should be followed. The objects referenced by these links will be fetched as part of the current request. See here for details.

  • :headers (Hash) — default: {}

    Additional HTTP headers.

  • :query (Hash) — default: {}

    Additional URL query parameters.

  • :timeout (Integer) — default: 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.

  • :wait (Boolean) — default: true

    If true wait for the response.

Returns:



25709
25710
25711
# File 'lib/ovirtsdk4/services.rb', line 25709

def get(opts = {})
  internal_get(GET, opts)
end

#graphics_consoles_serviceTemplateGraphicsConsolesService

Returns a reference to the service that manages the graphical consoles that are associated with the template.

Returns:



25903
25904
25905
# File 'lib/ovirtsdk4/services.rb', line 25903

def graphics_consoles_service
  @graphics_consoles_service ||= TemplateGraphicsConsolesService.new(self, 'graphicsconsoles')
end

#nics_serviceTemplateNicsService

Returns a reference to the service that manages the NICs that are associated with the template.

Returns:



25912
25913
25914
# File 'lib/ovirtsdk4/services.rb', line 25912

def nics_service
  @nics_service ||= TemplateNicsService.new(self, 'nics')
end

#permissions_serviceAssignedPermissionsService

Returns a reference to the service that manages the permissions that are associated with the template.

Returns:



25921
25922
25923
# File 'lib/ovirtsdk4/services.rb', line 25921

def permissions_service
  @permissions_service ||= AssignedPermissionsService.new(self, 'permissions')
end

#remove(opts = {}) ⇒ Object

Removes a virtual machine template.

DELETE /ovirt-engine/api/templates/123

Parameters:

  • opts (Hash) (defaults to: {})

    Additional options.

Options Hash (opts):

  • :async (Boolean)

    Indicates if the removal should be performed asynchronously.

  • :headers (Hash) — default: {}

    Additional HTTP headers.

  • :query (Hash) — default: {}

    Additional URL query parameters.

  • :timeout (Integer) — default: 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.

  • :wait (Boolean) — default: true

    If true wait for the response.



25739
25740
25741
# File 'lib/ovirtsdk4/services.rb', line 25739

def remove(opts = {})
  internal_remove(REMOVE, opts)
end

#service(path) ⇒ Service

Locates the service corresponding to the given path.

Parameters:

  • path (String)

    The path of the service.

Returns:

  • (Service)

    A reference to the service.

Raises:



25950
25951
25952
25953
25954
25955
25956
25957
25958
25959
25960
25961
25962
25963
25964
25965
25966
25967
25968
25969
25970
25971
25972
25973
25974
25975
25976
25977
25978
25979
25980
25981
25982
25983
25984
25985
25986
25987
25988
25989
25990
25991
25992
25993
25994
25995
25996
25997
# File 'lib/ovirtsdk4/services.rb', line 25950

def service(path)
  if path.nil? || path == ''
    return self
  end
  if path == 'cdroms'
    return cdroms_service
  end
  if path.start_with?('cdroms/')
    return cdroms_service.service(path[7..-1])
  end
  if path == 'diskattachments'
    return disk_attachments_service
  end
  if path.start_with?('diskattachments/')
    return disk_attachments_service.service(path[16..-1])
  end
  if path == 'graphicsconsoles'
    return graphics_consoles_service
  end
  if path.start_with?('graphicsconsoles/')
    return graphics_consoles_service.service(path[17..-1])
  end
  if path == 'nics'
    return nics_service
  end
  if path.start_with?('nics/')
    return nics_service.service(path[5..-1])
  end
  if path == 'permissions'
    return permissions_service
  end
  if path.start_with?('permissions/')
    return permissions_service.service(path[12..-1])
  end
  if path == 'tags'
    return tags_service
  end
  if path.start_with?('tags/')
    return tags_service.service(path[5..-1])
  end
  if path == 'watchdogs'
    return watchdogs_service
  end
  if path.start_with?('watchdogs/')
    return watchdogs_service.service(path[10..-1])
  end
  raise Error.new("The path \"#{path}\" doesn't correspond to any service")
end

#tags_serviceAssignedTagsService

Returns a reference to the service that manages the tags that are associated with the template.

Returns:



25930
25931
25932
# File 'lib/ovirtsdk4/services.rb', line 25930

def tags_service
  @tags_service ||= AssignedTagsService.new(self, 'tags')
end

#update(template, opts = {}) ⇒ Template

Updates the template.

The name, description, type, memory, cpu, topology, os, high_availability, display, stateless, usb, and timezone elements can be updated after a template has been created.

For example, to update a template so that it has 1 GiB of memory send a request like this:

PUT /ovirt-engine/api/templates/123

With the following request body:

<template>
  <memory>1073741824</memory>
</template>

The version_name name attribute is the only one that can be updated within the version attribute used for template versions:

<template>
  <version>
    <version_name>mytemplate_2</version_name>
  </version>
</template>

Parameters:

  • template (Template)

    The template to update.

  • opts (Hash) (defaults to: {})

    Additional options.

Options Hash (opts):

  • :async (Boolean)

    Indicates if the update should be performed asynchronously.

  • :headers (Hash) — default: {}

    Additional HTTP headers.

  • :query (Hash) — default: {}

    Additional URL query parameters.

  • :timeout (Integer) — default: 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.

  • :wait (Boolean) — default: true

    If true wait for the response.

Returns:



25875
25876
25877
# File 'lib/ovirtsdk4/services.rb', line 25875

def update(template, opts = {})
  internal_update(template, Template, UPDATE, opts)
end

#watchdogs_serviceTemplateWatchdogsService

Returns a reference to the service that manages the watchdogs that are associated with the template.

Returns:



25939
25940
25941
# File 'lib/ovirtsdk4/services.rb', line 25939

def watchdogs_service
  @watchdogs_service ||= TemplateWatchdogsService.new(self, 'watchdogs')
end