Class: OvirtSDK4::ExternalHostsService

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

Instance Method Summary (collapse)

Instance Method Details

- (ExternalHostService) host_service(id)

Locates the host service.

Parameters:

  • id (String)

    The identifier of the host.

Returns:



7490
7491
7492
# File 'lib/ovirtsdk4/services.rb', line 7490

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

- (Array<ExternalHost>) 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 hosts to return. If not specified all the hosts are returned.

Returns:



7461
7462
7463
7464
7465
7466
7467
7468
7469
7470
7471
7472
7473
7474
7475
7476
7477
7478
7479
7480
7481
# File 'lib/ovirtsdk4/services.rb', line 7461

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



7501
7502
7503
7504
7505
7506
7507
7508
7509
7510
# File 'lib/ovirtsdk4/services.rb', line 7501

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

- (String) to_s

Returns an string representation of this service.

Returns:

  • (String)


7517
7518
7519
# File 'lib/ovirtsdk4/services.rb', line 7517

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