Registry / http-networking / python-libmaas

python-libmaas

JSON →
library0.6.8pypypi✓ verified 82d ago

A client API library for interacting with MAAS (Metal as a Service). It provides a programmatic interface to manage MAAS resources like machines, networks, and storage. Currently at version 0.6.8, it has a release cadence of a few releases per year, primarily for bug fixes and minor enhancements.

pip install python-libmaas
INSTALL
IMPORT
SIG · PYTHON-LIBMAAS
P
python-libmaas
http-networkingpythonv0.6.8
Install
7.4s avg
Import
Disk
58MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.6.8 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 54.6MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 7.4s · import 0.000s · 60MB
58MB installed
● package 58MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

MaasClient
import maas
from maas import MaasClient

Demonstrates connecting to a MAAS server using an API key and listing available machines. Uses environment variables for sensitive connection details and provides basic error handling.

import os from maas.client import MaasClient from maas.client.enum import LinkMode # Example: for network configuration # Configure MAAS connection from environment variables or provide directly MAAS_URL = os.environ.get("MAAS_URL", "https://your.maas.server:5240/MAAS") MAAS_API_KEY = os.environ.get("MAAS_API_KEY", "your-maas-api-key") if "your-maas-api-key" in MAAS_API_KEY: print("Warning: Please set the MAAS_API_KEY environment variable or replace 'your-maas-api-key'.") if "your.maas.server" in MAAS_URL: print("Warning: Please set the MAAS_URL environment variable or replace 'your.maas.server'.") try: # Initialize the client client = MaasClient(MAAS_URL, api_key=MAAS_API_KEY) # Connect to the MAAS API maas = client.connect() # Example: List all machines print("Fetching machines...") machines = maas.machines.list() if machines: print(f"Found {len(machines)} machines:") for machine in machines[:3]: # Print details for up to 3 machines print(f" - Hostname: {machine.hostname}, Status: {machine.status}, ID: {machine.system_id}") if machine.ip_addresses: print(f" IPs: {[ip.ip for ip in machine.ip_addresses]}") else: print(" No IP addresses found.") else: print("No machines found in MAAS.") # Example: Get a specific machine (uncomment and replace with a known system_id) # machine_id = "your_machine_system_id" # if machine_id != "your_machine_system_id": # try: # specific_machine = maas.machines.get(system_id=machine_id) # print(f"\nDetails for machine {machine_id}: {specific_machine.hostname}, {specific_machine.status}") # except Exception as e: # print(f"\nCould not fetch machine {machine_id}: {e}") except Exception as e: print(f"An error occurred: {e}")
Debug
Known issues
breakingThe client API was completely reworked in version 0.6.0. Code written for versions prior to 0.6.0 will likely require significant updates to import paths, class names, and method calls.
fix
Refer to the official documentation and examples for versions 0.6.0+ to update your codebase. Key changes include how `MaasClient` is initialized and how MAAS resources (like machines, networks) are accessed via the `client.connect()` object.
affects: 0.6.0 and later
gotchaEnsure your MAAS URL includes the `/MAAS` suffix (e.g., `https://your.maas.server:5240/MAAS`). Omitting this suffix is a common mistake and will lead to connection errors or incorrect API endpoints.
fix
Always append `/MAAS` to the base URL when configuring the `MaasClient`.
affects: All versions
gotchaAPI keys for MAAS can have varying permissions and may expire. If you encounter authentication errors (e.g., 'Authentication required'), verify the API key's validity and permissions in your MAAS dashboard.
fix
Generate a new API key from the MAAS UI if necessary, ensuring it has appropriate permissions for the operations you intend to perform.
affects: All versions
Upgrade
Version history
0.6.8latest on PyPI · released Aug 17, 2022
Audit
Dependencies
requestsrequiredHTTP client for API communication.
PyYAMLrequiredUsed for configuration parsing and data serialization (e.g., cloud-init user data).
Agent activity
17 hits · last 30 days
node
16
Resources
python-libmaas — pip install python-libmaas · libregistry