Class: OvirtSDK4::VmSessionsService

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

Instance Method Summary (collapse)

Instance Method Details

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

Returns:



26354
26355
26356
26357
26358
26359
26360
26361
26362
26363
26364
26365
26366
26367
26368
26369
26370
26371
26372
26373
26374
# File 'lib/ovirtsdk4/services.rb', line 26354

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



26394
26395
26396
26397
26398
26399
26400
26401
26402
26403
# File 'lib/ovirtsdk4/services.rb', line 26394

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

- (VmSessionService) session_service(id)

Locates the session service.

Parameters:

  • id (String)

    The identifier of the session.

Returns:



26383
26384
26385
# File 'lib/ovirtsdk4/services.rb', line 26383

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

- (String) to_s

Returns an string representation of this service.

Returns:

  • (String)


26410
26411
26412
# File 'lib/ovirtsdk4/services.rb', line 26410

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