Class: OvirtSDK4::VmHostDevicesService

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

#add(device, opts = {}) ⇒ HostDevice

Attach target device to given virtual machine.

Example:

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

With request body of type HostDevice, for example

<host_device id="123" />
Note
A necessary precondition for a successful host device attachment is that the virtual machine must be pinned to exactly one host. The device ID is then taken relative to this host.
Note
Attachment of a PCI device that is part of a bigger IOMMU group will result in attachment of the remaining devices from that IOMMU group as "placeholders". These devices are then identified using the placeholder attribute of the HostDevice type set to true.

In case you want attach a device that already serves as an IOMMU placeholder, simply issue an explicit Add operation for it, and its placeholder flag will be cleared, and the device will be accessible to the virtual machine.

Parameters:

  • device (HostDevice)

    The host device to be attached to given virtual machine.

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

Returns:



33239
33240
33241
# File 'lib/ovirtsdk4/services.rb', line 33239

def add(device, opts = {})
  internal_add(device, HostDevice, ADD, opts)
end

#device_service(id) ⇒ VmHostDeviceService

Returns a reference to the service that manages a specific host device attached to given virtual machine.

Parameters:

  • id (String)

    The identifier of the device.

Returns:



33284
33285
33286
# File 'lib/ovirtsdk4/services.rb', line 33284

def device_service(id)
  VmHostDeviceService.new(self, id)
end

#list(opts = {}) ⇒ Array<HostDevice>

List the host devices assigned to given virtual machine.

The order of the returned list of devices isn’t guaranteed.

Parameters:

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

    Additional options.

Options Hash (opts):

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

  • :max (Integer)

    Sets the maximum number of devices to return. If not specified all the devices are returned.

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



33273
33274
33275
# File 'lib/ovirtsdk4/services.rb', line 33273

def list(opts = {})
  internal_get(LIST, 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.



33295
33296
33297
33298
33299
33300
33301
33302
33303
33304
# File 'lib/ovirtsdk4/services.rb', line 33295

def service(path)
  if path.nil? || path == ''
    return self
  end
  index = path.index('/')
  if index.nil?
    return device_service(path)
  end
  return device_service(path[0..(index - 1)]).service(path[(index + 1)..-1])
end