Synchronize a Repository

In this section, there is provided a basic workflow for synchronizing a remote repository. Bear in mind that the attached snippets utilize httpie and jq. Refer to Workflows to learn more about these utilities.

Create a repository foo

#!/usr/bin/env bash
export REPO_NAME=$(head /dev/urandom | tr -dc a-z | head -c5)

echo "Creating a new repository named $REPO_NAME."
export REPO_HREF=$(http POST $BASE_ADDR/pulp/api/v3/repositories/file/file/ name=$REPO_NAME \
  | jq -r '.pulp_href')

echo "Inspecting repository."

Repository GET Response:

    "pulp_created": "2019-05-16T19:23:55.224096Z",
    "pulp_href": "/pulp/api/v3/repositories/file/file/680f18e7-0513-461f-b067-436b03285e4c/",
    "latest_version_href": null,
    "versions_href": "/pulp/api/v3/repositories/file/file/680f18e7-0513-461f-b067-436b03285e4c/versions/",
    "description": "",
    "name": "foo"

Reference (pulpcore): Repository API Usage

Create a new remote bar

#!/usr/bin/env bash
echo "Creating a remote that points to an external source of files."
http POST $BASE_ADDR/pulp/api/v3/remotes/file/file/ \
    name='bar' \

echo "Export an environment variable for the new remote URI."
export REMOTE_HREF=$(http $BASE_ADDR/pulp/api/v3/remotes/file/file/ | jq -r '.results[] | select(.name == "bar") | .pulp_href')

echo "Inspecting new Remote."

Remote GET Response:

    "pulp_created": "2019-05-16T19:23:56.771326Z",
    "pulp_href": "/pulp/api/v3/remotes/file/file/e682efef-3974-4366-aece-a333bfaec9f3/",
    "pulp_last_updated": "2019-05-16T19:23:56.771341Z",
    "download_concurrency": 20,
    "name": "bar",
    "policy": "immediate",
    "proxy_url": "",
    "ssl_ca_certificate": null,
    "ssl_client_certificate": null,
    "ssl_client_key": null,
    "ssl_validation": true,
    "url": "",
    "validate": true

Reference: File Remote Usage

Sync repository foo using remote bar

#!/usr/bin/env bash

echo "Create a task to sync the repository using the remote."
export TASK_URL=$(http POST $BASE_ADDR$REPO_HREF'sync/' remote=$REMOTE_HREF mirror=False \
  | jq -r '.task')

# Poll the task (here we use a function defined in docs/_scripts/
wait_until_task_finished $BASE_ADDR$TASK_URL

# After the task is complete, it gives us a new repository version
echo "Set REPOVERSION_HREF from finished task."
export REPOVERSION_HREF=$(http $BASE_ADDR$TASK_URL| jq -r '.created_resources | first')

echo "Inspecting RepositoryVersion."

Repository Version GET Response (when complete):

    "pulp_created": "2019-05-16T19:23:58.230896Z",
    "pulp_href": "/pulp/api/v3/repositories/file/file/680f18e7-0513-461f-b067-436b03285e4c/versions/1/",
    "base_version": null,
    "content_summary": {
        "added": {
            "file.file": {
                "count": 3,
                "href": "/pulp/api/v3/content/file/files/?repository_version_added=/pulp/api/v3/repositories/file/file/680f18e7-0513-461f-b067-436b03285e4c/versions/1/"
        "present": {
            "file.file": {
                "count": 3,
                "href": "/pulp/api/v3/content/file/files/?repository_version=/pulp/api/v3/repositories/file/file/680f18e7-0513-461f-b067-436b03285e4c/versions/1/"
        "removed": {}
    "number": 1

Reference: File Sync Usage

Reference (pulpcore): Repository Version API Usage