pulpcore.plugin.tasking

All models documented here should be imported directly from the pulpcore.plugin.tasking namespace.

pulpcore.plugin.tasking.add_and_remove(repository_pk, add_content_units, remove_content_units, base_version_pk=None)

Create a new repository version by adding and then removing content units.

Parameters
  • repository_pk (int) – The primary key for a Repository for which a new Repository Version should be created.

  • add_content_units (list) – List of PKs for Content that should be added to the previous Repository Version for this Repository.

  • remove_content_units (list) – List of PKs for:class:~pulpcore.app.models.Content that should be removed from the previous Repository Version for this Repository.

  • base_version_pk (int) – the primary key for a RepositoryVersion whose content will be used as the initial set of content for our new RepositoryVersion

pulpcore.plugin.tasking.dispatch(func, args=None, kwargs=None, task_group=None, exclusive_resources=None, shared_resources=None)

Enqueue a message to Pulp workers with a reservation.

This method provides normal enqueue functionality, while also requesting necessary locks for serialized urls. No two tasks that claim the same resource can execute concurrently. It accepts resources which it transforms into a list of urls (one for each resource).

This method creates a pulpcore.app.models.Task object and returns it.

The values in args and kwargs must be JSON serializable, but may contain instances of uuid.UUID.

Parameters
  • func (callable | str) – The function to be run when the necessary locks are acquired.

  • args (tuple) – The positional arguments to pass on to the task.

  • kwargs (dict) – The keyword arguments to pass on to the task.

  • task_group (pulpcore.app.models.TaskGroup) – A TaskGroup to add the created Task to.

  • exclusive_resources (list) – A list of resources this task needs exclusive access to while running. Each resource can be either a str or a django.models.Model instance.

  • shared_resources (list) – A list of resources this task needs non-exclusive access to while running. Each resource can be either a str or a django.models.Model instance.

Returns (pulpcore.app.models.Task): The Pulp Task that was created.

Raises

ValueError – When resources is an unsupported type.

pulpcore.plugin.tasking.fs_publication_export(exporter_pk, publication_pk)

Export a publication to the file system.

Parameters
  • exporter_pk (str) – FilesystemExporter pk

  • publication_pk (str) – Publication pk

pulpcore.plugin.tasking.fs_repo_version_export(exporter_pk, repo_version_pk)

Export a repository version to the file system.

Parameters
  • exporter_pk (str) – FilesystemExporter pk

  • repo_version_pk (str) – RepositoryVersion pk

pulpcore.plugin.tasking.general_create(app_label, serializer_name, *args, **kwargs)

Create a model instance.

Raises

ValidationError – If the serializer is not valid

pulpcore.plugin.tasking.general_create_from_temp_file(app_label, serializer_name, temp_file_pk, *args, **kwargs)

Create a model instance from contents stored in a temporary file.

A task which executes this function takes the ownership of a temporary file and deletes it afterwards. This function calls the function general_create() to create a model instance.

pulpcore.plugin.tasking.general_delete(instance_id, app_label, serializer_name)

Delete a model

The model instance is identified using the app_label, id, and serializer name.

Parameters
  • id (str) – the id of the model

  • app_label (str) – the Django app label of the plugin that provides the model

  • serializer_name (str) – name of the serializer class for the model

pulpcore.plugin.tasking.general_multi_delete(instance_ids)

Delete a list of model instances in a transaction

The model instances are identified using the id, app_label, and serializer_name.

Parameters

instance_ids (list) – List of tupels of id, app_label, serializer_name

pulpcore.plugin.tasking.general_update(instance_id, app_label, serializer_name, *args, **kwargs)

Update a model

The model instance is identified using the app_label, id, and serializer name. The serializer is used to perform validation.

Parameters
  • id (str) – the id of the model

  • app_label (str) – the Django app label of the plugin that provides the model

  • serializer_name (str) – name of the serializer class for the model

  • data (dict) – dictionary whose keys represent the fields of the model and their corresponding values.

  • partial (bool) – When true, only the fields specified in the data dictionary are updated. When false, any fields missing from the data dictionary are assumed to be None and their values are updated as such.

Raises

rest_framework.exceptions.ValidationError – When serializer instance can’t be saved due to validation error. This theoretically should never occur since validation is performed before the task is dispatched.

pulpcore.plugin.tasking.orphan_cleanup(content_pks=None, orphan_protection_time=0)

Delete all orphan Content and Artifact records. Go through orphan Content multiple times to remove content from subrepos. This task removes Artifact files from the filesystem as well.

Kwargs:

content_pks (list): A list of content pks. If specified, only remove these orphans.

pulpcore.plugin.tasking.reclaim_space(repo_pks, keeplist_rv_pks=None, force=False)

This task frees-up disk space by removing Artifact files from the filesystem for Content exclusive to the list of provided repos.

Note: content marked as proctected will be excluded from the reclaim disk space.

Kwargs:

repo_pks (list): A list of repo pks the disk reclaim space is performed on. keeplist_rv_pks (list): A list of repo version pks that will be excluded from the reclaim disk space. force (bool): If True, uploaded content will be taken into account.