Class: OvirtSDK4::GlusterVolumesService

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

Instance Method Summary (collapse)

Instance Method Details

- (GlusterVolume) add(volume, opts = {})

Creates a new Gluster volume and adds it to the database. The volume is created based on properties of the volume parameter. The properties name, volumeType and bricks are required.

Parameters:

Returns:



8897
8898
8899
8900
8901
8902
8903
8904
8905
8906
8907
8908
8909
8910
8911
8912
8913
8914
8915
8916
8917
8918
8919
8920
8921
# File 'lib/ovirtsdk4/services.rb', line 8897

def add(volume, opts = {})
  if volume.is_a?(Hash)
    volume = OvirtSDK4::GlusterVolume.new(volume)
  end
  request = Request.new(:method => :POST, :path => @path)
  begin
    writer = XmlWriter.new(nil, true)
    GlusterVolumeWriter.write_one(volume, writer, 'volume')
    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 GlusterVolumeReader.read_one(reader)
    ensure
      reader.close
    end
  else
    check_fault(response)
  end
end

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

Returns the representation of the object managed by this service.

Parameters:

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

    Additional options.

Options Hash (opts):

  • :case_sensitive (Boolean)

    Indicates if the search performed using the search parameter should be performed taking case into account. The default value is true, which means that case is taken into account. If you want to search ignoring case set it to false.

  • :max (Integer)

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

  • :search (String)

    A query string used to restrict the returned volumes.

Returns:



8938
8939
8940
8941
8942
8943
8944
8945
8946
8947
8948
8949
8950
8951
8952
8953
8954
8955
8956
8957
8958
8959
8960
8961
8962
8963
8964
8965
8966
8967
# File 'lib/ovirtsdk4/services.rb', line 8938

def list(opts = {})
  query = {}
  value = opts[:case_sensitive]
  unless value.nil?
    value = Writer.render_boolean(value)
    query['case_sensitive'] = value
  end
  value = opts[:max]
  unless value.nil?
    value = Writer.render_integer(value)
    query['max'] = value
  end
  value = opts[:search]
  unless value.nil?
    query['search'] = 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 GlusterVolumeReader.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.



8987
8988
8989
8990
8991
8992
8993
8994
8995
8996
# File 'lib/ovirtsdk4/services.rb', line 8987

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

- (String) to_s

Returns an string representation of this service.

Returns:

  • (String)


9003
9004
9005
# File 'lib/ovirtsdk4/services.rb', line 9003

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

- (GlusterVolumeService) volume_service(id)

Locates the volume service.

Parameters:

  • id (String)

    The identifier of the volume.

Returns:



8976
8977
8978
# File 'lib/ovirtsdk4/services.rb', line 8976

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