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 12070 def initialize(connection, path) @connection = connection @path = path end
Extend the image transfer session.
@param opts [Hash] Additional options.
# File lib/ovirtsdk4/services.rb, line 12080 def extend(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}/extend", body: body ) response = @connection.send(request) case response.code when 200 action = check_action(response) else check_action(response) end end
After finishing to transfer the data, finalize the transfer.
This will make sure that the data being transferred is valid and fits the image entity that was targeted in the transfer. Specifically, will verify that if the image entity is a QCOW disk, the data uploaded is indeed a QCOW file, and that the image doesn't have a backing file.
@param opts [Hash] Additional options.
# File lib/ovirtsdk4/services.rb, line 12110 def finalize(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}/finalize", body: body ) response = @connection.send(request) case response.code when 200 action = check_action(response) else check_action(response) end end
Get the image transfer entity.
@param opts [Hash] Additional options.
@return [ImageTransfer]
# File lib/ovirtsdk4/services.rb, line 12137 def get(opts = {}) query = {} 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 ImageTransferReader.read_one(reader) ensure reader.close end else check_fault(response) end end
Pause the image transfer session.
@param opts [Hash] Additional options.
# File lib/ovirtsdk4/services.rb, line 12159 def pause(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}/pause", body: body ) response = @connection.send(request) case response.code when 200 action = check_action(response) else check_action(response) end end
Resume the image transfer session. The client will need to poll the transfer's phase until it is different than `resuming`. For example:
transfer_service = transfers_service.image_transfer_service(transfer.id) transfer_service.resume() transfer = transfer_service.get()
while transfer.phase == types.ImageTransferPhase.RESUMING:
time.sleep(1) transfer = transfer_service.get()
@param opts [Hash] Additional options.
# File lib/ovirtsdk4/services.rb, line 12196 def resume(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}/resume", body: body ) response = @connection.send(request) case response.code when 200 action = check_action(response) else check_action(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 12223 def service(path) if path.nil? || path == '' return self end raise Error.new("The path \"#{path}\" doesn't correspond to any service") end
Returns an string representation of this service.
@return [String]
# File lib/ovirtsdk4/services.rb, line 12235 def to_s "#<#{ImageTransferService}:#{@path}>" end