or run

tessl search
Log in

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/python-libmaas@0.6.x

docs

index.md
tile.json

tessl/pypi-python-libmaas

tessl install tessl/pypi-python-libmaas@0.6.0

Python client library for MAAS 2.0+ with sync/async support, providing machine provisioning, network management, and storage configuration.

devices.mddocs/reference/

Device Management

Manage non-deployable devices like network switches, routers, and other infrastructure components that MAAS should track but not control for deployment.

Overview

What is a Device?

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.

Device vs Machine Differences

FeatureDeviceMachine
DeployableNoYes
Power ControlNoYes (via BMC/IPMI)
OS InstallationNoYes
CommissioningNoYes
Network TrackingYesYes
IP Address ManagementYesYes
Typical Use CasesSwitches, routers, PDUs, BMCs, printersServers, compute nodes

Common Device Use Cases

Devices are ideal for:

  • Network Infrastructure: Switches, routers, firewalls that need IP addresses tracked
  • Power Distribution Units (PDUs): Power management hardware
  • Baseboard Management Controllers (BMCs): Out-of-band management interfaces
  • Network Printers: Printers that need static IP assignments
  • IoT Devices: Sensors or monitoring equipment
  • Existing Servers: Machines not managed by MAAS but part of the network

Parent Relationship

Devices can have a parent node, typically used when a device is a child component of a machine:

  • A BMC device can be a child of the physical server it manages
  • A device can represent a network port or interface on a parent machine
  • The parent relationship helps organize infrastructure hierarchy

Capabilities

Listing Devices

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}")

Getting Specific Device

client.devices.get(system_id)
device = client.devices.get('abc123')
print(f"Device: {device.hostname}")

Creating Devices

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 device
  • hostname (str, optional): Device hostname (auto-generated if not specified)
  • domain (int | str, optional): DNS domain ID or name
  • zone (Zone | str, optional): Availability zone object or name
  • parent (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']
)

Updating Devices

Modify device properties.

device.save()
device.refresh()
# Update device hostname
device.hostname = 'new-switch-name'
device.save()

# Refresh from server
device.refresh()

Deleting Devices

Remove devices from MAAS.

device.delete()
# Delete device
device.delete()

Node Type Conversion

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}")

Device Properties

  • system_id (str): Unique system identifier
  • hostname (str): Device hostname
  • fqdn (str): Fully qualified domain name
  • domain (Domain): DNS domain
  • ip_addresses (list): List of IP addresses
  • mac_addresses (list): List of MAC addresses
  • parent (str): Parent node system ID
  • zone (Zone): Availability zone
  • interface_set (list): Network interfaces