Class: OvirtSDK4::VmService

Inherits:
MeasurableService 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

#affinity_labels_serviceAssignedAffinityLabelsService

List of scheduling labels assigned to this virtual machine.

Returns:



31521
31522
31523
# File 'lib/ovirtsdk4/services.rb', line 31521

def affinity_labels_service
  @affinity_labels_service ||= AssignedAffinityLabelsService.new(self, 'affinitylabels')
end

#applications_serviceVmApplicationsService

Locates the applications service.

Returns:



31530
31531
31532
# File 'lib/ovirtsdk4/services.rb', line 31530

def applications_service
  @applications_service ||= VmApplicationsService.new(self, 'applications')
end

#auto_pin_cpu_and_numa_nodes(opts = {}) ⇒ Object

Apply an automatic CPU and NUMA configuration on the VM.

Important
Since version 4.5 of the engine this operation is deprecated, and preserved only for backwards compatibility. It will be removed in the future. Instead please use PUT followed by update operation.

An example for a request:

POST /ovirt-engine/api/vms/123/autopincpuandnumanodes

With a request body like this:

<action>
  <optimize_cpu_settings>true</optimize_cpu_settings>
</action>

Parameters:

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

    Additional options.

Options Hash (opts):

  • :async (Boolean)

    Indicates if the detach action should be performed asynchronously.

  • :optimize_cpu_settings (Boolean)

    Specifies how the auto CPU and NUMA configuration is applied. If set to true, will adjust the CPU topology to fit the VM pinned host hardware. Otherwise, it will use the VM CPU topology.

  • :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.



30197
30198
30199
# File 'lib/ovirtsdk4/services.rb', line 30197

def auto_pin_cpu_and_numa_nodes(opts = {})
  internal_action(:autopincpuandnumanodes, nil, AUTO_PIN_CPU_AND_NUMA_NODES, opts)
end

#backups_serviceVmBackupsService

List of backups of this virtual machine.

Returns:



31539
31540
31541
# File 'lib/ovirtsdk4/services.rb', line 31539

def backups_service
  @backups_service ||= VmBackupsService.new(self, 'backups')
end

#cancel_migration(opts = {}) ⇒ Object

This operation stops any migration of a virtual machine to another physical host.

POST /ovirt-engine/api/vms/123/cancelmigration

The cancel migration action does not take any action specific parameters; therefore, the request body should contain an empty action:

<action/>

Parameters:

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

    Additional options.

Options Hash (opts):

  • :async (Boolean)

    Indicates if the migration should cancelled 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.



30236
30237
30238
# File 'lib/ovirtsdk4/services.rb', line 30236

def cancel_migration(opts = {})
  internal_action(:cancelmigration, nil, CANCEL_MIGRATION, opts)
end

#cdroms_serviceVmCdromsService

Locates the cdroms service.

Returns:



31548
31549
31550
# File 'lib/ovirtsdk4/services.rb', line 31548

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

#checkpoints_serviceVmCheckpointsService

List of checkpoints of this virtual machine.

Returns:



31557
31558
31559
# File 'lib/ovirtsdk4/services.rb', line 31557

def checkpoints_service
  @checkpoints_service ||= VmCheckpointsService.new(self, 'checkpoints')
end

#clone(opts = {}) ⇒ Object

Executes the clone method.

Parameters:

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

    Additional options.

Options Hash (opts):

  • :async (Boolean)

    Indicates if the clone should be performed asynchronously.

  • :discard_snapshots (Boolean)

    Use the discard_snapshots parameter when the virtual machine should be clone with its snapshots collapsed. Default is true.

  • :storage_domain (StorageDomain)

    The storage domain on which the virtual machines disks will be copied to.

  • :vm (Vm)
  • :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.



30272
30273
30274
# File 'lib/ovirtsdk4/services.rb', line 30272

def clone(opts = {})
  internal_action(:clone, nil, CLONE, opts)
end

#commit_snapshot(opts = {}) ⇒ Object

Permanently restores the virtual machine to the state of the previewed snapshot.

See the preview_snapshot operation for details.

Parameters:

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

    Additional options.

