From 44b3067ca2511f72d4b3352e22e69e112da041c4 Mon Sep 17 00:00:00 2001 From: Gerrod Ubben Date: Sun, 3 Mar 2024 01:29:07 -0500 Subject: [PATCH] Add replicator support fixes: #648 --- CHANGES/648.feature | 1 + pulp_python/app/replica.py | 39 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 CHANGES/648.feature create mode 100644 pulp_python/app/replica.py diff --git a/CHANGES/648.feature b/CHANGES/648.feature new file mode 100644 index 000000000..6c1195673 --- /dev/null +++ b/CHANGES/648.feature @@ -0,0 +1 @@ +Added Pulp replication support for Python distributions. diff --git a/pulp_python/app/replica.py b/pulp_python/app/replica.py new file mode 100644 index 000000000..e59c80543 --- /dev/null +++ b/pulp_python/app/replica.py @@ -0,0 +1,39 @@ +from pulpcore.plugin.replica import Replicator + +from pulp_glue.python.context import ( + PulpPythonDistributionContext, + PulpPythonPublicationContext, + PulpPythonRepositoryContext, +) +from pulp_python.app.models import PythonDistribution, PythonRemote, PythonRepository +from pulp_python.app.tasks import sync as python_sync + + +class PythonReplicator(Replicator): + repository_ctx_cls = PulpPythonRepositoryContext + distribution_ctx_cls = PulpPythonDistributionContext + publication_ctx_cls = PulpPythonPublicationContext + app_label = "python" + remote_model_cls = PythonRemote + repository_model_cls = PythonRepository + distribution_model_cls = PythonDistribution + distribution_serializer_name = "PythonDistributionSerializer" + repository_serializer_name = "PythonRepositorySerializer" + remote_model_serializer_name = "PythonRemoteSerializer" + sync_task = python_sync + + def remote_extra_fields(self, upstream_distribution): + # This could be dangerous since python remotes are default 'on_demand' + # Upstream sources could be entirely 'on_demand' and this replicator policy would heavily + # strain the upstream Pulp. + return {"policy": "immediate", "prereleases": True} + + def repository_extra_fields(self, remote): + # Use autopublish since publications result in faster serving times + return {"autopublish": True} + + def sync_params(self, repository, remote): + return {"remote_pk": str(remote.pk), "repository_pk": str(repository.pk), "mirror": True} + + +REPLICATION_ORDER = [PythonReplicator]