Pulp Glue Library

0.39.0 · active · verified Thu Apr 16

`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

Warnings

Install

Imports

Quickstart

This example demonstrates how to connect to a Pulp server using `PulpConnection` and `PulpAPI`, authenticate with basic credentials (from environment variables), and then list available core repositories. Adjust `PULP_BASE_URL`, `PULP_USERNAME`, and `PULP_PASSWORD` for your Pulp instance. Set `verify_ssl=True` in production if your server has a trusted certificate.

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}")

view raw JSON →