Class: OvirtSDK4::IscsiBondsService

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

Instance Method Summary (collapse)

Instance Method Details

- (IscsiBond) add(bond, opts = {})

Adds a new bond.

Parameters:

Returns:



11478
11479
11480
11481
11482
11483
11484
11485
11486
11487
11488
11489
11490
11491
11492
11493
11494
11495
11496
11497
11498
11499
11500
11501
11502
# File 'lib/ovirtsdk4/services.rb', line 11478

def add(bond, opts = {})
  if bond.is_a?(Hash)
    bond = OvirtSDK4::IscsiBond.new(bond)
  end
  request = Request.new(:method => :POST, :path => @path)
  begin
    writer = XmlWriter.new(nil, true)
    IscsiBondWriter.write_one(bond, writer, 'bond')
    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 IscsiBondReader.read_one(reader)
    ensure
      reader.close
    end
  else
    check_fault(response)
  end
end

- (IscsiBondService) iscsi_bond_service(id)

Locates the iscsi_bond service.

Parameters:

  • id (String)

    The identifier of the iscsi_bond.

Returns:



11542
11543
11544
# File 'lib/ovirtsdk4/services.rb', line 11542

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

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

Returns:



11513
11514
11515
11516
11517
11518
11519
11520
11521
11522
11523
11524
11525
11526
11527
11528
11529
11530
11531
11532
11533
# File 'lib/ovirtsdk4/services.rb', line 11513

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



11553
11554
11555
11556
11557
11558
11559
11560
11561
11562
# File 'lib/ovirtsdk4/services.rb', line 11553

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

- (String) to_s

Returns an string representation of this service.

Returns:

  • (String)


11569
11570
11571
# File 'lib/ovirtsdk4/services.rb', line 11569

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