Options Hash (opts):

  • :async (Boolean)

    Indicates if the snapshots should be committed 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.



30300
30301
30302
# File 'lib/ovirtsdk4/services.rb', line 30300

def commit_snapshot(opts = {})
  internal_action(:commitsnapshot, nil, COMMIT_SNAPSHOT, opts)
end

#detach(opts = {}) ⇒ Object

Detaches a virtual machine from a pool.

POST /ovirt-engine/api/vms/123/detach

The detach action does not take any action specific parameters; therefore, the request body should contain an empty action:

<action/>

Parameters:

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

    Additional options.

Options Hash (opts):

  • :async (Boolean)

    Indicates if the detach action 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.



30339
30340
30341
# File 'lib/ovirtsdk4/services.rb', line 30339

def detach(opts = {})
  internal_action(:detach, nil, DETACH, opts)
end

#disk_attachments_serviceDiskAttachmentsService

List of disks attached to this virtual machine.

Returns:



31566
31567
31568
# File 'lib/ovirtsdk4/services.rb', line 31566

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

#export(opts = {}) ⇒ Object

Exports the virtual machine.

A virtual machine can be exported to an export domain. For example, to export virtual machine 123 to the export domain myexport:

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

With a request body like this:

<action>
  <storage_domain>
    <name>myexport</name>
  </storage_domain>
  <exclusive>true</exclusive>
  <discard_snapshots>true</discard_snapshots>
</action>

Since version 4.2 of the engine it is also possible to export a virtual machine as a virtual appliance (OVA). For example, to export virtual machine 123 as an OVA file named myvm.ova that is placed in the directory /home/ovirt/ on host myhost:

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

With a request body like this:

<action>
  <host>
    <name>myhost</name>
  </host>
  <directory>/home/ovirt</directory>
  <filename>myvm.ova</filename>
</action>
Note
Confirm that the export operation has completed before attempting any actions on the export domain.

Parameters:

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

    Additional options.

Options Hash (opts):

  • :async (Boolean)

    Indicates if the export should be performed asynchronously.

  • :discard_snapshots (Boolean)

    Use the discard_snapshots parameter when the virtual machine should be exported with all of its snapshots collapsed.

  • :exclusive (Boolean)

    Use the exclusive parameter when the virtual machine should be exported even if another copy of it already exists in the export domain (override).

  • :storage_domain (StorageDomain)

    The (export) storage domain to export the virtual machine to.

  • :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.



30420
30421
30422
# File 'lib/ovirtsdk4/services.rb', line 30420

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

#export_to_export_domain(opts = {}) ⇒ Object

Exports a virtual machine to an export domain.

Parameters:

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

    Additional options.

Options Hash (opts):

  • :async (Boolean)

    Indicates if the export should be performed asynchronously.

  • :discard_snapshots (Boolean)

    Use the discard_snapshots parameter when the virtual machine should be exported with all of its snapshots collapsed.

  • :exclusive (Boolean)

    Use the exclusive parameter when the virtual machine should be exported even if another copy of it already exists in the export domain (override).

  • :storage_domain (StorageDomain)

    The (export) storage domain to export the virtual machine to.

  • :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.



31401
31402
31403
# File 'lib/ovirtsdk4/services.rb', line 31401

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 virtual machine as an OVA file to a given path on a specified host.

Parameters:

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

    Additional options.

Options Hash (opts):

  • :async (Boolean)

    Indicates if the export should be performed asynchronously.

  • :directory (String)

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

  • :discard_snapshots (Boolean)

    Use the discard_snapshots parameter when the virtual machine should be exported with all of its snapshots collapsed.

  • :exclusive (Boolean)

    Use the exclusive parameter when the virtual machine should be exported even if another copy of it already exists in the export domain (override).

  • :filename (String)

    The name of the OVA file.

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

  • :host (Host)

    The host to generate the OVA file on.

  • :storage_domain (StorageDomain)

    The (export) storage domain to export the virtual machine to.

  • :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.



31450
31451
31452
# File 'lib/ovirtsdk4/services.rb', line 31450

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

#freeze_filesystems(opts = {}) ⇒ Object

Freezes virtual machine file systems.

