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.

network.mddocs/reference/

Network Management

Comprehensive network configuration including fabrics, VLANs, subnets, spaces, IP ranges, static routes, and interface management.

Capabilities

Fabrics

Network fabrics represent physical network groupings.

client.fabrics.list()
client.fabrics.get(id)
client.fabrics.get_default()
client.fabrics.create(name=None, description=None, class_type=None)
fabric.save()
fabric.delete()
from maas.client import connect

client = connect('http://maas.example.com:5240/MAAS/', apikey='key')

# List fabrics
fabrics = client.fabrics.list()

# Get specific fabric
fabric = client.fabrics.get(0)

# Get default fabric
default_fabric = client.fabrics.get_default()

# Create fabric
new_fabric = client.fabrics.create(
    name='fabric-1',
    description='Production network fabric',
    class_type='10g'
)

# Update fabric
fabric.name = 'updated-fabric'
await fabric.save()

# Delete fabric
await fabric.delete()

Fabric properties:

  • id (int, readonly): Unique fabric identifier
  • name (str): Fabric name
  • class_type (str): Network class type (e.g., '10g', '1g')
  • vlans (Vlans): Collection of VLANs in this fabric

VLANs

VLANs segment network traffic within fabrics.

# VLANs are accessed via fabric objects
fabric.vlans.list()
fabric.vlans.get(vid)
fabric.vlans.create(vid, name=None, description=None, mtu=1500, dhcp_on=False, primary_rack=None, secondary_rack=None, relay_vlan=None, space=None)
Vlan.read(fabric, vid)
vlan.save()
vlan.delete()
# Access VLANs through fabric
fabric = client.fabrics.get(0)
vlans = fabric.vlans.list()

# Get specific VLAN by VID
vlan = fabric.vlans.get(100)

# Or use Vlan.read()
from maas.client.viscera import Vlan
vlan = await Vlan.read(fabric, 100)

# Create VLAN
vlan = await fabric.vlans.create(
    vid=100,
    name='Production',
    description='Production VLAN',
    mtu=1500,
    dhcp_on=True,
    space='dmz'
)

# Update VLAN
vlan.name = 'Production-Updated'
vlan.mtu = 9000
await vlan.save()

# Delete VLAN
await vlan.delete()

VLAN properties:

  • id (int, readonly): Unique VLAN identifier
  • fabric (Fabric): Parent fabric
  • vid (int): VLAN ID (0-4094)
  • name (str): VLAN name
  • mtu (int): Maximum transmission unit
  • space (Space): Associated space
  • relay_vlan (Vlan): DHCP relay VLAN
  • dhcp_on (bool): DHCP enabled
  • primary_rack (RackController): Primary rack controller for DHCP
  • secondary_rack (RackController): Secondary rack controller for DHCP
  • external_dhcp (str, readonly): External DHCP server IP

Subnets

Subnets define IP address ranges and network configuration.

client.subnets.list()
client.subnets.get(id)
Subnet.read(id)
client.subnets.create(cidr, name=None, description=None, vlan=None, fabric=None, gateway_ip=None, dns_servers=None, rdns_mode=None, allow_proxy=None, active_discovery=None, managed=True)
subnet.save()
subnet.delete()
from maas.client.enum import RDNSMode

# List subnets
subnets = client.subnets.list()

# Get specific subnet
subnet = client.subnets.get(1)

# Create subnet
subnet = await client.subnets.create(
    cidr='192.168.100.0/24',
    name='Production Subnet',
    description='Main production network',
    vlan=100,
    fabric=0,
    gateway_ip='192.168.100.1',
    dns_servers=['8.8.8.8', '8.8.4.4'],
    rdns_mode=RDNSMode.ENABLED,
    allow_proxy=True,
    active_discovery=True,
    managed=True
)

# Update subnet
subnet.name = 'Production-Primary'
subnet.gateway_ip = '192.168.100.254'
await subnet.save()

# Delete subnet
await subnet.delete()

