Pulp Glue DEB

0.4.3 · active · verified Thu Apr 16

pulp-glue-deb is a Python glue library designed to provide a version-agnostic interface for interacting with the Pulpcore REST API, specifically for managing Debian (DEB) content. It abstracts away version-specific API changes, allowing developers to write more resilient code. The current version is 0.4.3, and it receives regular updates, typically a few releases per year, indicating active maintenance.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to establish a connection to a Pulpcore server and create a new Debian repository using `pulp-glue-deb`. It uses environment variables for Pulp API credentials and gracefully handles pre-existing repositories.

import os
from pulp_glue_core.connection import PulpConnection
from pulp_glue_deb.app.deb import api as deb_api

# Get Pulp API URL and credentials from environment variables
PULP_API_URL = os.environ.get('PULP_API_URL', 'http://localhost:8080/pulp/api/v3/')
PULP_USERNAME = os.environ.get('PULP_USERNAME', 'admin')
PULP_PASSWORD = os.environ.get('PULP_PASSWORD', 'password')

try:
    # 1. Establish connection to Pulp
    # Set verify_ssl=True in production and ensure valid certificates
    connection = PulpConnection(
        PULP_API_URL,
        username=PULP_USERNAME,
        password=PULP_PASSWORD,
        verify_ssl=False # WARNING: Do not use False in production with untrusted CAs
    )
    print(f"Connected to Pulp at {PULP_API_URL}")

    # 2. Get the DEB API client
    deb_client = deb_api.DebClient(connection)

    # 3. Create a DEB repository
    repo_name = "my-test-deb-repo"
    repo_description = "A test Debian repository created via pulp-glue-deb."

    # Check if repository already exists to avoid creation error
    existing_repos = deb_client.list_repositories(name=repo_name)
    if existing_repos:
        repo = existing_repos[0]
        print(f"Repository '{repo_name}' already exists (Pulp Href: {repo['pulp_href']}).")
    else:
        repo = deb_client.create_repository(
            name=repo_name,
            description=repo_description
        )
        print(f"Successfully created DEB repository: {repo['name']} (Pulp Href: {repo['pulp_href']})")

    # Optional: Delete the created repository
    # deb_client.delete_repository(repo['pulp_href'])
    # print(f"Deleted repository '{repo_name}'.")

except Exception as e:
    print(f"An error occurred: {e}")
    print("Ensure Pulpcore with the 'deb' plugin is running and accessible. Also verify environment variables PULP_API_URL, PULP_USERNAME, PULP_PASSWORD are set correctly.")

view raw JSON →