Creates a new implementation of the service.
@param connection [Connection] The connection to be used by this service.
@param path [String] The relative path of this service, for example `vms/123/disks`.
@api private
# File lib/ovirtsdk4/services.rb, line 9772 def initialize(connection, path) @connection = connection @path = path end
Activate the bricks post data migration of remove brick operation.
Used to activate brick(s) once the data migration from bricks is complete but user no longer wishes to remove bricks. The bricks that were previously marked for removal will now be used as normal bricks.
For example, to retain the bricks that on glustervolume `123` from which data was migrated, send a request like this:
POST /ovirt-engine/api/clusters/567/glustervolumes/123/glusterbricks/activate
With a request body like this:
<action>
<bricks> <brick> <name>host1:/rhgs/brick1</name> </brick> </bricks>
</action>
@param opts [Hash] Additional options.
@option opts [Boolean] :async Indicates if the activation should be performed asynchronously.
@option opts [Array<GlusterBrick>] :bricks The list of bricks that need to be re-activated.
# File lib/ovirtsdk4/services.rb, line 9810 def activate(opts = {}) action = Action.new(opts) writer = XmlWriter.new(nil, true) ActionWriter.write_one(action, writer) body = writer.string writer.close request = HttpRequest.new( method: :POST, url: "#{@path}/activate", body: body ) response = @connection.send(request) case response.code when 200 action = check_action(response) else check_action(response) end end
Adds a list of bricks to gluster volume.
Used to expand a gluster volume by adding bricks. For replicated volume types, the parameter `replica_count` needs to be passed. In case the replica count is being increased, then the number of bricks needs to be equivalent to the number of replica sets.
For example, to add bricks to gluster volume `123`, send a request like this:
POST /ovirt-engine/api/clusters/567/glustervolumes/123/glusterbricks
With a request body like this:
<bricks>
<brick> <server_id>111</server_id> <brick_dir>/export/data/brick3</brick_dir> </brick>
</bricks>
@param bricks [Array<GlusterBrick>] The list of bricks to be added to the volume
@param opts [Hash] Additional options.
@option opts [Integer] :replica_count Replica count of volume post add operation.
@option opts [Integer] :stripe_count Stripe count of volume post add operation.
@return [Array<GlusterBrick>]
# File lib/ovirtsdk4/services.rb, line 9866 def add(bricks, opts = {}) if bricks.is_a?(Array) bricks = List.new(bricks) bricks.each_with_index do |value, index| if value.is_a?(Hash) bricks[index] = OvirtSDK4::GlusterBrick.new(value) end end end query = {} value = opts[:replica_count] unless value.nil? value = Writer.render_integer(value) query['replica_count'] = value end value = opts[:stripe_count] unless value.nil? value = Writer.render_integer(value) query['stripe_count'] = value end request = HttpRequest.new(method: :POST, url: @path, query: query) begin writer = XmlWriter.new(nil, true) GlusterBrickWriter.write_many(bricks, writer) request.body = writer.string ensure writer.close end response = @connection.send(request) case response.code when 200, 201, 202 begin reader = XmlReader.new(response.body) return GlusterBrickReader.read_many(reader) ensure reader.close end else check_fault(response) end end
Returns a reference to the service managing a single gluster brick.
@param id [String] The identifier of the `brick`.
@return [GlusterBrickService] A reference to the `brick` service.
# File lib/ovirtsdk4/services.rb, line 10135 def brick_service(id) GlusterBrickService.new(@connection, "#{@path}/#{id}") end
Lists the bricks of a gluster volume.
For example, to list bricks of gluster volume `123`, send a request like this:
GET /ovirt-engine/api/clusters/567/glustervolumes/123/glusterbricks
Provides an output as below:
<bricks>
<brick id="234"> <name>host1:/rhgs/data/brick1</name> <brick_dir>/rhgs/data/brick1</brick_dir> <server_id>111</server_id> <status>up</status> </brick> <brick id="233"> <name>host2:/rhgs/data/brick1</name> <brick_dir>/rhgs/data/brick1</brick_dir> <server_id>222</server_id> <status>up</status> </brick>
</bricks>
@param opts [Hash] Additional options.
@option opts [Integer] :max Sets the maximum number of bricks to return. If not specified all the bricks are returned.
@return [Array<GlusterBrick>]
# File lib/ovirtsdk4/services.rb, line 9944 def list(opts = {}) query = {} value = opts[:max] unless value.nil? value = Writer.render_integer(value) query['max'] = value end request = HttpRequest.new(method: :GET, url: @path, query: query) response = @connection.send(request) case response.code when 200 begin reader = XmlReader.new(response.body) return GlusterBrickReader.read_many(reader) ensure reader.close end else check_fault(response) end end
Start migration of data prior to removing bricks.
Removing bricks is a two-step process, where the data on bricks to be removed, is first migrated to remaining bricks. Once migration is completed the removal of bricks is confirmed via the API <<services/gluster_bricks/methods/remove, remove>>. If at any point, the action needs to be cancelled <<services/gluster_bricks/methods/stop_migrate, stopmigrate>> has to be called.
For instance, to delete a brick from a gluster volume with id `123`, send a request:
POST /ovirt-engine/api/clusters/567/glustervolumes/123/glusterbricks/migrate
With a request body like this:
<action>
<bricks> <brick> <name>host1:/rhgs/brick1</name> </brick> </bricks>
</action>
The migration process can be tracked from the job id returned from the API using <<services/job/methods/get, job>> and steps in job using <<services/step/methods/get, step>>
@param opts [Hash] Additional options.
@option opts [Boolean] :async Indicates if the migration should be performed asynchronously.
@option opts [Array<GlusterBrick>] :bricks List of bricks for which data migration needs to be started.
# File lib/ovirtsdk4/services.rb, line 10003 def migrate(opts = {}) action = Action.new(opts) writer = XmlWriter.new(nil, true) ActionWriter.write_one(action, writer) body = writer.string writer.close request = HttpRequest.new( method: :POST, url: "#{@path}/migrate", body: body ) response = @connection.send(request) case response.code when 200 action = check_action(response) else check_action(response) end end
Removes bricks from gluster volume.
The recommended way to remove bricks without data loss is to first migrate the data using <<services/gluster_bricks/methods/stop_migrate, stopmigrate>> and then removing them. If migrate was not called on bricks prior to remove, the bricks are removed without data migration which may lead to data loss.
For example, to delete the bricks from gluster volume `123`, send a request like this:
DELETE /ovirt-engine/api/clusters/567/glustervolumes/123/glusterbricks
With a request body like this:
<bricks>
<brick> <name>host:brick_directory</name> </brick>
</bricks>
@param opts [Hash] Additional options.
@option opts [Boolean] :async Indicates if the remove should be performed asynchronously. @option opts [Array<GlusterBrick>] :bricks The list of bricks to be removed @option opts [Integer] :replica_count Replica count of volume post add operation.
# File lib/ovirtsdk4/services.rb, line 10053 def remove(opts = {}) query = {} value = opts[:async] unless value.nil? value = Writer.render_boolean(value) query['async'] = value end value = opts[:bricks] unless value.nil? query['bricks'] = value end value = opts[:replica_count] unless value.nil? value = Writer.render_integer(value) query['replica_count'] = value end request = HttpRequest.new(method: :DELETE, url: @path, query: query) response = @connection.send(request) unless response.code == 200 check_fault(response) end end
Locates the service corresponding to the given path.
@param path [String] The path of the service.
@return [Service] A reference to the service.
# File lib/ovirtsdk4/services.rb, line 10146 def service(path) if path.nil? || path == '' return self end index = path.index('/') if index.nil? return brick_service(path) end return brick_service(path[0..(index - 1)]).service(path[(index +1)..-1]) end
Stops migration of data from bricks for a remove brick operation.
To cancel data migration that was started as part of the 2-step remove brick process in case the user wishes to continue using the bricks. The bricks that were marked for removal will function as normal bricks post this operation.
For example, to stop migration of data from the bricks of gluster volume `123`, send a request like this:
POST /ovirt-engine/api/clusters/567/glustervolumes/123/glusterbricks/stopmigrate
With a request body like this:
<bricks>
<brick> <name>host:brick_directory</name> </brick>
</bricks>
@param opts [Hash] Additional options.
@option opts [Boolean] :async Indicates if the action should be performed asynchronously.
@option opts [Array<GlusterBrick>] :bricks List of bricks for which data migration needs to be stopped. This list should match the arguments passed to
<<services/gluster_bricks/methods/migrate, migrate>>.
# File lib/ovirtsdk4/services.rb, line 10108 def stop_migrate(opts = {}) action = Action.new(opts) writer = XmlWriter.new(nil, true) ActionWriter.write_one(action, writer) body = writer.string writer.close request = HttpRequest.new( method: :POST, url: "#{@path}/stopmigrate", body: body ) response = @connection.send(request) case response.code when 200 action = check_action(response) else check_action(response) end end
Returns an string representation of this service.
@return [String]
# File lib/ovirtsdk4/services.rb, line 10162 def to_s "#<#{GlusterBricksService}:#{@path}>" end