tessl install tessl/pypi-python-libmaas@0.6.0Python client library for MAAS 2.0+ with sync/async support, providing machine provisioning, network management, and storage configuration.
Command-line interface for managing MAAS servers from the terminal. The maas command provides comprehensive access to MAAS functionality through subcommands.
The CLI is installed as part of the python-libmaas package:
pip install python-libmaasThis provides the maas command-line tool.
# General syntax
maas [--help] <profile> <command> [options]Create a new profile and authenticate:
maas login <profile-name> <url> [apikey]Examples:
# Login with interactive prompts
maas login myprofile http://maas.example.com:5240/MAAS/
# Login with API key
maas login myprofile http://maas.example.com:5240/MAAS/ consumer:token:secretRemove a profile:
maas logout <profile-name>maas profiles listmaas profiles switch <profile-name>maas profiles show <profile-name>maas <profile> machines listmaas <profile> machine <system-id>maas <profile> machine allocate [options]Options:
--hostname: Specific hostname--architecture: Architecture constraint--cpu-count: Minimum CPU count--mem: Minimum memory in MB--tags: Required tags--zone: Availability zoneExample:
maas prod machine allocate --cpu-count 4 --mem 8192 --tags ssdmaas <profile> machine deploy <system-id> [options]Options:
--distro-series: OS release (e.g., 'focal', 'jammy')--hwe-kernel: Hardware enablement kernelExample:
maas prod machine deploy abc123 --distro-series jammymaas <profile> machine release <system-id> [options]Options:
--comment: Release comment--erase: Securely erase disks# Power on
maas <profile> machine power-on <system-id>
# Power off
maas <profile> machine power-off <system-id> [--stop-mode soft|hard]
# Reboot
maas <profile> machine reboot <system-id># Lock machine
maas <profile> machine lock <system-id> [--comment "text"]
# Unlock machine
maas <profile> machine unlock <system-id>maas <profile> nodes listmaas <profile> devices listmaas <profile> controllers listmaas <profile> rack-controllers listmaas <profile> region-controllers listmaas <profile> fabrics listmaas <profile> vlans listmaas <profile> subnets listmaas <profile> spaces listmaas <profile> tags listmaas <profile> files listmaas <profile> users listStart an interactive Python shell with MAAS API access:
maas <profile> shellThis opens a Python REPL with pre-configured access to the MAAS API:
# Inside the shell
>>> machines = client.machines.list()
>>> for m in machines:
... print(m.hostname)Commands output data in various formats:
--format json where available)Most commands support:
--help: Show command help--format: Output format (table, json)--verbose: Verbose outputThe CLI entry point is defined in setup.py:
entry_points={
'console_scripts': [
'maas = maas.client.flesh:main'
]
}The CLI functionality can also be accessed programmatically:
from maas.client.flesh import main
import sys
# Call CLI with arguments
sys.argv = ['maas', 'myprofile', 'machines', 'list']
main(sys.argv[1:])For extending the CLI:
from maas.client.flesh import Command, TableCommand, OriginCommand
class Command:
"""Base command class."""
class TableCommand(Command):
"""Base command for table output."""
class OriginCommand(Command):
"""Base command requiring MAAS profile."""
class OriginTableCommand(OriginCommand, TableCommand):
"""Base table command requiring profile."""
class OriginPagedTableCommand(OriginTableCommand):
"""Base paged table command."""