Class: OvirtSDK4::DiskService

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

Instance Method Summary (collapse)

Instance Method Details

- (Object) copy(opts = {})

Executes the copy method.



27446
27447
27448
27449
27450
27451
27452
27453
27454
27455
27456
27457
27458
27459
27460
27461
27462
27463
27464
# File 'lib/ovirtsdk4/services.rb', line 27446

def copy(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}/copy",
  :body => body,
  })
  response = @connection.send(request)
  case response.code
  when 200
    action = check_action(response)
  else
    check_fault(response)
  end
end

- (Object) export(opts = {})

Executes the export method.



27469
27470
27471
27472
27473
27474
27475
27476
27477
27478
27479
27480
27481
27482
27483
27484
27485
27486
27487
# File 'lib/ovirtsdk4/services.rb', line 27469

def export(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}/export",
  :body => body,
  })
  response = @connection.send(request)
  case response.code
  when 200
    action = check_action(response)
  else
    check_fault(response)
  end
end

- (Disk) get(opts = {})

Returns the representation of the object managed by this service.

Parameters:

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

    Additional options.

Returns:



27496
27497
27498
27499
27500
27501
27502
27503
27504
27505
27506
27507
27508
27509
27510
27511
# File 'lib/ovirtsdk4/services.rb', line 27496

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

- (Object) move(opts = {})

Executes the move method.



27516
27517
27518
27519
27520
27521
27522
27523
27524
27525
27526
27527
27528
27529
27530
27531
27532
27533
27534
# File 'lib/ovirtsdk4/services.rb', line 27516

def move(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}/move",
  :body => body,
  })
  response = @connection.send(request)
  case response.code
  when 200
    action = check_action(response)
  else
    check_fault(response)
  end
end

- (AssignedPermissionsService) permissions_service

Locates the permissions service.

Returns:



27561
27562
27563
# File 'lib/ovirtsdk4/services.rb', line 27561

def permissions_service
  return AssignedPermissionsService.new(@connection, "#{@path}/permissions")
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.



27543
27544
27545
27546
27547
27548
27549
27550
27551
27552
27553
27554
27555
# File 'lib/ovirtsdk4/services.rb', line 27543

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)


27580
27581
27582
27583
27584
27585
27586
27587
27588
27589
27590
27591
27592
27593
27594
27595
27596
27597
# File 'lib/ovirtsdk4/services.rb', line 27580

def service(path)
  if path.nil? || path == ''
    return self
  end
  if path == 'permissions'
    return permissions_service
  end
  if path.start_with?('permissions/')
    return permissions_service.service(path[12..-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:



27569
27570
27571
# File 'lib/ovirtsdk4/services.rb', line 27569

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

- (String) to_s

Returns an string representation of this service.

Returns:

  • (String)


27604
27605
27606
# File 'lib/ovirtsdk4/services.rb', line 27604

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