Pulp Glue Library
`pulp-glue` is a Python library that provides a version-agnostic interface for interacting with PulpCore's REST API. It aims to abstract differences between PulpCore API versions, offering a more stable API surface for consumers. The current version is 0.39.0, with regular updates typically tied to PulpCore releases.
Common errors
-
AttributeError: 'PulpAPI' object has no attribute 'get_client'
cause Attempting to use the deprecated `get_client()` method directly on a `PulpAPI` instance.fixImport `get_client` from `pulp_glue.pulpcore.client` and call it directly, or interact with API resources directly via the `PulpAPI` object (e.g., `api.repositories_core.list()`). -
httpx.ConnectError: [Errno 111] Connection refused (or similar 'Connection refused')
cause The Pulp server is not running or is unreachable at the specified `base_url`.fixVerify the Pulp server status and ensure the `PULP_BASE_URL` is correct and accessible from your client. Check network connectivity and firewall rules. -
httpx.HTTPStatusError: Client error '401 Unauthorized' for url: ...
cause Incorrect username or password provided for basic authentication to the Pulp server.fixDouble-check `PULP_USERNAME` and `PULP_PASSWORD` are correct for your Pulp instance. -
httpx.ConnectError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed
cause The SSL certificate of the Pulp server cannot be verified, often due to self-signed certificates or misconfiguration in a development environment.fixFor development or testing, set `verify_ssl=False` in the `PulpConnection` constructor. For production, ensure the server uses a valid, trusted SSL certificate and that your system's certificate authorities are up-to-date.
Warnings
- breaking Support for Python 3.6 was dropped in version 0.28.0, and Python 3.7 was dropped in version 0.33.0.
- deprecated The `PulpAPI.get_client()` method was deprecated in version 0.34.0.
- gotcha The `verify_ssl` argument in `PulpConnection` now defaults to `True` since version 0.27.0. If you are using self-signed certificates or a development environment, you might need to set `verify_ssl=False` explicitly.
Install
-
pip install pulp-glue
Imports
- PulpConnection
from pulp_glue.common.connection import PulpConnection
- PulpAPI
from pulp_glue.common.api import PulpAPI
- get_client
api_instance.get_client()
from pulp_glue.pulpcore.client import get_client
Quickstart
import os
from pulp_glue.common.connection import PulpConnection
from pulp_glue.common.api import PulpAPI
import httpx # For error handling
# Configuration (replace with your Pulp server details or environment variables)
PULP_BASE_URL = os.environ.get('PULP_BASE_URL', 'https://localhost:8080/pulp/api/v3/')
PULP_USERNAME = os.environ.get('PULP_USERNAME', 'admin')
PULP_PASSWORD = os.environ.get('PULP_PASSWORD', 'password')
try:
# 1. Establish a connection
# In production, ensure verify_ssl=True with valid certs
connection = PulpConnection(
base_url=PULP_BASE_URL,
basic_auth=(PULP_USERNAME, PULP_PASSWORD),
verify_ssl=False
)
# 2. Initialize the API client
api = PulpAPI(connection)
# 3. Perform a basic operation (e.g., list repositories)
print(f"Connecting to Pulp at: {PULP_BASE_URL}")
print(f"Listing core repositories:")
repositories = api.repositories_core.list()
for repo in repositories.results:
print(f" - {repo.name} (Pulp HREF: {repo.pulp_href})")
except httpx.HTTPStatusError as e:
print(f"HTTP Error: {e.response.status_code} - {e.response.text}")
print("Please check your Pulp URL, username, and password.")
except httpx.RequestError as e:
print(f"Request Error: {e}")
print("Could not connect to the Pulp server. Check the URL and server status.")
except Exception as e:
print(f"An unexpected error occurred: {e}")