This operation freezes a virtual machine’s file systems using the QEMU guest agent when taking a live snapshot of a running virtual machine. Normally, this is done automatically by the manager, but this must be executed manually with the API for virtual machines using OpenStack Volume (Cinder) disks.

Example:

POST /ovirt-engine/api/vms/123/freezefilesystems
<action/>

Parameters:

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

    Additional options.

Options Hash (opts):

  • :async (Boolean)

    Indicates if the freeze 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.



30462
30463
30464
# File 'lib/ovirtsdk4/services.rb', line 30462

def freeze_filesystems(opts = {})
  internal_action(:freezefilesystems, nil, FREEZE_FILESYSTEMS, opts)
end

#get(opts = {}) ⇒ Vm

Retrieves the description of the virtual machine.

Parameters:

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

    Additional options.

Options Hash (opts):

  • :all_content (Boolean)

    Indicates if all of the attributes of the virtual machine should be included in the response.

    By default the following attributes are excluded:

    • console

    • initialization.configuration.data - The OVF document describing the virtual machine.

    • rng_source

    • soundcard

    • virtio_scsi

    For example, to retrieve the complete representation of the virtual machine '123':

    GET /ovirt-engine/api/vms/123?all_content=true
    Note
    These attributes are not included by default as they reduce performance. These attributes are seldom used and require additional queries to the database. Only use this parameter when required as it will reduce performance.
  • :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.

  • :next_run (Boolean)

    Indicates if the returned result describes the virtual machine as it is currently running or if describes the virtual machine with the modifications that have already been performed but that will only come into effect when the virtual machine is restarted. By default the value is false.

    If the parameter is included in the request, but without a value, it is assumed that the value is true. The the following request:

    GET /vms/{vm:id};next_run

    Is equivalent to using the value true:

    GET /vms/{vm:id};next_run=true
  • :ovf_as_ova (Boolean)

    Indicates if the results should expose the OVF as it appears in OVA files of that VM. The OVF document describing the virtual machine. This parameter will work only when all_content=True is set. The OVF will be presented in initialization.configuration.data.

    For example:

    GET /vms/{vm:id}?all_content=true&ovf_as_ova=true
  • :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:



30545
30546
30547
# File 'lib/ovirtsdk4/services.rb', line 30545

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

#graphics_consoles_serviceVmGraphicsConsolesService

Locates the graphics_consoles service.

Returns:



31575
31576
31577
# File 'lib/ovirtsdk4/services.rb', line 31575

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

#host_devices_serviceVmHostDevicesService

Locates the host_devices service.

Returns:



31584
31585
31586
# File 'lib/ovirtsdk4/services.rb', line 31584

def host_devices_service
  @host_devices_service ||= VmHostDevicesService.new(self, 'hostdevices')
end

#katello_errata_serviceKatelloErrataService

Reference to the service that can show the applicable errata available on the virtual machine. This information is taken from Katello.

Returns:



31594
31595
31596
# File 'lib/ovirtsdk4/services.rb', line 31594

def katello_errata_service
  @katello_errata_service ||= KatelloErrataService.new(self, 'katelloerrata')
end

#logon(opts = {}) ⇒ Object

Initiates the automatic user logon to access a virtual machine from an external console.

This action requires the ovirt-guest-agent-gdm-plugin and the ovirt-guest-agent-pam-module packages to be installed and the ovirt-guest-agent service to be running on the virtual machine.

Users require the appropriate user permissions for the virtual machine in order to access the virtual machine from an external console.

For example:

POST /ovirt-engine/api/vms/123/logon

Request body:

<action/>

Parameters:

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

    Additional options.

Options Hash (opts):

  • :async (Boolean)

    Indicates if the logon 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.



30591
30592
30593
# File 'lib/ovirtsdk4/services.rb', line 30591

def logon(opts = {})
  internal_action(:logon, nil, LOGON, opts)
end

#maintenance(opts = {}) ⇒ Object

Sets the global maintenance mode on the hosted engine virtual machine.

This action has no effect on other virtual machines.

Example:

POST /ovirt-engine/api/vms/123/maintenance
<action>
  <maintenance_enabled>true<maintenance_enabled/>
</action>

