Class: OvirtSDK4::StorageDomainServerConnectionsService

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

Instance Method Summary (collapse)

Instance Method Details

- (StorageConnection) add(connection, opts = {})

Adds a new connection.

Parameters:

Returns:



19335
19336
19337
19338
19339
19340
19341
19342
19343
19344
19345
19346
19347
19348
19349
19350
19351
19352
19353
19354
19355
19356
19357
19358
19359
# File 'lib/ovirtsdk4/services.rb', line 19335

def add(connection, opts = {})
  if connection.is_a?(Hash)
    connection = OvirtSDK4::StorageConnection.new(connection)
  end
  request = Request.new(:method => :POST, :path => @path)
  begin
    writer = XmlWriter.new(nil, true)
    StorageConnectionWriter.write_one(connection, writer, 'connection')
    request.body = writer.string
  ensure
    writer.close
  end
  response = @connection.send(request)
  case response.code
  when 201, 202
    begin
      reader = XmlReader.new(response.body)
      return StorageConnectionReader.read_one(reader)
    ensure
      reader.close
    end
  else
    check_fault(response)
  end
end

- (StorageDomainServerConnectionService) connection_service(id)

Locates the connection service.

Parameters:

  • id (String)

    The identifier of the connection.

Returns:



19399
19400
19401
# File 'lib/ovirtsdk4/services.rb', line 19399

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

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

Returns:



19370
19371
19372
19373
19374
19375
19376
19377
19378
19379
19380
19381
19382
19383
19384
19385
19386
19387
19388
19389
19390
# File 'lib/ovirtsdk4/services.rb', line 19370

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



19410
19411
19412
19413
19414
19415
19416
19417
19418
19419
# File 'lib/ovirtsdk4/services.rb', line 19410

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

- (String) to_s

Returns an string representation of this service.

Returns:

  • (String)


19426
19427
19428
# File 'lib/ovirtsdk4/services.rb', line 19426

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