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 13949 def initialize(connection, path) @connection = connection @path = path end
Set an external job execution to be cleared by the system.
For example, to set a job with identifier `123` send the following request:
POST /ovirt-engine/api/jobs/clear
With the following request body:
<action/>
@param opts [Hash] Additional options.
@option opts [Boolean] :async Indicates if the action should be performed asynchronously.
# File lib/ovirtsdk4/services.rb, line 13975 def clear(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}/clear", body: body ) response = @connection.send(request) case response.code when 200 action = check_action(response) else check_action(response) end end
Marks an external job execution as ended.
For example, to terminate a job with identifier `123` send the following request:
POST /ovirt-engine/api/jobs/end
With the following request body:
<action>
<force>true</force> <status>finished</status>
</action>
@param opts [Hash] Additional options.
@option opts [Boolean] :async Indicates if the action should be performed asynchronously.
@option opts [Boolean] :force Indicates if the job should be forcibly terminated.
@option opts [Boolean] :succeeded Indicates if the job should be marked as successfully finished or as failed.
This parameter is optional, and the default value is `true`.
# File lib/ovirtsdk4/services.rb, line 14025 def end_(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}/end", body: body ) response = @connection.send(request) case response.code when 200 action = check_action(response) else check_action(response) end end
Retrieves a job.
GET /ovirt-engine/api/jobs/123
You will receive response in XML like this one:
<job href=“/ovirt-engine/api/jobs/123” id=“123”>
<actions> <link href="/ovirt-engine/api/jobs/123/clear" rel="clear"/> <link href="/ovirt-engine/api/jobs/123/end" rel="end"/> </actions> <description>Adding Disk</description> <link href="/ovirt-engine/api/jobs/123/steps" rel="steps"/> <auto_cleared>true</auto_cleared> <end_time>2016-12-12T23:07:29.758+02:00</end_time> <external>false</external> <last_updated>2016-12-12T23:07:29.758+02:00</last_updated> <start_time>2016-12-12T23:07:26.593+02:00</start_time> <status>failed</status> <owner href="/ovirt-engine/api/users/456" id="456"/>
</job>
@param opts [Hash] Additional options.
@return [Job]
# File lib/ovirtsdk4/services.rb, line 14078 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 JobReader.read_one(reader) ensure reader.close end else 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 14111 def service(path) if path.nil? || path == '' return self end if path == 'steps' return steps_service end if path.start_with?('steps/') return steps_service.service(path[6..-1]) end raise Error.new("The path \"#{path}\" doesn't correspond to any service") end
List all the steps of the job.
@return [StepsService] A reference to `steps` service.
# File lib/ovirtsdk4/services.rb, line 14100 def steps_service StepsService.new(@connection, "#{@path}/steps") end
Returns an string representation of this service.
@return [String]
# File lib/ovirtsdk4/services.rb, line 14129 def to_s "#<#{JobService}:#{@path}>" end