Class: OvirtSDK4::OpenstackImagesService

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

Instance Method Summary (collapse)

Instance Method Details

- (OpenstackImageService) image_service(id)

Locates the image service.

Parameters:

  • id (String)

    The identifier of the image.

Returns:



13659
13660
13661
# File 'lib/ovirtsdk4/services.rb', line 13659

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

- (Array<OpenStackImage>) 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 images to return. If not specified all the images are returned.

Returns:



13630
13631
13632
13633
13634
13635
13636
13637
13638
13639
13640
13641
13642
13643
13644
13645
13646
13647
13648
13649
13650
# File 'lib/ovirtsdk4/services.rb', line 13630

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



13670
13671
13672
13673
13674
13675
13676
13677
13678
13679
# File 'lib/ovirtsdk4/services.rb', line 13670

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

- (String) to_s

Returns an string representation of this service.

Returns:

  • (String)


13686
13687
13688
# File 'lib/ovirtsdk4/services.rb', line 13686

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