app.tasks

This module implements tasks to run.

copyright
  1. 2018 European Spallation Source ERIC

license

BSD 2-Clause, see LICENSE for more details.

class app.tasks.TaskWorker(queues, name=None, default_result_ttl=500, connection=None, exc_handler=None, exception_handlers=None, default_worker_ttl=420, job_class=None, queue_class=None, log_job_description=True, job_monitoring_interval=30, disable_default_exception_handler=False, prepare_for_work=True, serializer=None)[source]

Modified version of the rq worker which updates the task status and end time in the CSEntry database

handle_job_failure(job, queue, started_job_registry=None, exc_string='')[source]

Handles the failure or an executing job by: 1. Setting the job status to failed 2. Removing the job from StartedJobRegistry 3. Setting the workers current job to None 4. Add the job to FailedJobRegistry

handle_job_success(job, queue, started_job_registry)[source]
prepare_job_execution(job, heartbeat_ttl=None)[source]

Performs misc bookkeeping like updating states prior to job execution.

static save_exception(job, exc_string)[source]

Save the exception to the database

The exception is only saved if it occured before the AWX job was triggered. If the AWX job failed, we can refer to the logs on AWX.

static update_reverse_dependencies(job)[source]
update_task_attributes(job, attributes)[source]

Update the attributes of the task linked to the given job

app.tasks.generate_items_excel_file()[source]

Export all inventory items to an excel file

Return the name of the file

app.tasks.launch_awx_job(resource='job', **kwargs)[source]

Launch an AWX job

job_template or inventory_source shall be passed as keyword argument

Parameters
  • resource – job|workflow_job|inventory_source

  • **kwargs – keyword arguments passed to launch the job

Returns

A dictionary with information from resource.monitor

app.tasks.reindex_ansible_groups()[source]

Reindex Ansible groups

This is to ensure the hosts are up to date in the elasticsearch index for dynamic groups