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.
Type-safe enumerations for node states, power states, interface types, storage configurations, and other MAAS concepts.
Machine and device lifecycle states.
from maas.client.enum import NodeStatus
class NodeStatus:
"""Node status enumeration."""
DEFAULT = ... # Default (alias for NEW)
NEW = ... # Newly enlisted
COMMISSIONING = ... # Commissioning in progress
FAILED_COMMISSIONING = ... # Commissioning failed
MISSING = ... # Node cannot be contacted
READY = ... # Ready for allocation
RESERVED = ... # Reserved for named deployment
ALLOCATED = ... # Allocated to user
DEPLOYING = ... # Deployment in progress
DEPLOYED = ... # Successfully deployed
RETIRED = ... # Retired from service
BROKEN = ... # Marked as broken
FAILED_DEPLOYMENT = ... # Deployment failed
RELEASING = ... # Release in progress
FAILED_RELEASING = ... # Release failed
DISK_ERASING = ... # Disk erase in progress
FAILED_DISK_ERASING = ... # Disk erase failed
RESCUE_MODE = ... # In rescue mode
ENTERING_RESCUE_MODE = ... # Entering rescue mode
FAILED_ENTERING_RESCUE_MODE = ... # Failed to enter rescue mode
EXITING_RESCUE_MODE = ... # Exiting rescue mode
FAILED_EXITING_RESCUE_MODE = ... # Failed to exit rescue mode
TESTING = ... # Testing in progress
FAILED_TESTING = ... # Testing failedUsage:
from maas.client import connect
from maas.client.enum import NodeStatus
client = connect('http://maas.example.com:5240/MAAS/', apikey='key')
# Check machine status
machine = client.machines.get('system_id')
if machine.status == NodeStatus.READY:
print("Machine is ready for allocation")
elif machine.status == NodeStatus.DEPLOYED:
print("Machine is deployed")Type of node in MAAS.
from maas.client.enum import NodeType
class NodeType:
"""Node type enumeration."""
MACHINE = ... # Deployable machine
DEVICE = ... # Non-deployable device
RACK_CONTROLLER = ... # Rack controller
REGION_CONTROLLER = ... # Region controller
REGION_AND_RACK_CONTROLLER = ... # Combined controllerMachine power states.
from maas.client.enum import PowerState
class PowerState:
"""Power state enumeration."""
ON = ... # Powered on
OFF = ... # Powered off
UNKNOWN = ... # Power state unknown
ERROR = ... # Power query errorUsage:
from maas.client.enum import PowerState
# Query power state
state = machine.query_power_state()
if state == PowerState.ON:
print("Machine is powered on")
elif state == PowerState.OFF:
print("Machine is powered off")How to power off machines.
from maas.client.enum import PowerStopMode
class PowerStopMode:
"""Power stop mode enumeration."""
SOFT = ... # Graceful shutdown (ACPI)
HARD = ... # Immediate power offUsage:
from maas.client.enum import PowerStopMode
# Graceful shutdown
machine.power_off(stop_mode=PowerStopMode.SOFT)
# Immediate power off
machine.power_off(stop_mode=PowerStopMode.HARD)Reverse DNS configuration for subnets.
from maas.client.enum import RDNSMode
class RDNSMode:
"""Reverse DNS mode enumeration."""
DISABLED = ... # Disabled
ENABLED = ... # Enabled (standard)
RFC2317 = ... # RFC2317 classless delegationType of IP address range.
from maas.client.enum import IPRangeType
class IPRangeType:
"""IP range type enumeration."""
DYNAMIC = ... # Dynamic DHCP range
RESERVED = ... # Reserved range (not for DHCP)Usage:
from maas.client.enum import IPRangeType
# Create dynamic range
ip_range = client.ip_ranges.create(
type=IPRangeType.DYNAMIC,
start_ip='192.168.1.100',
end_ip='192.168.1.200',
subnet=1
)Network interface types.
from maas.client.enum import InterfaceType
class InterfaceType:
"""Network interface type enumeration."""
PHYSICAL = ... # Physical network interface
BOND = ... # Bonded interface
BRIDGE = ... # Bridge interface
VLAN = ... # VLAN interface
UNKNOWN = ... # Unknown typeUsage:
from maas.client.enum import InterfaceType
# Check interface type
for iface in machine.interface_set:
if iface.type == InterfaceType.PHYSICAL:
print(f"Physical interface: {iface.name}")
elif iface.type == InterfaceType.BOND:
print(f"Bond interface: {iface.name}")Interface link configuration mode.
from maas.client.enum import LinkMode
class LinkMode:
"""Interface link mode enumeration."""
AUTO = ... # Automatic configuration
DHCP = ... # DHCP configuration
STATIC = ... # Static IP configuration
LINK_UP = ... # Link up only (no IP)Storage device types.
from maas.client.enum import BlockDeviceType
class BlockDeviceType:
"""Block device type enumeration."""
PHYSICAL = ... # Physical disk
VIRTUAL = ... # Virtual diskPartition table formats.
from maas.client.enum import PartitionTableType
class PartitionTableType:
"""Partition table type enumeration."""
MBR = ... # Master Boot Record
GPT = ... # GUID Partition TableRAID configuration levels.
from maas.client.enum import RaidLevel
class RaidLevel:
"""RAID level enumeration."""
RAID_0 = ... # RAID 0 (striping)
RAID_1 = ... # RAID 1 (mirroring)
RAID_5 = ... # RAID 5 (striping with parity)
RAID_6 = ... # RAID 6 (striping with double parity)
RAID_10 = ... # RAID 10 (mirrored stripes)Bcache caching modes.
from maas.client.enum import CacheMode
class CacheMode:
"""Cache mode enumeration for bcache."""
WRITEBACK = ... # Write to cache first
WRITETHROUGH = ... # Write to cache and backing device
WRITEAROUND = ... # Write to backing device onlyEvent severity levels for system events and logging.
from maas.client.viscera.events import Level
class Level:
"""Event level enumeration (IntEnum)."""
AUDIT = 0 # Audit events (user actions)
DEBUG = 10 # Debug information
INFO = 20 # Informational messages
WARNING = 30 # Warning messages
ERROR = 40 # Error messages
CRITICAL = 50 # Critical errorsUsage:
from maas.client.viscera.events import Level
# Filter events by level
events = client.events.query(level=Level.ERROR)
critical_events = client.events.query(level=Level.CRITICAL)
# Can also use as string or int
events = client.events.query(level='WARNING')
events = client.events.query(level=30)
# Access via client.events.Level
events = client.events.query(level=client.events.Level.INFO)Note: The Level enum corresponds to Python's logging module levels, making it intuitive for developers familiar with standard Python logging.
DNSSEC validation configuration for DNS resolution.
from maas.client.viscera.maas import MAAS
class MAAS:
class DNSSEC:
"""DNSSEC validation mode enumeration."""
AUTO = ... # Automatic based on upstream DNS
YES = ... # Enable DNSSEC validation
NO = ... # Disable DNSSEC validationUsage:
from maas.client import connect
from maas.client.viscera.maas import MAAS
client = connect('http://maas.example.com:5240/MAAS/', apikey='key')
# Set DNSSEC validation
client.maas.set_dnssec_validation(MAAS.DNSSEC.YES)
# Get current setting
validation = client.maas.get_dnssec_validation()
if validation == MAAS.DNSSEC.AUTO:
print("DNSSEC validation is automatic")Default storage layout for machine deployment.
from maas.client.viscera.maas import MAAS
class MAAS:
class StorageLayout:
"""Default storage layout enumeration."""
FLAT = ... # Simple flat partitioning (default)
LVM = ... # LVM-based partitioning
BCACHE = ... # Bcache with SSD cachingUsage:
from maas.client import connect
from maas.client.viscera.maas import MAAS
client = connect('http://maas.example.com:5240/MAAS/', apikey='key')
# Set default storage layout for all deployments
client.maas.set_default_storage_layout(MAAS.StorageLayout.LVM)
# Get current default
layout = client.maas.get_default_storage_layout()
if layout == MAAS.StorageLayout.FLAT:
print("Using flat storage layout")
elif layout == MAAS.StorageLayout.LVM:
print("Using LVM storage layout")
elif layout == MAAS.StorageLayout.BCACHE:
print("Using Bcache storage layout")# Import specific enums
from maas.client.enum import NodeStatus, PowerState, InterfaceType
from maas.client.viscera.events import Level
from maas.client.viscera.maas import MAAS
# Import all enums from maas.client.enum
from maas.client import enum
# Access MAAS nested enums
print(MAAS.DNSSEC.AUTO)
print(MAAS.StorageLayout.LVM)