Class: OvirtSDK4::VmNicService

Inherits:
MeasurableService show all
Defined in:
lib/ovirtsdk4/services.rb,
lib/ovirtsdk4/services.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) activate(opts = {})

Executes the activate method.



25283
25284
25285
25286
25287
25288
25289
25290
25291
25292
25293
25294
25295
25296
25297
25298
25299
25300
25301
# File 'lib/ovirtsdk4/services.rb', line 25283

def activate(opts = {})
  action = Action.new(opts)
  writer = XmlWriter.new(nil, true)
  ActionWriter.write_one(action, writer)
  body = writer.string
  writer.close
  request = Request.new({
  :method => :POST,
  :path => "#{@path}/activate",
  :body => body,
  })
  response = @connection.send(request)
  case response.code
  when 200
    action = check_action(response)
  else
    check_fault(response)
  end
end

- (Object) deactivate(opts = {})

Executes the deactivate method.



25306
25307
25308
25309
25310
25311
25312
25313
25314
25315
25316
25317
25318
25319
25320
25321
25322
25323
25324
# File 'lib/ovirtsdk4/services.rb', line 25306

def deactivate(opts = {})
  action = Action.new(opts)
  writer = XmlWriter.new(nil, true)
  ActionWriter.write_one(action, writer)
  body = writer.string
  writer.close
  request = Request.new({
  :method => :POST,
  :path => "#{@path}/deactivate",
  :body => body,
  })
  response = @connection.send(request)
  case response.code
  when 200
    action = check_action(response)
  else
    check_fault(response)
  end
end

- (Nic) get(opts = {})

Returns the representation of the object managed by this service.

Parameters:

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

    Additional options.

Returns:



25333
25334
25335
25336
25337
25338
25339
25340
25341
25342
25343
25344
25345
25346
25347
25348
# File 'lib/ovirtsdk4/services.rb', line 25333

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



25357
25358
25359
25360
25361
25362
25363
25364
25365
25366
25367
25368
25369
# File 'lib/ovirtsdk4/services.rb', line 25357

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

- (VmReportedDevicesService) reported_devices_service

Locates the reported_devices service.

Returns:



25405
25406
25407
# File 'lib/ovirtsdk4/services.rb', line 25405

def reported_devices_service
  return VmReportedDevicesService.new(@connection, "#{@path}/reporteddevices")
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)


25424
25425
25426
25427
25428
25429
25430
25431
25432
25433
25434
25435
25436
25437
25438
25439
25440
25441
# File 'lib/ovirtsdk4/services.rb', line 25424

def service(path)
  if path.nil? || path == ''
    return self
  end
  if path == 'reporteddevices'
    return reported_devices_service
  end
  if path.start_with?('reporteddevices/')
    return reported_devices_service.service(path[16..-1])
  end
  if path == 'statistics'
    return statistics_service
  end
  if path.start_with?('statistics/')
    return statistics_service.service(path[11..-1])
  end
  raise Error.new("The path \"#{path}\" doesn't correspond to any service")
end

- (StatisticsService) statistics_service

Locates the statistics service.

Returns:



25413
25414
25415
# File 'lib/ovirtsdk4/services.rb', line 25413

def statistics_service
  return StatisticsService.new(@connection, "#{@path}/statistics")
end

- (String) to_s

Returns an string representation of this service.

Returns:

  • (String)


25448
25449
25450
# File 'lib/ovirtsdk4/services.rb', line 25448

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

- (Object) update(nic)

Updates the object managed by this service.



25374
25375
25376
25377
25378
25379
25380
25381
25382
25383
25384
25385
25386
25387
25388
25389
25390
25391
25392
25393
25394
25395
25396
25397
25398
25399
# File 'lib/ovirtsdk4/services.rb', line 25374

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