Class: OvirtSDK4::GlusterVolumesService
- Inherits:
-
Service
- Object
- Service
- OvirtSDK4::GlusterVolumesService
- Defined in:
- lib/ovirtsdk4/services.rb,
lib/ovirtsdk4/services.rb
Instance Method Summary (collapse)
-
- (GlusterVolume) add(volume, opts = {})
Creates a new Gluster volume and adds it to the database.
-
- (Array<GlusterVolume>) list(opts = {})
Returns the representation of the object managed by this service.
-
- (Service) service(path)
Locates the service corresponding to the given path.
-
- (String) to_s
Returns an string representation of this service.
-
- (GlusterVolumeService) volume_service(id)
Locates the
volume
service.
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.
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.
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.
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.
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.
8976 8977 8978 |
# File 'lib/ovirtsdk4/services.rb', line 8976 def volume_service(id) return GlusterVolumeService.new(@connection, "#{@path}/#{id}") end |