Class: OvirtSDK4::DiskProfileService

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

Instance Method Summary (collapse)

Instance Method Details

- (DiskProfile) get(opts = {})

Returns the representation of the object managed by this service.

Parameters:

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

    Additional options.

Returns:



5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
# File 'lib/ovirtsdk4/services.rb', line 5502

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

- (AssignedPermissionsService) permissions_service

Locates the permissions service.

Returns:



5574
5575
5576
# File 'lib/ovirtsdk4/services.rb', line 5574

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.



5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
# File 'lib/ovirtsdk4/services.rb', line 5526

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)


5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
# File 'lib/ovirtsdk4/services.rb', line 5585

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
  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)


5603
5604
5605
# File 'lib/ovirtsdk4/services.rb', line 5603

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

- (Object) update(profile)

Updates the object managed by this service.



5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
# File 'lib/ovirtsdk4/services.rb', line 5543

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