Skip to content

Commit

Permalink
Merge pull request #1568 from pavelpicka/5738-mirror-repo
Browse files Browse the repository at this point in the history
Repository mirror
  • Loading branch information
goosemania committed Feb 11, 2020
2 parents fddc87b + 9713b41 commit 60eb63e
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGES/5738.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add mirror mode for sync endpoint.
2 changes: 1 addition & 1 deletion docs/_static/api.json

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions docs/workflows/create_sync_publish.rst
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ Sync repository ``foo`` using remote ``bar``
.. literalinclude:: ../_scripts/sync.sh
:language: bash

You can specify ``mirror=True`` for a mirror mode. It means Pulp won't update
repository using previous repository version but create a new copy of remote
repository as a new repository version.

RepositoryVersion GET response (when sync task complete):

.. code:: json
Expand Down
6 changes: 4 additions & 2 deletions pulp_rpm/app/tasks/synchronizing.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,14 @@ def repodata_exists(remote, url):
return True


def synchronize(remote_pk, repository_pk):
def synchronize(remote_pk, repository_pk, mirror):
"""
Sync content from the remote repository.
Create a new version of the repository that is synchronized with the remote.
Args:
mirror (bool): Mirror mode
remote_pk (str): The remote PK.
repository_pk (str): The repository PK.
Expand Down Expand Up @@ -146,7 +147,8 @@ def synchronize(remote_pk, repository_pk):

first_stage = RpmFirstStage(remote, deferred_download, treeinfo=treeinfo)
dv = RpmDeclarativeVersion(first_stage=first_stage,
repository=repository)
repository=repository,
mirror=mirror)
dv.create()


Expand Down
2 changes: 2 additions & 0 deletions pulp_rpm/app/viewsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,13 @@ def sync(self, request, pk):
)
serializer.is_valid(raise_exception=True)
remote = serializer.validated_data.get('remote')
mirror = serializer.validated_data.get('mirror')

result = enqueue_with_reservation(
tasks.synchronize,
[repository, remote],
kwargs={
'mirror': mirror,
'remote_pk': remote.pk,
'repository_pk': repository.pk
}
Expand Down

0 comments on commit 60eb63e

Please sign in to comment.