Parameters:

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

    Additional options.

Options Hash (opts):

  • :async (Boolean)

    Indicates if the global maintenance action should be performed asynchronously.

  • :maintenance_enabled (Boolean)

    Indicates if global maintenance should be enabled or disabled.

  • :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.



30636
30637
30638
# File 'lib/ovirtsdk4/services.rb', line 30636

def maintenance(opts = {})
  internal_action(:maintenance, nil, MAINTENANCE, opts)
end

#mediated_devices_serviceVmMediatedDevicesService

Reference to the service that manages mediated devices associated with the VM.

Returns:



31603
31604
31605
# File 'lib/ovirtsdk4/services.rb', line 31603

def mediated_devices_service
  @mediated_devices_service ||= VmMediatedDevicesService.new(self, 'mediateddevices')
end

#migrate(opts = {}) ⇒ Object

Migrates a virtual machine to another physical host.

Example:

POST /ovirt-engine/api/vms/123/migrate

To specify a specific host to migrate the virtual machine to:

<action>
  <host id="2ab5e1da-b726-4274-bbf7-0a42b16a0fc3"/>
</action>

Parameters:

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

    Additional options.

Options Hash (opts):

  • :async (Boolean)

    Indicates if the migration should be performed asynchronously.

  • :cluster (Cluster)

    Specifies the cluster the virtual machine should migrate to. This is an optional parameter. By default, the virtual machine is migrated to another host within the same cluster.

    Warning
    Live migration to another cluster is not supported. Strongly consider the target cluster’s hardware architecture and network architecture before attempting a migration.
  • :force (Boolean)

    Specifies that the virtual machine should migrate even if the virtual machine is defined as non-migratable. This is an optional parameter. By default, it is set to false.

  • :host (Host)

    Specifies a specific host that the virtual machine should migrate to. This is an optional parameter. By default, the engine-name automatically selects a default host for migration within the same cluster. If an API user requires a specific host, the user can specify the host with either an id or name parameter.

  • :migrate_vms_in_affinity_closure (Boolean)

    Migrate also all other virtual machines in positive enforcing affinity groups with this virtual machine, that are running on the same host.

    The default value is false.

  • :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.



30700
30701
30702
# File 'lib/ovirtsdk4/services.rb', line 30700

def migrate(opts = {})
  internal_action(:migrate, nil, MIGRATE, opts)
end

#nics_serviceVmNicsService

Locates the nics service.

Returns:



31612
31613
31614
# File 'lib/ovirtsdk4/services.rb', line 31612

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

#numa_nodes_serviceVmNumaNodesService

Locates the numa_nodes service.

Returns:



31621
31622
31623
# File 'lib/ovirtsdk4/services.rb', line 31621

def numa_nodes_service
  @numa_nodes_service ||= VmNumaNodesService.new(self, 'numanodes')
end

#permissions_serviceAssignedPermissionsService

Locates the permissions service.

Returns:



31630
31631
31632
# File 'lib/ovirtsdk4/services.rb', line 31630

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

#preview_snapshot(opts = {}) ⇒ Object

Temporarily restores the virtual machine to the state of a snapshot.

The snapshot is indicated with the snapshot.id parameter. It is restored temporarily, so that the content can be inspected. Once that inspection is finished, the state of the virtual machine can be made permanent, using the commit_snapshot method, or discarded using the undo_snapshot method.

Parameters:

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

    Additional options.

Options Hash (opts):

  • :async (Boolean)

    Indicates if the preview should be performed asynchronously.

  • :disks (Array<Disk>)

    Specify the disks included in the snapshot’s preview.

    For each disk parameter, it is also required to specify its image_id.

    For example, to preview a snapshot with identifier 456 which includes a disk with identifier 111 and its image_id as 222, send a request like this:

    POST /ovirt-engine/api/vms/123/previewsnapshot

    Request body:

    <action>
      <disks>
        <disk id="111">
          <image_id>222</image_id>
        </disk>
      </disks>
      <snapshot id="456"/>
    </action>
  • :lease (StorageDomainLease)

    Specify the lease storage domain ID to use in the preview of the snapshot. If lease parameter is not passed, then the previewed snapshot lease storage domain will be used. If lease parameter is passed with empty storage domain parameter, then no lease will be used for the snapshot preview. If lease parameter is passed with storage domain parameter then the storage domain ID can be only one of the leases domain IDs that belongs to one of the virtual machine snapshots. This is an optional parameter, set by default to null

  • :restore_memory (Boolean)
  • :snapshot (Snapshot)
  • :vm (Vm)
  • :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.



