Class: OvirtSDK4::IscsiBondService

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

Instance Method Summary (collapse)

Instance Method Details

- (IscsiBond) get(opts = {})

Returns the representation of the object managed by this service.

Parameters:

  • opts (Hash) (defaults to: {})

    Additional options.

Returns:



11334
11335
11336
11337
11338
11339
11340
11341
11342
11343
11344
11345
11346
11347
11348
11349
# File 'lib/ovirtsdk4/services.rb', line 11334

def get(opts = {})
  query = {}
  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_one(reader)
    ensure
      reader.close
    end
  else
    check_fault(response)
  end
end

- (NetworksService) networks_service

Locates the networks service.

Returns:



11406
11407
11408
# File 'lib/ovirtsdk4/services.rb', line 11406

def networks_service
  return NetworksService.new(@connection, "#{@path}/networks")
end

- (Object) remove(opts = {})

Deletes the object managed by this service.

Parameters:

  • opts (Hash) (defaults to: {})

    Additional options.

Options Hash (opts):

  • :async (Boolean)

    Indicates if the remove should be performed asynchronously.



11358
11359
11360
11361
11362
11363
11364
11365
11366
11367
11368
11369
11370
# File 'lib/ovirtsdk4/services.rb', line 11358

def remove(opts = {})
  query = {}
  value = opts[:async]
  unless value.nil?
    value = Writer.render_boolean(value)
    query['async'] = value
  end
  request = Request.new(:method => :DELETE, :path => @path, :query => query)
  response = @connection.send(request)
  unless response.code == 200
    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.

Raises:

  • (Error)


11425
11426
11427
11428
11429
11430
11431
11432
11433
11434
11435
11436
11437
11438
11439
11440
11441
11442
# File 'lib/ovirtsdk4/services.rb', line 11425

def service(path)
  if path.nil? || path == ''
    return self
  end
  if path == 'networks'
    return networks_service
  end
  if path.start_with?('networks/')
    return networks_service.service(path[9..-1])
  end
  if path == 'storageserverconnections'
    return storage_server_connections_service
  end
  if path.start_with?('storageserverconnections/')
    return storage_server_connections_service.service(path[25..-1])
  end
  raise Error.new("The path \"#{path}\" doesn't correspond to any service")
end

- (StorageServerConnectionsService) storage_server_connections_service

Locates the storage_server_connections service.

Returns:



11414
11415
11416
# File 'lib/ovirtsdk4/services.rb', line 11414

def storage_server_connections_service
  return StorageServerConnectionsService.new(@connection, "#{@path}/storageserverconnections")
end

- (String) to_s

Returns an string representation of this service.

Returns:

  • (String)


11449
11450
11451
# File 'lib/ovirtsdk4/services.rb', line 11449

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

- (Object) update(bond)

Updates the object managed by this service.



11375
11376
11377
11378
11379
11380
11381
11382
11383
11384
11385
11386
11387
11388
11389
11390
11391
11392
11393
11394
11395
11396
11397
11398
11399
11400
# File 'lib/ovirtsdk4/services.rb', line 11375

def update(bond)
  if bond.is_a?(Hash)
    bond = OvirtSDK4::IscsiBond.new(bond)
  end
  request = Request.new(:method => :PUT, :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 200
    begin
      reader = XmlReader.new(response.body)
      return IscsiBondReader.read_one(reader)
    ensure
      reader.close
    end
    return result
  else
    check_fault(response)
  end
end