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 non-deployable devices like network switches, routers, and other infrastructure components that MAAS should track but not control for deployment.
A Device in MAAS is a non-deployable network-connected component that MAAS tracks for network management purposes. Unlike machines, devices cannot be allocated, commissioned, or deployed with operating systems.
| Feature | Device | Machine |
|---|---|---|
| Deployable | No | Yes |
| Power Control | No | Yes (via BMC/IPMI) |
| OS Installation | No | Yes |
| Commissioning | No | Yes |
| Network Tracking | Yes | Yes |
| IP Address Management | Yes | Yes |
| Typical Use Cases | Switches, routers, PDUs, BMCs, printers | Servers, compute nodes |
Devices are ideal for:
Devices can have a parent node, typically used when a device is a child component of a machine:
client.devices.list()from maas.client import connect
client = connect('http://maas.example.com:5240/MAAS/', apikey='key')
devices = client.devices.list()
for device in devices:
print(f"{device.hostname}: {device.system_id}")client.devices.get(system_id)device = client.devices.get('abc123')
print(f"Device: {device.hostname}")Register new devices with MAAS for tracking purposes.
client.devices.create(**params)
Devices.create(mac_addresses, hostname=None, domain=None, zone=None)Parameters:
mac_addresses (list[str], required): MAC address(es) of the devicehostname (str, optional): Device hostname (auto-generated if not specified)domain (int | str, optional): DNS domain ID or namezone (Zone | str, optional): Availability zone object or nameparent (str, optional): Parent node system ID (for child devices like BMCs)from maas.client import connect
client = connect('http://maas.example.com:5240/MAAS/', apikey='key')
# Create basic device (minimal parameters)
device = client.devices.create(
mac_addresses=['00:11:22:33:44:55']
)
# Create device with hostname and domain
device = client.devices.create(
hostname='switch1',
mac_addresses=['00:11:22:33:44:55'],
domain='maas.local'
)
# Create device in specific zone
device = client.devices.create(
hostname='router1',
mac_addresses=['aa:bb:cc:dd:ee:ff'],
zone='datacenter-1'
)
# Create device with parent node (e.g., BMC as child of server)
device = client.devices.create(
hostname='server1-bmc',
mac_addresses=['11:22:33:44:55:66'],
parent='abc123' # system_id of parent machine
)
# Create device with multiple MAC addresses
device = client.devices.create(
hostname='switch-core',
mac_addresses=['00:11:22:33:44:55', '00:11:22:33:44:56']
)Modify device properties.
device.save()
device.refresh()# Update device hostname
device.hostname = 'new-switch-name'
device.save()
# Refresh from server
device.refresh()Remove devices from MAAS.
device.delete()# Delete device
device.delete()Convert generic Node objects to Device type.
node.as_device()When working with nodes from generic listings, convert them to Device type:
from maas.client.viscera import Nodes
from maas.client.enum import NodeType
# List all nodes
nodes = Nodes.read()
for node in nodes:
if node.node_type == NodeType.DEVICE:
device = node.as_device()
print(f"Device: {device.hostname}")
print(f" Parent: {device.parent}")system_id (str): Unique system identifierhostname (str): Device hostnamefqdn (str): Fully qualified domain namedomain (Domain): DNS domainip_addresses (list): List of IP addressesmac_addresses (list): List of MAC addressesparent (str): Parent node system IDzone (Zone): Availability zoneinterface_set (list): Network interfaces