30776
30777
30778
# File 'lib/ovirtsdk4/services.rb', line 30776

def preview_snapshot(opts = {})
  internal_action(:previewsnapshot, nil, PREVIEW_SNAPSHOT, opts)
end

#reboot(opts = {}) ⇒ Object

Sends a reboot request to a virtual machine.

For example:

POST /ovirt-engine/api/vms/123/reboot

The reboot action does not take any action specific parameters; therefore, the request body should contain an empty action:

<action/>

To reboot the VM even if a backup is running for it, the action should include the 'force' element.

For example, to force reboot virtual machine 123:

POST /ovirt-engine/api/vms/123/reboot
<action>
    <force>true</force>
</action>

Parameters:

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

    Additional options.

Options Hash (opts):

  • :async (Boolean)

    Indicates if the reboot should be performed asynchronously.

  • :force (Boolean)

    Indicates if the VM should be forcibly rebooted even if a backup is running for it.

  • :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.



30837
30838
30839
# File 'lib/ovirtsdk4/services.rb', line 30837

def reboot(opts = {})
  internal_action(:reboot, nil, REBOOT, opts)
end

#remove(opts = {}) ⇒ Object

Removes the virtual machine, including the virtual disks attached to it.

For example, to remove the virtual machine with identifier 123:

DELETE /ovirt-engine/api/vms/123

Parameters:

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

    Additional options.

Options Hash (opts):

  • :async (Boolean)

    Indicates if the remove should be performed asynchronously.

  • :detach_only (Boolean)

    Indicates if the attached virtual disks should be detached first and preserved instead of being removed.

  • :force (Boolean)

    Indicates if the virtual machine should be forcibly removed.

    Locked virtual machines and virtual machines with locked disk images cannot be removed without this flag set to true.

  • :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.



30876
30877
30878
# File 'lib/ovirtsdk4/services.rb', line 30876

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

#reorder_mac_addresses(opts = {}) ⇒ Object

Executes the reorder_mac_addresses method.

Parameters:

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

    Additional options.

Options Hash (opts):

  • :async (Boolean)

    Indicates if the action 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.



30902
30903
30904
# File 'lib/ovirtsdk4/services.rb', line 30902

def reorder_mac_addresses(opts = {})
  internal_action(:reordermacaddresses, nil, REORDER_MAC_ADDRESSES, opts)
end

#reported_devices_serviceVmReportedDevicesService

Locates the reported_devices service.

Returns:



31639
31640
31641
# File 'lib/ovirtsdk4/services.rb', line 31639

def reported_devices_service
  @reported_devices_service ||= VmReportedDevicesService.new(self, 'reporteddevices')
end

#reset(opts = {}) ⇒ Object

Sends a reset request to a virtual machine.

For example:

POST /ovirt-engine/api/vms/123/reset

The reset action does not take any action specific parameters; therefore, the request body should contain an empty action:

<action/>

Parameters:

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

    Additional options.

Options Hash (opts):

  • :async (Boolean)

    Indicates if the reset 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.



30943
30944
30945
# File 'lib/ovirtsdk4/services.rb', line 30943

def reset(opts = {})
  internal_action(:reset, nil, RESET, opts)
end

#screenshot(opts = {}) ⇒ Object

Captures screenshot of the current state of the VM.

For example:

POST /ovirt-engine/api/vms/123/screenshot

The screenshot action does not take any action specific parameters; therefore, the request body should contain an empty action:

<action/>

Parameters:

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

    Additional options.

Options Hash (opts):

  • :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.



30983
30984
30985
# File 'lib/ovirtsdk4/services.rb', line 30983

