Class: OvirtSDK4::StorageServerConnectionsService

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:



20416
20417
20418
20419
20420
20421
20422
20423
20424
20425
20426
20427
20428
20429
20430
20431
20432
20433
20434
20435
20436
20437
20438
20439
20440
# File 'lib/ovirtsdk4/services.rb', line 20416

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

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



20451
20452
20453
20454
20455
20456
20457
20458
20459
20460
20461
20462
20463
20464
20465
20466
20467
20468
20469
20470
20471
# File 'lib/ovirtsdk4/services.rb', line 20451

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.



20491
20492
20493
20494
20495
20496
20497
20498
20499
20500
# File 'lib/ovirtsdk4/services.rb', line 20491

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

- (StorageServerConnectionService) storage_connection_service(id)

Locates the storage_connection service.

Parameters:

  • id (String)

    The identifier of the storage_connection.

Returns:



20480
20481
20482
# File 'lib/ovirtsdk4/services.rb', line 20480

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

- (String) to_s

Returns an string representation of this service.

Returns:

  • (String)


20507
20508
20509
# File 'lib/ovirtsdk4/services.rb', line 20507

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