Subnet properties:

  • id (int, readonly): Subnet ID
  • cidr (str, readonly): CIDR notation
  • name (str): Subnet name
  • gateway_ip (str): Gateway IP address
  • dns_servers (list): List of DNS server IPs
  • vlan (Vlan): Associated VLAN
  • space (str): Space name
  • rdns_mode (RDNSMode): Reverse DNS mode
  • active_discovery (bool): Enable active subnet discovery
  • allow_proxy (bool): Allow proxy access
  • managed (bool): Whether MAAS manages this subnet

Spaces

Spaces provide logical network grouping for access control.

client.spaces.list()
client.spaces.get(id)
client.spaces.get_default()
Space.read(id)
client.spaces.create(name=None, description=None)
space.delete()
# List spaces
spaces = client.spaces.list()

# Get specific space
space = client.spaces.get(1)

# Get default space
default_space = client.spaces.get_default()

# Create space
space = await client.spaces.create(
    name='dmz',
    description='DMZ network space'
)

# Delete space
await space.delete()

Space properties:

  • id (int, readonly): Unique space identifier
  • name (str, readonly): Space name
  • description (str, readonly): Space description
  • vlans (Vlans, readonly): VLANs associated with this space

IP Ranges

Manage dynamic and reserved IP address ranges.

client.ip_ranges.list()
client.ip_ranges.get(id)
IPRange.read(id)
client.ip_ranges.create(start_ip, end_ip, type=IPRangeType.RESERVED, comment=None, subnet=None)
ip_range.save()
ip_range.delete()
from maas.client.enum import IPRangeType

# List IP ranges
ip_ranges = client.ip_ranges.list()

# Get specific IP range
ip_range = client.ip_ranges.get(1)

# Create dynamic range for DHCP
ip_range = await client.ip_ranges.create(
    start_ip='192.168.1.100',
    end_ip='192.168.1.200',
    type=IPRangeType.DYNAMIC,
    subnet=1,
    comment='DHCP pool'
)

# Create reserved range
reserved = await client.ip_ranges.create(
    start_ip='192.168.1.10',
    end_ip='192.168.1.50',
    type=IPRangeType.RESERVED,
    subnet=1,
    comment='Infrastructure IPs'
)

# Update IP range
ip_range.start_ip = '192.168.1.105'
ip_range.end_ip = '192.168.1.205'
ip_range.comment = 'Updated DHCP pool'
await ip_range.save()

# Delete IP range
await ip_range.delete()

IP Range properties:

  • id (int, readonly): Unique IP range identifier
  • start_ip (str): Starting IP address
  • end_ip (str): Ending IP address
  • type (IPRangeType, readonly): Range type (DYNAMIC or RESERVED)
  • comment (str): Range comment/description
  • subnet (Subnet, readonly): Associated subnet

Static Routes

Configure static network routes.

client.static_routes.list()
client.static_routes.get(id)
client.static_routes.create(**params)

Parameters:

  • source (int): Source subnet ID
  • destination (int): Destination subnet ID
  • gateway_ip (str): Gateway IP address
  • metric (int, optional): Route metric
# Create static route
route = client.static_routes.create(
    source=1,
    destination=2,
    gateway_ip='192.168.1.254',
    metric=10
)

# List routes
routes = client.static_routes.list()

# Delete route
route.delete()

Network Interfaces

Machine and device network interfaces are now documented separately. See Network Interface Management for complete documentation on:

  • Creating and managing interfaces (physical, bond, bridge, VLAN)
  • Configuring IP addresses through interface links
  • Link modes (AUTO, DHCP, STATIC, LINK_UP)
  • Interface properties and operations

Types

from maas.client.enum import IPRangeType, InterfaceType, LinkMode, RDNSMode

class IPRangeType:
    """IP range type enumeration."""
    DYNAMIC = ...  # Dynamic DHCP range
    RESERVED = ...  # Reserved range

class InterfaceType:
    """Network interface type enumeration."""
    PHYSICAL = ...
    BOND = ...
    BRIDGE = ...
    VLAN = ...
    UNKNOWN = ...

class LinkMode:
    """Interface link mode enumeration."""
    AUTO = ...      # Automatic configuration
    DHCP = ...      # DHCP configuration
    STATIC = ...    # Static IP configuration
    LINK_UP = ...   # Link up only

class RDNSMode:
    """Reverse DNS mode enumeration."""
    DISABLED = ...
    ENABLED = ...
    RFC2317 = ...