class OvirtSDK4::StepsService

Public Class Methods

new(connection, path) click to toggle source

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 21934
def initialize(connection, path)
  @connection = connection
  @path = path
end

Public Instance Methods

add(step, opts = {}) click to toggle source

Add an external step to an existing job or to an existing step.

For example, to add a step to `job` with identifier `123` send the following request:

source

POST /ovirt-engine/api/jobs/123/steps


With the following request body:

source,xml

<step>

<description>Validating</description>
<start_time>2016-12-12T23:07:26.605+02:00</start_time>
<status>started</status>
<type>validating</type>

</step>


The response should look like:

source,xml

<step href=“/ovirt-engine/api/jobs/123/steps/456” id=“456”>

<actions>
  <link href="/ovirt-engine/api/jobs/123/steps/456/end" rel="end"/>
</actions>
<description>Validating</description>
<link href="/ovirt-engine/api/jobs/123/steps/456/statistics" rel="statistics"/>
<external>true</external>
<number>2</number>
<start_time>2016-12-13T01:06:15.380+02:00</start_time>
<status>started</status>
<type>validating</type>
<job href="/ovirt-engine/api/jobs/123" id="123"/>

</step>


@param step [Step] Step that will be added.

@param opts [Hash] Additional options.

@return [Step]

# File lib/ovirtsdk4/services.rb, line 21987
def add(step, opts = {})
  if step.is_a?(Hash)
    step = OvirtSDK4::Step.new(step)
  end
  query = {}
  request = HttpRequest.new(method: :POST, url: @path, query: query)
  begin
    writer = XmlWriter.new(nil, true)
    StepWriter.write_one(step, 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 StepReader.read_one(reader)
    ensure
      reader.close
    end
  else
    check_fault(response)
  end
end
list(opts = {}) click to toggle source

Retrieves the representation of the steps.

source

GET /ovirt-engine/api/job/123/steps


You will receive response in XML like this one:

source,xml

<steps>

<step href="/ovirt-engine/api/jobs/123/steps/456" id="456">
  <actions>
    <link href="/ovirt-engine/api/jobs/123/steps/456/end" rel="end"/>
  </actions>
  <description>Validating</description>
  <link href="/ovirt-engine/api/jobs/123/steps/456/statistics" rel="statistics"/>
  <external>true</external>
  <number>2</number>
  <start_time>2016-12-13T01:06:15.380+02:00</start_time>
  <status>started</status>
  <type>validating</type>
  <job href="/ovirt-engine/api/jobs/123" id="123"/>
</step>
...

</steps>


@param opts [Hash] Additional options.

@option opts [Integer] :max Sets the maximum number of steps to return. If not specified all the steps are returned.

@return [Array<Step>]

# File lib/ovirtsdk4/services.rb, line 22050
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 StepReader.read_many(reader)
    ensure
      reader.close
    end
  else
    check_fault(response)
  end
end
service(path) click to toggle source

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 22090
def service(path)
  if path.nil? || path == ''
    return self
  end
  index = path.index('/')
  if index.nil?
    return step_service(path)
  end
  return step_service(path[0..(index - 1)]).service(path[(index +1)..-1])
end
step_service(id) click to toggle source

Reference to the step service.

@param id [String] The identifier of the `step`.

@return [StepService] A reference to the `step` service.

# File lib/ovirtsdk4/services.rb, line 22079
def step_service(id)
  StepService.new(@connection, "#{@path}/#{id}")
end
to_s() click to toggle source

Returns an string representation of this service.

@return [String]

# File lib/ovirtsdk4/services.rb, line 22106
def to_s
  "#<#{StepsService}:#{@path}>"
end