forked from pulp/pulp_container
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pulp Container now supports the Replication feature. Also, Distribution now reports whether the registry is using HTTP (unsecure) or HTTPS (secure) via the new 'secure' field inside ContainerDistributionSerializer. closes pulp#1648 closes pulp#1213
- Loading branch information
1 parent
7cab423
commit 73eb8a0
Showing
4 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Distribution now reports whether the registry is using HTTP (insecure) or HTTPS (secure) via the | ||
new 'secure' field. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Added support for the Replication feature. The replication process allows a Pulp instance to | ||
replicate container repositories from an upstream Pulp, creating the required remotes, | ||
repositories, and distributions. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
from pulpcore.plugin.replica import Replicator | ||
from pulpcore.plugin.util import get_url | ||
|
||
from pulp_glue.container.context import ( | ||
PulpContainerDistributionContext, | ||
PulpContainerRepositoryContext, | ||
) | ||
|
||
from pulp_container.app.models import ContainerDistribution, ContainerRemote, ContainerRepository | ||
from pulp_container.app.tasks import synchronize as container_synchronize | ||
|
||
|
||
class ContainerReplicator(Replicator): | ||
distribution_ctx_cls = PulpContainerDistributionContext | ||
repository_ctx_cls = PulpContainerRepositoryContext | ||
remote_model_cls = ContainerRemote | ||
repository_model_cls = ContainerRepository | ||
distribution_model_cls = ContainerDistribution | ||
distribution_serializer_name = "ContainerDistributionSerializer" | ||
repository_serializer_name = "ContainerRepositorySerializer" | ||
remote_serializer_name = "ContainerRemoteSerializer" | ||
app_label = "container" | ||
sync_task = container_synchronize | ||
|
||
def sync_params(self, repository, remote): | ||
"""Returns a dictionary where key is a parameter for the sync task.""" | ||
return dict( | ||
remote_pk=str(remote.pk), | ||
repository_pk=str(repository.pk), | ||
signed_only=False, | ||
mirror=True, | ||
) | ||
|
||
def url(self, upstream_distribution): | ||
scheme = "https" if upstream_distribution["secure"] else "http" | ||
registry_url = upstream_distribution["registry_path"].split("/")[0] | ||
return f"{scheme}://{registry_url}" | ||
|
||
def remote_extra_fields(self, upstream_distribution): | ||
upstream_name = upstream_distribution["registry_path"].split("/")[1] | ||
return {"upstream_name": upstream_name} | ||
|
||
def distribution_data(self, repository, upstream_distribution): | ||
""" | ||
Return the fields that need to be updated/cleared on distributions for idempotence. | ||
""" | ||
return { | ||
"repository": get_url(repository), | ||
"base_path": upstream_distribution["base_path"], | ||
"private": upstream_distribution["private"], | ||
} | ||
|
||
|
||
REPLICATION_ORDER = [ContainerReplicator] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters