Class: OvirtSDK4::HostDevicesService

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

Instance Method Summary (collapse)

Instance Method Details

- (HostDeviceService) device_service(id)

Locates the device service.

Parameters:

  • id (String)

    The identifier of the device.

Returns:



9597
9598
9599
# File 'lib/ovirtsdk4/services.rb', line 9597

def device_service(id)
  return HostDeviceService.new(@connection, "#{@path}/#{id}")
end

- (Array<HostDevice>) list(opts = {})

Returns the representation of the object managed by this service.

Parameters:

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

    Additional options.

Options Hash (opts):

  • :max (Integer)

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

Returns:



9568
9569
9570
9571
9572
9573
9574
9575
9576
9577
9578
9579
9580
9581
9582
9583
9584
9585
9586
9587
9588
# File 'lib/ovirtsdk4/services.rb', line 9568

def list(opts = {})
  query = {}
  value = opts[:max]
  unless value.nil?
    value = Writer.render_integer(value)
    query['max'] = value
  end
  request = Request.new(:method => :GET, :path => @path, :query => query)
  response = @connection.send(request)
  case response.code
  when 200
    begin
      reader = XmlReader.new(response.body)
      return HostDeviceReader.read_many(reader)
    ensure
      reader.close
    end
  else
    check_fault(response)
  end
end

- (Service) service(path)

Locates the service corresponding to the given path.

Parameters:

  • path (String)

    The path of the service.

Returns:

  • (Service)

    A reference to the service.



9608
9609
9610
9611
9612
9613
9614
9615
9616
9617
# File 'lib/ovirtsdk4/services.rb', line 9608

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

- (String) to_s

Returns an string representation of this service.

Returns:

  • (String)


9624
9625
9626
# File 'lib/ovirtsdk4/services.rb', line 9624

def to_s
  return "#<#{HostDevicesService}:#{@path}>"
end