affinity_labels_service()
click to toggle source
List of scheduling labels assigned to this VM.
@return [AssignedAffinityLabelsService] A reference to `affinity_labels`
service.
def affinity_labels_service
AssignedAffinityLabelsService.new(@connection, "#{@path}/affinitylabels")
end
applications_service()
click to toggle source
Locates the `applications` service.
@return [VmApplicationsService] A reference to `applications` service.
def applications_service
VmApplicationsService.new(@connection, "#{@path}/applications")
end
cancel_migration(opts = {})
click to toggle source
This operation stops any migration of a virtual machine to another physical
host.
- source
POST /ovirt-engine/api/vms/123/cancelmigration
The cancel migration action does not take any action specific parameters,
so the request body should contain an empty `action`:
- source,xml
<action/>
@param opts [Hash] Additional options.
@option opts [Boolean] :async Indicates if the migration should cancelled
asynchronously.
def cancel_migration(opts = {})
action = Action.new(opts)
writer = XmlWriter.new(nil, true)
ActionWriter.write_one(action, writer)
body = writer.string
writer.close
request = HttpRequest.new(
method: :POST,
url: "#{@path}/cancelmigration",
body: body
)
response = @connection.send(request)
case response.code
when 200
action = check_action(response)
else
check_action(response)
end
end
cdroms_service()
click to toggle source
Locates the `cdroms` service.
@return [VmCdromsService] A reference to `cdroms` service.
def cdroms_service
VmCdromsService.new(@connection, "#{@path}/cdroms")
end
clone(opts = {})
click to toggle source
Executes the `clone` method.
@param opts [Hash] Additional options.
@option opts [Boolean] :async Indicates if the clone should be performed
asynchronously.
@option opts [Vm] :vm
def clone(opts = {})
action = Action.new(opts)
writer = XmlWriter.new(nil, true)
ActionWriter.write_one(action, writer)
body = writer.string
writer.close
request = HttpRequest.new(
method: :POST,
url: "#{@path}/clone",
body: body
)
response = @connection.send(request)
case response.code
when 200
action = check_action(response)
else
check_action(response)
end
end
commit_snapshot(opts = {})
click to toggle source
Executes the `commit_snapshot` method.
@param opts [Hash] Additional options.
@option opts [Boolean] :async Indicates if the snapshots should be
committed asynchronously.
def commit_snapshot(opts = {})
action = Action.new(opts)
writer = XmlWriter.new(nil, true)
ActionWriter.write_one(action, writer)
body = writer.string
writer.close
request = HttpRequest.new(
method: :POST,
url: "#{@path}/commitsnapshot",
body: body
)
response = @connection.send(request)
case response.code
when 200
action = check_action(response)
else
check_action(response)
end
end
detach(opts = {})
click to toggle source
Detaches a virtual machine from a pool.
- source
POST /ovirt-engine/api/vms/123/detach
The detach action does not take any action specific parameters, so the
request body should contain an empty `action`:
- source,xml
<action/>
@param opts [Hash] Additional options.
@option opts [Boolean] :async Indicates if the detach should be performed
asynchronously.
def detach(opts = {})
action = Action.new(opts)
writer = XmlWriter.new(nil, true)
ActionWriter.write_one(action, writer)
body = writer.string
writer.close
request = HttpRequest.new(
method: :POST,
url: "#{@path}/detach",
body: body
)
response = @connection.send(request)
case response.code
when 200
action = check_action(response)
else
check_action(response)
end
end
disk_attachments_service()
click to toggle source
List of disks attached to this virtual machine.
@return [DiskAttachmentsService] A reference to `disk_attachments` service.
def disk_attachments_service
DiskAttachmentsService.new(@connection, "#{@path}/diskattachments")
end
export(opts = {})
click to toggle source
Export a virtual machine to an export domain.
For example to export virtual machine `123` to the export domain
`myexport`, send a request like this:
- source
POST /ovirt-engine/api/vms/123/export
With a request body like this:
- source,xml
<action>
<storage_domain>
<name>myexport</name>
</storage_domain>
<exclusive>true</exclusive>
<discard_snapshots>true</discard_snapshots>
</action>
@param opts [Hash] Additional options.
@option opts [Boolean] :async Indicates if the export should be performed
asynchronously.
@option opts [Boolean] :discard_snapshots The `discard_snapshots` parameter
is to be used when the virtual machine should be exported with all its
snapshots collapsed.
@option opts [Boolean] :exclusive The `exclusive` parameter is to be used
when the virtual machine should be exported even if another copy of
it already exists in the export domain (override).
@option opts [StorageDomain] :storage_domain
def export(opts = {})
action = Action.new(opts)
writer = XmlWriter.new(nil, true)
ActionWriter.write_one(action, writer)
body = writer.string
writer.close
request = HttpRequest.new(
method: :POST,
url: "#{@path}/export",
body: body
)
response = @connection.send(request)
case response.code
when 200
action = check_action(response)
else
check_action(response)
end
end
freeze_filesystems(opts = {})
click to toggle source
Freeze 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:
- source
POST /ovirt-engine/api/vms/123/freezefilesystems
- source,xml
<action/>
@param opts [Hash] Additional options.
@option opts [Boolean] :async Indicates if the freeze should be performed
asynchronously.
def freeze_filesystems(opts = {})
action = Action.new(opts)
writer = XmlWriter.new(nil, true)
ActionWriter.write_one(action, writer)
body = writer.string
writer.close
request = HttpRequest.new(
method: :POST,
url: "#{@path}/freezefilesystems",
body: body
)
response = @connection.send(request)
case response.code
when 200
action = check_action(response)
else
check_action(response)
end
end
get(opts = {})
click to toggle source
Retrieves the description of the virtual machine.
@param opts [Hash] Additional options.
@option opts [Boolean] :all_content Indicates if all 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' send a request like this:
....
GET /ovirt-engine/api/vms/123?all_content=true
....
NOTE: The reason for not including these attributes is performance: they are seldom used and they require
additional queries to the database. So try to use the this parameter only when it is really needed.
@option opts [Boolean] :filter Indicates if the results should be filtered
according to the permissions of the user.
@option opts [Boolean] :next_run Indicates if the returned result describes
the virtual machine as it is currently running, or if describes
it with the modifications that have already been performed but that will have effect only when it is
restarted. By default the values is `false`.
If the parameter is included in the request, but without a value, it is assumed that the value is `true`, so
the following request:
[source]
----
GET /vms/{vm:id};next_run
----
Is equivalent to using the value `true`:
[source]
----
GET /vms/{vm:id};next_run=true
----
@return [Vm]
def get(opts = {})
query = {}
value = opts[:all_content]
unless value.nil?
value = Writer.render_boolean(value)
query['all_content'] = value
end
value = opts[:filter]
unless value.nil?
value = Writer.render_boolean(value)
query['filter'] = value
end
value = opts[:next_run]
unless value.nil?
value = Writer.render_boolean(value)
query['next_run'] = value
end
request = HttpRequest.new(method: :GET, url: @path, query: query)
response = @connection.send(request)
case response.code
when 200
begin
reader = XmlReader.new(response.body)
return VmReader.read_one(reader)
ensure
reader.close
end
else
check_fault(response)
end
end
graphics_consoles_service()
click to toggle source
Locates the `graphics_consoles` service.
@return [VmGraphicsConsolesService] A reference to `graphics_consoles`
service.
def graphics_consoles_service
VmGraphicsConsolesService.new(@connection, "#{@path}/graphicsconsoles")
end
host_devices_service()
click to toggle source
Locates the `host_devices` service.
@return [VmHostDevicesService] A reference to `host_devices` service.
def host_devices_service
VmHostDevicesService.new(@connection, "#{@path}/hostdevices")
end
katello_errata_service()
click to toggle source
Reference to the service that can show the applicable errata available on
the virtual machine. This information is taken from Katello.
@return [KatelloErrataService] A reference to `katello_errata` service.
def katello_errata_service
KatelloErrataService.new(@connection, "#{@path}/katelloerrata")
end
logon(opts = {})
click to toggle source
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.
This is how an example request would look like:
- source
POST /ovirt-engine/api/vms/123/logon
Request body:
- source,xml
<action/>
@param opts [Hash] Additional options.
@option opts [Boolean] :async Indicates if the logon should be performed
asynchronously.
def logon(opts = {})
action = Action.new(opts)
writer = XmlWriter.new(nil, true)
ActionWriter.write_one(action, writer)
body = writer.string
writer.close
request = HttpRequest.new(
method: :POST,
url: "#{@path}/logon",
body: body
)
response = @connection.send(request)
case response.code
when 200
action = check_action(response)
else
check_action(response)
end
end
maintenance(opts = {})
click to toggle source
Executes the `maintenance` method.
@param opts [Hash] Additional options.
@option opts [Boolean] :async Indicates if the action should be performed
asynchronously.
@option opts [Boolean] :maintenance_enabled
def maintenance(opts = {})
action = Action.new(opts)
writer = XmlWriter.new(nil, true)
ActionWriter.write_one(action, writer)
body = writer.string
writer.close
request = HttpRequest.new(
method: :POST,
url: "#{@path}/maintenance",
body: body
)
response = @connection.send(request)
case response.code
when 200
action = check_action(response)
else
check_action(response)
end
end
migrate(opts = {})
click to toggle source
This operation migrates a virtual machine to another physical host.
- source
POST /ovirt-engine/api/vms/123/migrate
One can specify a specific host to migrate the virtual machine to:
- source,xml
<action>
<host id="2ab5e1da-b726-4274-bbf7-0a42b16a0fc3"/>
</action>
@param opts [Hash] Additional options.
@option opts [Boolean] :async Indicates if the migration should be
performed asynchronously.
@option opts [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.
@option opts [Boolean] :force Specifies the virtual machine should migrate
although it might be defined as non migratable. This is an
optional parameter. By default, it is set to `false`.
@option opts [Host] :host Specifies a specific host the virtual machine
should migrate to. This is an optional parameters. By default,
the oVirt Engine 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.
def migrate(opts = {})
action = Action.new(opts)
writer = XmlWriter.new(nil, true)
ActionWriter.write_one(action, writer)
body = writer.string
writer.close
request = HttpRequest.new(
method: :POST,
url: "#{@path}/migrate",
body: body
)
response = @connection.send(request)
case response.code
when 200
action = check_action(response)
else
check_action(response)
end
end
nics_service()
click to toggle source
Locates the `nics` service.
@return [VmNicsService] A reference to `nics` service.
def nics_service
VmNicsService.new(@connection, "#{@path}/nics")
end
numa_nodes_service()
click to toggle source
Locates the `numa_nodes` service.
@return [VmNumaNodesService] A reference to `numa_nodes` service.
def numa_nodes_service
VmNumaNodesService.new(@connection, "#{@path}/numanodes")
end
permissions_service()
click to toggle source
Locates the `permissions` service.
@return [AssignedPermissionsService] A reference to `permissions` service.
def permissions_service
AssignedPermissionsService.new(@connection, "#{@path}/permissions")
end
preview_snapshot(opts = {})
click to toggle source
Executes the `preview_snapshot` method.
@param opts [Hash] Additional options.
@option opts [Boolean] :async Indicates if the preview should be performed
asynchronously.
@option opts [Array<Disk>] :disks
@option opts [Boolean] :restore_memory
@option opts [Snapshot] :snapshot
@option opts [Vm] :vm
def preview_snapshot(opts = {})
action = Action.new(opts)
writer = XmlWriter.new(nil, true)
ActionWriter.write_one(action, writer)
body = writer.string
writer.close
request = HttpRequest.new(
method: :POST,
url: "#{@path}/previewsnapshot",
body: body
)
response = @connection.send(request)
case response.code
when 200
action = check_action(response)
else
check_action(response)
end
end
reboot(opts = {})
click to toggle source
This operation sends a reboot request to a virtual machine.
- source
POST /ovirt-engine/api/vms/123/reboot
The reboot action does not take any action specific parameters, so the
request body should contain an empty `action`:
- source,xml
<action/>
@param opts [Hash] Additional options.
@option opts [Boolean] :async Indicates if the reboot should be performed
asynchronously.
def reboot(opts = {})
action = Action.new(opts)
writer = XmlWriter.new(nil, true)
ActionWriter.write_one(action, writer)
body = writer.string
writer.close
request = HttpRequest.new(
method: :POST,
url: "#{@path}/reboot",
body: body
)
response = @connection.send(request)
case response.code
when 200
action = check_action(response)
else
check_action(response)
end
end
remove(opts = {})
click to toggle source
Removes the virtual machine, including the virtual disks attached to it.
For example, to remove the virtual machine with identifier `123` send a
request like this:
- source
DELETE /ovirt-engine/api/vms/123
@param opts [Hash] Additional options.
@option opts [Boolean] :async Indicates if the remove should be performed
asynchronously. @option opts [Boolean] :detach_only Indicates if the
attached virtual disks should be detached first and preserved instead of
being removed. @option opts [Boolean] :force 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.
def remove(opts = {})
query = {}
value = opts[:async]
unless value.nil?
value = Writer.render_boolean(value)
query['async'] = value
end
value = opts[:detach_only]
unless value.nil?
value = Writer.render_boolean(value)
query['detach_only'] = value
end
value = opts[:force]
unless value.nil?
value = Writer.render_boolean(value)
query['force'] = value
end
request = HttpRequest.new(method: :DELETE, url: @path, query: query)
response = @connection.send(request)
unless response.code == 200
check_fault(response)
end
end
reorder_mac_addresses(opts = {})
click to toggle source
Executes the `reorder_mac_addresses` method.
@param opts [Hash] Additional options.
@option opts [Boolean] :async Indicates if the action should be performed
asynchronously.
def reorder_mac_addresses(opts = {})
action = Action.new(opts)
writer = XmlWriter.new(nil, true)
ActionWriter.write_one(action, writer)
body = writer.string
writer.close
request = HttpRequest.new(
method: :POST,
url: "#{@path}/reordermacaddresses",
body: body
)
response = @connection.send(request)
case response.code
when 200
action = check_action(response)
else
check_action(response)
end
end
reported_devices_service()
click to toggle source
Locates the `reported_devices` service.
@return [VmReportedDevicesService] A reference to `reported_devices`
service.
def reported_devices_service
VmReportedDevicesService.new(@connection, "#{@path}/reporteddevices")
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.
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 == '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 == '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 == '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_service()
click to toggle source
Reference to the service that provides information about virtual machine
user sessions.
@return [VmSessionsService] A reference to `sessions` service.
def sessions_service
VmSessionsService.new(@connection, "#{@path}/sessions")
end
shutdown(opts = {})
click to toggle source
This operation sends a shutdown request to a virtual machine.
- source
POST /ovirt-engine/api/vms/123/shutdown
The shutdown action does not take any action specific parameters, so the
request body should contain an empty `action`:
- source,xml
<action/>
@param opts [Hash] Additional options.
@option opts [Boolean] :async Indicates if the shutdown should be performed
asynchronously.
def shutdown(opts = {})
action = Action.new(opts)
writer = XmlWriter.new(nil, true)
ActionWriter.write_one(action, writer)
body = writer.string
writer.close
request = HttpRequest.new(
method: :POST,
url: "#{@path}/shutdown",
body: body
)
response = @connection.send(request)
case response.code
when 200
action = check_action(response)
else
check_action(response)
end
end
snapshots_service()
click to toggle source
Locates the `snapshots` service.
@return [SnapshotsService] A reference to `snapshots` service.
def snapshots_service
SnapshotsService.new(@connection, "#{@path}/snapshots")
end
start(opts = {})
click to toggle source
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:
- source
POST /ovirt-engine/api/vms/123/start
With a request body:
- source,xml
<action/>
@param opts [Hash] Additional options.
@option opts [Boolean] :async Indicates if the action should be performed
asynchronously.
@option opts [Boolean] :filter Indicates if the results should be filtered
according to the permissions of the user.
@option opts [Boolean] :pause If set to `true`, start the virtual machine
in paused mode. Default is `false`.
@option opts [Boolean] :use_cloud_init If set to `true`, the initialization
type is set to cloud-init. The default value is `false`.
See https://cloudinit.readthedocs.io/en/latest[this] for details.
@option opts [Boolean] :use_sysprep If set to `true`, the initialization
type is set to Sysprep. The default value is `false`.
See https://en.wikipedia.org/wiki/Sysprep[this] for details.
@option opts [Vm] :vm The definition of the virtual machine for this
specific run.
For example:
[source,xml]
----
<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 will be
powered off, this definition will be reverted.
def start(opts = {})
action = Action.new(opts)
writer = XmlWriter.new(nil, true)
ActionWriter.write_one(action, writer)
body = writer.string
writer.close
request = HttpRequest.new(
method: :POST,
url: "#{@path}/start",
body: body
)
response = @connection.send(request)
case response.code
when 200
action = check_action(response)
else
check_action(response)
end
end
statistics_service()
click to toggle source
Locates the `statistics` service.
@return [StatisticsService] A reference to `statistics` service.
def statistics_service
StatisticsService.new(@connection, "#{@path}/statistics")
end
stop(opts = {})
click to toggle source
This operation forces a virtual machine to power-off.
- source
POST /ovirt-engine/api/vms/123/stop
The stop action does not take any action specific parameters, so the
request body should contain an empty `action`:
- source,xml
<action/>
@param opts [Hash] Additional options.
@option opts [Boolean] :async Indicates if the action should be performed
asynchronously.
def stop(opts = {})
action = Action.new(opts)
writer = XmlWriter.new(nil, true)
ActionWriter.write_one(action, writer)
body = writer.string
writer.close
request = HttpRequest.new(
method: :POST,
url: "#{@path}/stop",
body: body
)
response = @connection.send(request)
case response.code
when 200
action = check_action(response)
else
check_action(response)
end
end
suspend(opts = {})
click to toggle source
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.
- source
POST /ovirt-engine/api/vms/123/suspend
The suspend action does not take any action specific parameters, so the
request body should contain an empty `action`:
- source,xml
<action/>
@param opts [Hash] Additional options.
@option opts [Boolean] :async Indicates if the action should be performed
asynchronously.
def suspend(opts = {})
action = Action.new(opts)
writer = XmlWriter.new(nil, true)
ActionWriter.write_one(action, writer)
body = writer.string
writer.close
request = HttpRequest.new(
method: :POST,
url: "#{@path}/suspend",
body: body
)
response = @connection.send(request)
case response.code
when 200
action = check_action(response)
else
check_action(response)
end
end
thaw_filesystems(opts = {})
click to toggle source
Thaw 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:
- source
POST /api/vms/123/thawfilesystems
- source,xml
<action/>
@param opts [Hash] Additional options.
@option opts [Boolean] :async Indicates if the action should be performed
asynchronously.
def thaw_filesystems(opts = {})
action = Action.new(opts)
writer = XmlWriter.new(nil, true)
ActionWriter.write_one(action, writer)
body = writer.string
writer.close
request = HttpRequest.new(
method: :POST,
url: "#{@path}/thawfilesystems",
body: body
)
response = @connection.send(request)
case response.code
when 200
action = check_action(response)
else
check_action(response)
end
end
ticket(opts = {})
click to toggle source
Generates a time-sensitive authentication token for accessing a virtual
machine's display.
- source
POST /ovirt-engine/api/vms/123/ticket
The client-provided action optionally includes a desired ticket value
and/or an expiry time in seconds.
In any case, the response specifies the actual ticket value and expiry
used.
- source,xml
<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
<<services/graphics_console, service>> that manages the
graphics consoles of the virtual machine, sending a request like this:
- source
POST /ovirt-engine/api/vms/123/graphicsconsoles/456/ticket
@param opts [Hash] Additional options.
@option opts [Boolean] :async Indicates if the generation of the ticket
should be performed asynchronously.
@option opts [Ticket] :ticket
def ticket(opts = {})
action = Action.new(opts)
writer = XmlWriter.new(nil, true)
ActionWriter.write_one(action, writer)
body = writer.string
writer.close
request = HttpRequest.new(
method: :POST,
url: "#{@path}/ticket",
body: body
)
response = @connection.send(request)
case response.code
when 200
action = check_action(response)
return action.ticket
else
check_action(response)
end
end
to_s()
click to toggle source
Returns an string representation of this service.
@return [String]
def to_s
"#<#{VmService}:#{@path}>"
end
undo_snapshot(opts = {})
click to toggle source
Executes the `undo_snapshot` method.
@param opts [Hash] Additional options.
@option opts [Boolean] :async Indicates if the action should be performed
asynchronously.
def undo_snapshot(opts = {})
action = Action.new(opts)
writer = XmlWriter.new(nil, true)
ActionWriter.write_one(action, writer)
body = writer.string
writer.close
request = HttpRequest.new(
method: :POST,
url: "#{@path}/undosnapshot",
body: body
)
response = @connection.send(request)
case response.code
when 200
action = check_action(response)
else
check_action(response)
end
end
update(vm, opts = {})
click to toggle source
Updates the `vm`.
@param vm [Vm] The `vm` to update. @param opts [Hash] Additional options.
@option opts [Boolean] :async Indicates if the update should be performed
asynchronously.
@option opts [Boolean] :next_run 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.
@return [Vm]
def update(vm, opts = {})
if vm.is_a?(Hash)
vm = OvirtSDK4::Vm.new(vm)
end
query = {}
value = opts[:async]
unless value.nil?
value = Writer.render_boolean(value)
query['async'] = value
end
value = opts[:next_run]
unless value.nil?
value = Writer.render_boolean(value)
query['next_run'] = value
end
request = HttpRequest.new(method: :PUT, url: @path, query: query)
begin
writer = XmlWriter.new(nil, true)
VmWriter.write_one(vm, writer)
request.body = writer.string
ensure
writer.close
end
response = @connection.send(request)
case response.code
when 200
begin
reader = XmlReader.new(response.body)
return VmReader.read_one(reader)
ensure
reader.close
end
return result
else
check_fault(response)
end
end
watchdogs_service()
click to toggle source
Locates the `watchdogs` service.
@return [VmWatchdogsService] A reference to `watchdogs` service.
def watchdogs_service
VmWatchdogsService.new(@connection, "#{@path}/watchdogs")
end