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.

raids.mddocs/reference/

Software RAID Configuration

Configure and manage software RAID arrays on MAAS machines for redundancy and performance.

Capabilities

Listing RAID Arrays

Retrieve all RAID arrays configured on a machine.

# Via Machine object
machine.raids
from maas.client import connect

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

# Get a machine
machine = client.machines.get('abc123')

# List all RAID arrays
raids = machine.raids
for raid in raids:
    print(f"{raid.name}: RAID {raid.level} - {raid.size} bytes")

# Access by name
md0 = machine.raids.by_name['md0']

Getting Specific RAID

Retrieve a single RAID array by ID or name.

Raid.read(node, id)
machine.raids.get_by_name(name)
# Get RAID by ID
raid = await Raid.read(machine, 5)

# Get RAID by name
md0 = machine.raids.get_by_name('md0')

Creating RAID Arrays

Create a new software RAID array from block devices or partitions.

Raids.create(
    node,
    level,
    devices,
    name=None,
    uuid=None,
    spare_devices=None
)
from maas.client.enum import RaidLevel

# Get block devices
sdb = machine.block_devices.get_by_name('sdb')
sdc = machine.block_devices.get_by_name('sdc')

# Create RAID 1 (mirror) array
raid1 = await machine.raids.create(
    machine,
    RaidLevel.RAID_1,
    devices=[sdb, sdc],
    name='md0'
)

# Create RAID 0 (stripe) array with partitions
sdd = machine.block_devices.get_by_name('sdd')
sde = machine.block_devices.get_by_name('sde')

# Create partitions first
partition1 = await sdd.partitions.create(sdd, size=sdd.available_size)
partition2 = await sde.partitions.create(sde, size=sde.available_size)

raid0 = await machine.raids.create(
    machine,
    RaidLevel.RAID_0,
    devices=[partition1, partition2],
    name='md1'
)

# Create RAID 5 with spare devices
sdf = machine.block_devices.get_by_name('sdf')
sdg = machine.block_devices.get_by_name('sdg')
sdh = machine.block_devices.get_by_name('sdh')
sdi = machine.block_devices.get_by_name('sdi')

raid5 = await machine.raids.create(
    machine,
    RaidLevel.RAID_5,
    devices=[sdf, sdg, sdh],
    spare_devices=[sdi],
    name='md2'
)

Updating RAID Properties

Modify RAID array attributes and save changes.

raid.save()
# Update RAID properties
md0 = machine.raids.get_by_name('md0')
md0.name = 'raid-storage'
md0.uuid = 'new-uuid-value'

# Save changes
await md0.save()

Deleting RAID Arrays

Remove a RAID array from a machine.

raid.delete()
# Delete RAID array
md0 = machine.raids.get_by_name('md0')
await md0.delete()

Formatting RAID Arrays

Once created, RAID arrays can be formatted and mounted like block devices.

# Create RAID array
raid = await machine.raids.create(
    machine,
    RaidLevel.RAID_1,
    devices=[sdb, sdc],
    name='md0'
)

# Format the RAID array
virtual_device = raid.virtual_device
await virtual_device.format('ext4')
await virtual_device.mount('/data')

RAID Levels

MAAS supports the following RAID levels:

RAID 0 (Striping)

Stripes data across multiple disks for improved performance. No redundancy.

  • Minimum devices: 2
  • Capacity: Sum of all devices
  • Use case: High performance, non-critical data
raid0 = await machine.raids.create(
    machine,
    RaidLevel.RAID_0,
    devices=[sdb, sdc]
)

RAID 1 (Mirroring)

Mirrors data across multiple disks for redundancy.

  • Minimum devices: 2
  • Capacity: Size of smallest device
  • Use case: High availability, critical data
raid1 = await machine.raids.create(
    machine,
    RaidLevel.RAID_1,
    devices=[sdb, sdc]
)

RAID 5 (Striping with Parity)

Stripes data with distributed parity for performance and redundancy.

  • Minimum devices: 3
  • Capacity: (N-1) × smallest device size
  • Use case: Balanced performance and redundancy
raid5 = await machine.raids.create(
    machine,
    RaidLevel.RAID_5,
    devices=[sdb, sdc, sdd]
)

RAID 6 (Striping with Double Parity)

Stripes data with double parity, can tolerate two disk failures.

  • Minimum devices: 4
  • Capacity: (N-2) × smallest device size
  • Use case: High availability with multiple failure tolerance
raid6 = await machine.raids.create(
    machine,
    RaidLevel.RAID_6,
    devices=[sdb, sdc, sdd, sde]
)

RAID 10 (Mirrored Stripes)

Combines mirroring and striping for both performance and redundancy.

  • Minimum devices: 4
  • Capacity: (N/2) × smallest device size
  • Use case: High performance with redundancy
raid10 = await machine.raids.create(
    machine,
    RaidLevel.RAID_10,
    devices=[sdb, sdc, sdd, sde]
)

Complete RAID Example

from maas.client import connect
from maas.client.enum import RaidLevel

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

# Get block devices for RAID
sdb = machine.block_devices.get_by_name('sdb')
sdc = machine.block_devices.get_by_name('sdc')
sdd = machine.block_devices.get_by_name('sdd')
sde = machine.block_devices.get_by_name('sde')  # spare

# Create RAID 5 array with spare
raid5 = await machine.raids.create(
    machine,
    RaidLevel.RAID_5,
    devices=[sdb, sdc, sdd],
    spare_devices=[sde],
    name='storage-raid'
)

# Format and mount the RAID array
virtual_device = raid5.virtual_device
await virtual_device.format('xfs')
await virtual_device.mount('/storage')

print(f"Created {raid5.name} with {raid5.level}")
print(f"Total capacity: {raid5.size} bytes")
print(f"Mounted at: {virtual_device.filesystem.mount_point}")

RAID Properties

RAID arrays have the following properties:

  • id (int, readonly): Unique RAID identifier
  • node (Node, readonly): Parent machine
  • name (str): RAID array name (e.g., 'md0')
  • level (RaidLevel, readonly): RAID level
  • size (int, readonly): Total RAID capacity in bytes
  • uuid (str): RAID UUID
  • devices (list): Active devices in the array
  • spare_devices (list): Spare devices
  • virtual_device (BlockDevice, readonly): Virtual block device representing the array

Types

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

Related Documentation

  • Block Device Management - Manage storage devices
  • Partition Management - Create partitions for RAID
  • LVM Volume Groups - Logical Volume Management
  • Bcache Configuration - SSD caching for block devices