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.
adispatch(func, args=None, kwargs=None, task_group=None, exclusive_resources=None, shared_resources=None, immediate=False, deferred=True, versions=None)
async
¶
Async version of dispatch.
ageneral_update(instance_id, app_label, serializer_name, *args, **kwargs)
async
¶
Async version of [pulpcore.app.tasks.base.general_update][].
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
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.
check_content(func, args)
async
¶
Spawn tasks for each async generator value to make the API requests (scan) to osv.dev.
Parameters:
-
func
(callable | str
) βA Pulp plugin function that should return an async generator with the osv.dev expected request data format plus associated Pulp Content and RepoVersion.
-
args
(tuple
) βThe positional arguments to pass on to the func.
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
aadd_and_remove(repository_pk, add_content_units, remove_content_units, base_version_pk=None)
async
¶
Aynsc version of add_and_remove.