Class: OvirtSDK4::DiskProfilesService

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

Instance Method Summary (collapse)

Instance Method Details

- (DiskProfile) add(profile, opts = {})

Adds a new profile.

Parameters:

Returns:



5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
# File 'lib/ovirtsdk4/services.rb', line 5632

def add(profile, opts = {})
  if profile.is_a?(Hash)
    profile = OvirtSDK4::DiskProfile.new(profile)
  end
  request = Request.new(:method => :POST, :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 201, 202
    begin
      reader = XmlReader.new(response.body)
      return DiskProfileReader.read_one(reader)
    ensure
      reader.close
    end
  else
    check_fault(response)
  end
end

- (DiskProfileService) disk_profile_service(id)

Locates the disk_profile service.

Parameters:

  • id (String)

    The identifier of the disk_profile.

Returns:



5696
5697
5698
# File 'lib/ovirtsdk4/services.rb', line 5696

def disk_profile_service(id)
  return DiskProfileService.new(@connection, "#{@path}/#{id}")
end

- (Array<DiskProfile>) list(opts = {})

Returns the representation of the object managed by this service.

Parameters:

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

    Additional options.

Options Hash (opts):

  • :max (Integer)

    Sets the maximum number of profiles to return. If not specified all the profiles are returned.

Returns:



5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
# File 'lib/ovirtsdk4/services.rb', line 5667

def list(opts = {})
  query = {}
  value = opts[:max]
  unless value.nil?
    value = Writer.render_integer(value)
    query['max'] = value
  end
  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_many(reader)
    ensure
      reader.close
    end
  else
    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.



5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
# File 'lib/ovirtsdk4/services.rb', line 5707

def service(path)
  if path.nil? || path == ''
    return self
  end
  index = path.index('/')
  if index.nil?
    return disk_profile_service(path)
  end
  return disk_profile_service(path[0..(index - 1)]).service(path[(index +1)..-1])
end

- (String) to_s

Returns an string representation of this service.

Returns:

  • (String)


5723
5724
5725
# File 'lib/ovirtsdk4/services.rb', line 5723

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