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.
Manage MAAS rack and region controllers that provide infrastructure services like DHCP, DNS, power control, and image management.
Important: Controllers are MAAS infrastructure components and cannot be created via the API. They must be deployed and registered through MAAS installation processes. The API provides read-only access to controller information and status.
Rack controllers provide services like DHCP, TFTP, PXE boot, and power management to physical machines in the data center.
Rack Controller Roles:
client.rack_controllers.list()
client.rack_controllers.get(system_id)
RackController.read(system_id)from maas.client import connect
client = connect('http://maas.example.com:5240/MAAS/', apikey='key')
# List all rack controllers
rack_controllers = client.rack_controllers.list()
for rc in rack_controllers:
print(f"Rack: {rc.hostname}")
print(f" Status: {rc.status}")
print(f" FQDN: {rc.fqdn}")
print(f" Zone: {rc.zone.name}")
# Get specific rack controller
rack = client.rack_controllers.get('system_id')
# Or use RackController.read()
from maas.client.viscera import RackController
rack = await RackController.read('system_id')Region controllers provide the web UI, REST API, and coordinate rack controllers. They are the "brain" of MAAS.
Region Controller Roles:
client.region_controllers.list()
client.region_controllers.get(system_id)
RegionController.read(system_id)# List all region controllers
region_controllers = client.region_controllers.list()
for rc in region_controllers:
print(f"Region: {rc.hostname}")
print(f" Version: {rc.version if hasattr(rc, 'version') else 'N/A'}")
print(f" Power State: {rc.power_state}")
# Get specific region controller
region = client.region_controllers.get('system_id')
# Or use RegionController.read()
from maas.client.viscera import RegionController
region = await RegionController.read('system_id')A single MAAS node can function as both a region and rack controller (common in small deployments).
Controllers inherit from Node and have these key properties:
system_id (str, readonly): Unique system identifierhostname (str): Controller hostnamefqdn (str, readonly): Fully qualified domain namestatus (NodeStatus, readonly): Current status (typically DEPLOYED for active controllers)architecture (str): System architecture (e.g., 'amd64/generic')cpus (int): Number of CPU coresmemory (int): RAM in megabytesdistro_series (str, readonly): Ubuntu release (e.g., 'jammy', 'focal')osystem (str, readonly): Operating system (typically 'ubuntu')power_state (PowerState, readonly): Power state (ON, OFF, UNKNOWN, ERROR)interface_set (list, readonly): Network interfaceszone (Zone, readonly): Availability zoneservice_set (list, readonly): Services running on controller (rack controllers only)controller.refresh()# Refresh controller data from server
controller.refresh()
print(f"Updated status: {controller.status}")Convert generic Node objects to controller types.
node.as_rack_controller()
node.as_region_controller()When working with nodes from generic listings, convert them to specific controller types:
from maas.client.viscera import Nodes
from maas.client.enum import NodeType
# List all nodes
nodes = Nodes.read()
for node in nodes:
# Convert to controller types
if node.node_type == NodeType.RACK_CONTROLLER:
rack = node.as_rack_controller()
print(f"Rack Controller: {rack.hostname}")
# Access rack-specific properties
if hasattr(rack, 'service_set'):
print(f" Services: {[s.name for s in rack.service_set]}")
elif node.node_type == NodeType.REGION_CONTROLLER:
region = node.as_region_controller()
print(f"Region Controller: {region.hostname}")
elif node.node_type == NodeType.REGION_AND_RACK_CONTROLLER:
# Can convert to either type
rack = node.as_rack_controller()
region = node.as_region_controller()
print(f"Combined Controller: {rack.hostname}")Single-Node Setup:
Multi-Node Setup: