Pulp Glue DEB
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
-
PulpConnectionError: Failed to connect to Pulp at '...' with HTTP status: 401 Unauthorized
cause Incorrect Pulp API URL, wrong username/password, or the Pulp server is not running or accessible with the provided credentials.fixVerify that `PULP_API_URL`, `PULP_USERNAME`, and `PULP_PASSWORD` environment variables (or direct parameters) are correctly set. Ensure the Pulpcore server is running and reachable from where the client code is executed. -
pulp_glue_core.connection.PulpConnectionError: Received 404 Not Found when trying to access /pulp/api/v3/deb/
cause The `pulp_deb` content plugin is likely not installed, not enabled, or not properly configured on your Pulpcore server instance.fixLog into your Pulpcore server and confirm that the `pulp_deb` plugin is installed, enabled, and its API endpoints are available. Consult the Pulp documentation for proper plugin installation and troubleshooting. -
AttributeError: 'DebClient' object has no attribute 'create_repository'
cause This error typically indicates that the `pulp-glue-deb` library version is significantly outdated compared to the Pulpcore server's API, or you are attempting to call a function that does not exist in the current API schema.fixUpgrade `pulp-glue-deb` to the latest stable version using `pip install --upgrade pulp-glue-deb`. Review the `pulp-glue-deb` documentation or source code for the correct method signatures for your desired operation.
Warnings
- gotcha Pulpcore content plugins (e.g., `pulp_deb`) must be installed and enabled on the target Pulpcore server for pulp-glue-deb functionality to work. Without it, you'll encounter 404 or 400 errors when trying to use DEB-specific APIs.
- gotcha While `pulp-glue` aims to be version-agnostic, significant breaking changes in the underlying Pulpcore REST API can still lead to incompatibility. Always check the release notes for `pulp-glue-deb` and `pulpcore` when performing major upgrades.
- gotcha The `PulpConnection` often uses `verify_ssl=False` in quickstarts for local development. This is insecure and should NEVER be used in production with untrusted certificate authorities. Always verify SSL certificates.
Install
-
pip install pulp-glue-deb
Imports
- PulpConnection
from pulp_glue_deb.connection import PulpConnection
from pulp_glue_core.connection import PulpConnection
- api
from pulp_glue_deb.app.deb import api as deb_api
- DebClient
from pulp_glue_deb.app.deb.api import DebClient
Quickstart
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.")