pulpcore.plugin.tasking¶
All models documented here should be imported directly from the pulpcore.plugin.tasking
namespace.
pulpcore.plugin.tasking
¶
dispatch(func, args=None, kwargs=None, task_group=None, exclusive_resources=None, shared_resources=None, immediate=False, deferred=True, versions=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
, default:None
) –The positional arguments to pass on to the task.
-
kwargs
(dict
, default:None
) –The keyword arguments to pass on to the task.
-
task_group
(TaskGroup
, default:None
) –A TaskGroup to add the created Task to.
-
exclusive_resources
(list
, default:None
) –A list of resources this task needs exclusive access to while running. Each resource can be either a
str
or adjango.models.Model
instance. -
shared_resources
(list
, default:None
) –A list of resources this task needs non-exclusive access to while running. Each resource can be either a
str
or adjango.models.Model
instance. -
immediate
(bool
, default:False
) –Whether to allow running this task immediately. It must be guaranteed to execute fast without blocking. If not all resource constraints are met, the task will either be returned in a canceled state or, if
deferred
isTrue
be left in the queue to be picked up by a worker eventually. Defaults toFalse
. -
deferred
(bool
, default:True
) –Whether to allow defer running the task to a pulpcore_worker. Defaults to
True
.immediate
anddeferred
cannot both beFalse
. -
versions
(Optional[Dict[str, str]]
, default:None
) –Minimum versions of components by app_label the worker must provide to handle the task.
Returns (pulpcore.app.models.Task): The Pulp Task that was created.
Raises:
-
ValueError
–When
resources
is an unsupported type.
fs_publication_export(exporter_pk, publication_pk, start_repo_version_pk=None)
¶
Export a publication to the file system using an exporter.
Parameters:
-
exporter_pk
(str
) –FilesystemExporter pk
-
publication_pk
(str
) –Publication pk
fs_repo_version_export(exporter_pk, repo_version_pk, start_repo_version_pk=None)
¶
Export a repository version to the file system using an exporter.
Parameters:
-
exporter_pk
(str
) –FilesystemExporter pk
-
repo_version_pk
(str
) –RepositoryVersion pk
general_create(app_label, serializer_name, *args, **kwargs)
¶
Create a model instance.
Raises:
-
ValidationError
–If the serializer is not valid
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.
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
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
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.
orphan_cleanup(content_pks=None, orphan_protection_time=settings.ORPHAN_PROTECTION_TIME)
¶
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.
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
(uuid
) –The primary key for a Repository for which a new Repository Version should be created.
-
add_content_units
(list
) –List of PKs for pulpcore.app.models.Content that should be added to the previous Repository Version for this Repository.
-
remove_content_units
(list
) –List of PKs forpulpcore.app.models.Content that should be removed from the previous Repository Version for this Repository.
-
base_version_pk
(uuid
, default:None
) –the primary key for a RepositoryVersion whose content will be used as the initial set of content for our new RepositoryVersion