Class: OvirtSDK4::JobsService

Inherits:
Service
  • Object
show all
Defined in:
lib/ovirtsdk4/services.rb,
lib/ovirtsdk4/services.rb

Instance Method Summary collapse

Methods inherited from Service

#inspect, #to_s

Instance Method Details

#add(job, opts = {}) ⇒ Job

Add an external job.

For example, to add a job with the following request:

POST /ovirt-engine/api/jobs

With the following request body:

<job>
  <description>Doing some work</description>
  <auto_cleared>true</auto_cleared>
</job>

The response should look like:

<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>Doing some work</description>
  <link href="/ovirt-engine/api/jobs/123/steps" rel="steps"/>
  <auto_cleared>true</auto_cleared>
  <external>true</external>
  <last_updated>2016-12-13T02:15:42.130+02:00</last_updated>
  <start_time>2016-12-13T02:15:42.130+02:00</start_time>
  <status>started</status>
  <owner href="/ovirt-engine/api/users/456" id="456"/>
</job>

Parameters:

  • job (Job)

    Job that will be added.

  • opts (Hash) (defaults to: {})

    Additional options.

Options Hash (opts):

  • :headers (Hash) — default: {}

    Additional HTTP headers.

  • :query (Hash) — default: {}

    Additional URL query parameters.

  • :timeout (Integer) — default: nil

    The timeout for this request, in seconds. If no value is explicitly given then the timeout set globally for the connection will be used.

  • :wait (Boolean) — default: true

    If true wait for the response.

Returns:



15179
15180
15181
# File 'lib/ovirtsdk4/services.rb', line 15179

def add(job, opts = {})
  internal_add(job, Job, ADD, opts)
end

#job_service(id) ⇒ JobService

Reference to the job service.

Parameters:

  • id (String)

    The identifier of the job.

Returns:

  • (JobService)

    A reference to the job service.



15261
15262
15263
# File 'lib/ovirtsdk4/services.rb', line 15261

def job_service(id)
  JobService.new(self, id)
end

#list(opts = {}) ⇒ Array<Job>

Retrieves the representation of the jobs.

GET /ovirt-engine/api/jobs

You will receive response in XML like this one:

<jobs>
  <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>
  ...
</jobs>

The order of the returned list of jobs isn’t guaranteed.

Parameters:

  • opts (Hash) (defaults to: {})

    Additional options.

Options Hash (opts):

  • :case_sensitive (Boolean)

    Indicates if the search performed using the search parameter should be performed taking case into account. The default value is true, which means that case is taken into account. If you want to search ignoring case set it to false.

  • :follow (String)

    Indicates which inner links should be followed. The objects referenced by these links will be fetched as part of the current request. See here for details.

  • :max (Integer)

    Sets the maximum number of jobs to return. If not specified all the jobs are returned.

  • :search (String)

    A query string used to restrict the returned jobs.

  • :headers (Hash) — default: {}

    Additional HTTP headers.

  • :query (Hash) — default: {}

    Additional URL query parameters.

  • :timeout (Integer) — default: nil

    The timeout for this request, in seconds. If no value is explicitly given then the timeout set globally for the connection will be used.

  • :wait (Boolean) — default: true

    If true wait for the response.

Returns:



15250
15251
15252
# File 'lib/ovirtsdk4/services.rb', line 15250

def list(opts = {})
  internal_get(LIST, opts)
end

#service(path) ⇒ Service

Locates the service corresponding to the given path.

Parameters:

  • path (String)

    The path of the service.

Returns:

  • (Service)

    A reference to the service.



15272
15273
15274
15275
15276
15277
15278
15279
15280
15281
# File 'lib/ovirtsdk4/services.rb', line 15272

def service(path)
  if path.nil? || path == ''
    return self
  end
  index = path.index('/')
  if index.nil?
    return job_service(path)
  end
  return job_service(path[0..(index - 1)]).service(path[(index + 1)..-1])
end