Class: OvirtSDK4::AssignedNetworkService

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

Instance Method Summary (collapse)

Instance Method Details

- (Network) get(opts = {})

Returns the representation of the object managed by this service.

Parameters:

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

    Additional options.

Returns:



2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
# File 'lib/ovirtsdk4/services.rb', line 2437

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 NetworkReader.read_one(reader)
    ensure
      reader.close
    end
  else
    check_fault(response)
  end
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.



2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
# File 'lib/ovirtsdk4/services.rb', line 2461

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)


2512
2513
2514
2515
2516
2517
# File 'lib/ovirtsdk4/services.rb', line 2512

def service(path)
  if path.nil? || path == ''
    return self
  end
  raise Error.new("The path \"#{path}\" doesn't correspond to any service")
end

- (String) to_s

Returns an string representation of this service.

Returns:

  • (String)


2524
2525
2526
# File 'lib/ovirtsdk4/services.rb', line 2524

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

- (Object) update(network)

Updates the object managed by this service.



2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
# File 'lib/ovirtsdk4/services.rb', line 2478

def update(network)
  if network.is_a?(Hash)
    network = OvirtSDK4::Network.new(network)
  end
  request = Request.new(:method => :PUT, :path => @path)
  begin
    writer = XmlWriter.new(nil, true)
    NetworkWriter.write_one(network, writer, 'network')
    request.body = writer.string
  ensure
    writer.close
  end
  response = @connection.send(request)
  case response.code
  when 200
    begin
      reader = XmlReader.new(response.body)
      return NetworkReader.read_one(reader)
    ensure
      reader.close
    end
    return result
  else
    check_fault(response)
  end
end