-
Notifications
You must be signed in to change notification settings - Fork 87
Expand file tree
/
Copy pathreplica.py
More file actions
48 lines (37 loc) · 1.84 KB
/
Copy pathreplica.py
File metadata and controls
48 lines (37 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
from pulp_glue.python.context import (
PulpPythonDistributionContext,
PulpPythonPublicationContext,
PulpPythonRepositoryContext,
)
from pulpcore.plugin.replica import Replicator
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 url(self, upstream_distribution):
# Ignore distributions that are only pull-through
repo, pub = upstream_distribution["repository"], upstream_distribution["publication"]
repo_ver = upstream_distribution.get("repository_version")
if repo or pub or repo_ver:
return super().url(upstream_distribution)
return None
def repository_extra_fields(self, remote):
return {"autopublish": False}
def sync_params(self, repository, remote):
return {"remote_pk": str(remote.pk), "repository_pk": str(repository.pk), "mirror": True}
REPLICATION_ORDER = [PythonReplicator]