Skip to content
Permalink
Browse files

Updating the sync code due to breaking changes in Galaxy in API

  • Loading branch information...
daviddavis committed Aug 29, 2018
1 parent bf91821 commit 83f377602897ebf58261ca0d92473dc57a64ac25
Showing with 7 additions and 3 deletions.
  1. +1 −1 README.rst
  2. +6 −2 pulp_ansible/app/tasks/synchronizing.py
@@ -89,7 +89,7 @@ Create a repository ``foo``
Create a new remote ``bar``
-----------------------------

``$ http POST :8000/pulp/api/v3/remotes/ansible/ name=bar url='https://galaxy.ansible.com/api/v1/roles/?namespace=elastic'``
``$ http POST :8000/pulp/api/v3/remotes/ansible/ name=bar url='https://galaxy.ansible.com/api/v1/roles/?namespace__name=elastic'``

.. code:: json
@@ -1,5 +1,6 @@
import json
import logging
import math

from collections import namedtuple
from concurrent.futures import FIRST_COMPLETED
@@ -34,6 +35,9 @@
# The Github URL template to fetch a .tar.gz file from
GITHUB_URL = 'https://github.com/%s/%s/archive/%s.tar.gz'

# default results per page. used to calculate number of pages
PAGE_SIZE = 10


def synchronize(remote_pk, repository_pk):
"""
@@ -101,7 +105,7 @@ def parse_roles(metadata):

for result in metadata['results']:
role = {'name': result['name'],
'namespace': result['namespace'],
'namespace': result['summary_fields']['namespace']['name'],
'summary_fields': result['summary_fields'], # needed for versions
'github_user': result['github_user'],
'github_repo': result['github_repo']}
@@ -132,7 +136,7 @@ def role_page_url(remote, page=1):

def parse_metadata(path):
metadata = json.load(open(path))
page_count = metadata['num_pages']
page_count = math.ceil(float(metadata['count']) / float(PAGE_SIZE))
return page_count, parse_roles(metadata)

downloader = remote.get_downloader(role_page_url(remote))

0 comments on commit 83f3776

Please sign in to comment.
You can’t perform that action at this time.