def screenshot(opts = {})
  internal_action(:screenshot, nil, SCREENSHOT, 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:



31695
31696
31697
31698
31699
31700
31701
31702
31703
31704
31705
31706
31707
31708
31709
31710
31711
31712
31713
31714
31715
31716
31717
31718
31719
31720
31721
31722
31723
31724
31725
31726
31727
31728
31729
31730
31731
31732
31733
31734
31735
31736
31737
31738
31739
31740
31741
31742
31743
31744
31745
31746
31747
31748
31749
31750
31751
31752
31753
31754
31755
31756
31757
31758
31759
31760
31761
31762
31763
31764
31765
31766
31767
31768
31769
31770
31771
31772
31773
31774
31775
31776
31777
31778
31779
31780
31781
31782
31783
31784
31785
31786
31787
31788
31789
31790
31791
31792
31793
31794
31795
31796
31797
31798
31799
31800
31801
31802
31803
31804
31805
31806
31807
31808
31809
31810
31811
31812
31813
31814
# File 'lib/ovirtsdk4/services.rb', line 31695

def service(path)
  if path.nil? || path == ''
    return self
  end
  if path == 'affinitylabels'
    return affinity_labels_service
  end
  if path.start_with?('affinitylabels/')
    return affinity_labels_service.service(path[15..-1])
  end
  if path == 'applications'
    return applications_service
  end
  if path.start_with?('applications/')
    return applications_service.service(path[13..-1])
  end
  if path == 'backups'
    return backups_service
  end
  if path.start_with?('backups/')
    return backups_service.service(path[8..-1])
  end
  if path == 'cdroms'
    return cdroms_service
  end
  if path.start_with?('cdroms/')
    return cdroms_service.service(path[7..-1])
  end
  if path == 'checkpoints'
    return checkpoints_service
  end
  if path.start_with?('checkpoints/')
    return checkpoints_service.service(path[12..-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 == 'hostdevices'
    return host_devices_service
  end
  if path.start_with?('hostdevices/')
    return host_devices_service.service(path[12..-1])
  end
  if path == 'katelloerrata'
    return katello_errata_service
  end
  if path.start_with?('katelloerrata/')
    return katello_errata_service.service(path[14..-1])
  end
  if path == 'mediateddevices'
    return mediated_devices_service
  end
  if path.start_with?('mediateddevices/')
    return mediated_devices_service.service(path[16..-1])
  end
  if path == 'nics'
    return nics_service
  end
  if path.start_with?('nics/')
    return nics_service.service(path[5..-1])
  end
  if path == 'numanodes'
    return numa_nodes_service
  end
  if path.start_with?('numanodes/')
    return numa_nodes_service.service(path[10..-1])
  end
  if path == 'permissions'
    return permissions_service
  end
  if path.start_with?('permissions/')
    return permissions_service.service(path[12..-1])
  end
  if path == 'reporteddevices'
    return reported_devices_service
  end
  if path.start_with?('reporteddevices/')
    return reported_devices_service.service(path[16..-1])
  end
  if path == 'sessions'
    return sessions_service
  end
  if path.start_with?('sessions/')
    return sessions_service.service(path[9..-1])
  end
  if path == 'snapshots'
    return snapshots_service
  end
  if path.start_with?('snapshots/')
    return snapshots_service.service(path[10..-1])
  end
  if path == 'statistics'
    return statistics_service
  end
  if path.start_with?('statistics/')
    return statistics_service.service(path[11..-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

#sessions_serviceVmSessionsService

Reference to the service that provides information about virtual machine user sessions.

Returns:



31648
31649
31650
# File 'lib/ovirtsdk4/services.rb', line 31648

def sessions_service
  @sessions_service ||= VmSessionsService.new(self, 'sessions')
end

#shutdown(opts = {}) ⇒ Object

This operation sends a shutdown request to a virtual machine.

For example:

POST /ovirt-engine/api/vms/123/shutdown

The shutdown action does not take any action specific parameters; therefore, the request body should contain an empty action:

<action/>

To shutdown the VM even if a backup is running for it, the action should include the 'force' element.

For example, to force shutdown virtual machine 123:

POST /ovirt-engine/api/vms/123/shutdown
<action>
    <force>true</force>
</action>

Parameters:

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

    Additional options.

Options Hash (opts):

  • :async (Boolean)

    Indicates if the shutdown should be performed asynchronously.

  • :force (Boolean)

    Indicates if the VM should be forcibly shutdown even if a backup is running for it.

  • :reason (String)

    The reason the virtual machine was stopped. Optionally set by user when shutting down the virtual machine.

  • :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.



31048
31049
31050
# File 'lib/ovirtsdk4/services.rb', line 31048

def shutdown(opts = {})
  internal_action(:shutdown, nil, SHUTDOWN, opts)
end

#snapshots_serviceSnapshotsService

Locates the snapshots service.

Returns:



31657
31658
31659
# File 'lib/ovirtsdk4/services.rb', line 31657

def snapshots_service
  @snapshots_service ||= SnapshotsService.new(self, 'snapshots')
end

#start(opts = {}) ⇒ Object

Starts the virtual machine.

If the virtual environment is complete and the virtual machine contains all necessary components to function, it can be started.

This example starts the virtual machine:

POST /ovirt-engine/api/vms/123/start

With a request body:

<action/>

Parameters:

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

    Additional options.

Options Hash (opts):

  • :async (Boolean)

    Indicates if the start action should be performed asynchronously.

  • :authorized_key (AuthorizedKey)
  • :filter (Boolean)

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

  • :pause (Boolean)

    If set to true, start the virtual machine in paused mode. The default is false.

  • :use_cloud_init (Boolean)

    If set to true, the initialization type is set to cloud-init. The default value is false. See cloud-init documentation for details.

  • :use_ignition (Boolean)

    If set to true, the initialization type is set to Ignition. The default value is false. See Ignition documentation for details.

  • :use_initialization (Boolean)

    If set to true, the initialization type is set by the VM’s OS. Windows will set to Sysprep, Linux to cloud-init and RedHat CoreOS to Ignition. If any of the initialization-types are explicitly set (useCloudInit, useSysprep or useIgnition), they will be prioritized and this flag will be ignored. The default value is false.

  • :use_sysprep (Boolean)

    If set to true, the initialization type is set to Sysprep. The default value is false. See Sysprep for details.

  • :vm (Vm)

    The definition of the virtual machine for this specific run.

    For example:

    <action>
      <vm>
        <os>
          <boot>
            <devices>
              <device>cdrom</device>
            </devices>
          </boot>
        </os>
      </vm>
    </action>

    This will set the boot device to the CDROM only for this specific start. After the virtual machine is powered off, this definition will be reverted.

  • :volatile (Boolean)

    Indicates that this run configuration will be discarded even in the case of guest-initiated reboot. The default value is false.

  • :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.



31146
31147
31148
# File 'lib/ovirtsdk4/services.rb', line 31146

def start(opts = {})
  internal_action(:start, nil, START, opts)
end

#statistics_serviceStatisticsService

Locates the statistics service.

Returns:



31666
31667
31668
# File 'lib/ovirtsdk4/services.rb', line 31666

def statistics_service
  @statistics_service ||= StatisticsService.new(self, 'statistics')
end

#stop(opts = {}) ⇒ Object

This operation forces a virtual machine to power-off.

For example:

POST /ovirt-engine/api/vms/123/stop

The stop action does not take any action specific parameters; therefore, the request body should contain an empty action:

<action/>

To stop the VM even if a backup is running for it, the action should include the 'force' element.

For example, to force stop virtual machine 123:

POST /ovirt-engine/api/vms/123/stop
<action>
    <force>true</force>
</action>

Parameters:

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

    Additional options.

Options Hash (opts):

  • :async (Boolean)

    Indicates if the stop action should be performed asynchronously.

  • :force (Boolean)

    Indicates if the VM should be forcibly stop even if a backup is running for it.

  • :reason (String)

    The reason the virtual machine was stopped. Optionally set by user when shutting down the virtual machine.

  • :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.



31211
31212
31213
# File 'lib/ovirtsdk4/services.rb', line 31211

def stop(opts = {})
  internal_action(:stop, nil, STOP, opts)
end

#suspend(opts = {}) ⇒ Object

This operation saves the virtual machine state to disk and stops it. Start a suspended virtual machine and restore the virtual machine state with the start action.

For example:

POST /ovirt-engine/api/vms/123/suspend

The suspend action does not take any action specific parameters; therefore, the request body should contain an empty action:

<action/>

Parameters:

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

    Additional options.

Options Hash (opts):

  • :async (Boolean)

    Indicates if the suspend action 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.



31253
31254
31255
# File 'lib/ovirtsdk4/services.rb', line 31253

def suspend(opts = {})
  internal_action(:suspend, nil, SUSPEND, opts)
end

#tags_serviceAssignedTagsService

Locates the tags service.

Returns:



31675
31676
31677
# File 'lib/ovirtsdk4/services.rb', line 31675

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

#thaw_filesystems(opts = {}) ⇒ Object

Thaws virtual machine file systems.

This operation thaws a virtual machine’s file systems using the QEMU guest agent when taking a live snapshot of a running virtual machine. Normally, this is done automatically by the manager, but this must be executed manually with the API for virtual machines using OpenStack Volume (Cinder) disks.

Example:

POST /api/vms/123/thawfilesystems
<action/>

Parameters:

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

    Additional options.

Options Hash (opts):

  • :async (Boolean)

    Indicates if the thaw file systems action 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.



31295
31296
31297
# File 'lib/ovirtsdk4/services.rb', line 31295

def thaw_filesystems(opts = {})
  internal_action(:thawfilesystems, nil, THAW_FILESYSTEMS, opts)
end

#ticket(opts = {}) ⇒ Object

Generates a time-sensitive authentication token for accessing a virtual machine’s display.

For example:

POST /ovirt-engine/api/vms/123/ticket

The client-provided action optionally includes a desired ticket value and/or an expiry time in seconds.

The response specifies the actual ticket value and expiry used.

<action>
  <ticket>
    <value>abcd12345</value>
    <expiry>120</expiry>
  </ticket>
</action>
Important

If the virtual machine is configured to support only one graphics protocol then the generated authentication token will be valid for that protocol. But if the virtual machine is configured to support multiple protocols, VNC and SPICE, then the authentication token will only be valid for the SPICE protocol.

In order to obtain an authentication token for a specific protocol, for example for VNC, use the ticket method of the service, which manages the graphics consoles of the virtual machine, by sending a request:

POST /ovirt-engine/api/vms/123/graphicsconsoles/456/ticket

Parameters:

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

    Additional options.

Options Hash (opts):

  • :async (Boolean)

    Indicates if the generation of the ticket should be performed asynchronously.

  • :ticket (Ticket)
  • :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.



31364
31365
31366
# File 'lib/ovirtsdk4/services.rb', line 31364

def ticket(opts = {})
  internal_action(:ticket, :ticket, TICKET, opts)
end

#undo_snapshot(opts = {}) ⇒ Object

Restores the virtual machine to the state it had before previewing the snapshot.

See the preview_snapshot operation for details.

Parameters:

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

    Additional options.

Options Hash (opts):

  • :async (Boolean)

    Indicates if the undo snapshot action 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.



31478
31479
31480
# File 'lib/ovirtsdk4/services.rb', line 31478

def undo_snapshot(opts = {})
  internal_action(:undosnapshot, nil, UNDO_SNAPSHOT, opts)
end

#update(vm, opts = {}) ⇒ Vm

Update the virtual machine in the system for the given virtual machine id.

Parameters:

  • vm (Vm)

    The vm to update.

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

    Additional options.

Options Hash (opts):

  • :async (Boolean)

    Indicates if the update should be performed asynchronously.

  • :next_run (Boolean)

    Indicates if the update should be applied to the virtual machine immediately or if it should be applied only when the virtual machine is restarted. The default value is false, so by default changes are applied immediately.

  • :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:



31512
31513
31514
# File 'lib/ovirtsdk4/services.rb', line 31512

def update(vm, opts = {})
  internal_update(vm, Vm, UPDATE, opts)
end

#watchdogs_serviceVmWatchdogsService

Locates the watchdogs service.

Returns:



31684
31685
31686
# File 'lib/ovirtsdk4/services.rb', line 31684

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