Sunbeam MAAS network config - verify all 9 Juju spaces on any node

Quick script to confirm a Sunbeam node has all 9 Juju spaces configured in MAAS before commission/deploy.

Requires node’s system_id


What it checks

Juju space Match rule
oam bondm with IP + subnet
admin VLAN 3402
public VLAN 3404
ceph-access VLAN 3405
overlay VLAN 3407
internal VLAN 3403
ceph-replica VLAN 3406
tenant-storage VLAN 3408
provider VLAN 3409

Status meanings

Status Meaning
OK Space found — IP and subnet linked
NO-IP Interface exists on that VLAN, but no IP
NO-SUB IP present, subnet missing
MISSING No interface on that VLAN

Exit codes: 0 = PASS · 1 = PARTIAL · 2 = FAIL · 3 = MAAS CLI error


Script

Run on maas infra node

Change SYS to your node’s system_id

python3 <<'PY'

import subprocess, json, sys

SYS = "y77rtx"   # <-- change this

MAAS = "/snap/bin/maas"

SPACES = [

    ("oam", "bondm"),

    ("admin", 3402), ("public", 3404), ("ceph-access", 3405),

    ("overlay", 3407), ("internal", 3403), ("ceph-replica", 3406),

    ("tenant-storage", 3408), ("provider", 3409),

]

r = subprocess.run([MAAS, "admin", "interfaces", "read", SYS], capture_output=True, text=True)

if not r.stdout.strip().startswith("["):

    print("MAAS failed:", r.stdout[:300] or r.stderr[:300]); sys.exit(3)

ifaces = json.loads(r.stdout)

def vid(i): return (i.get("vlan") or {}).get("vid")

def link_of(i):

    for l in i.get("links", []):

        if l.get("ip_address"):

            s = l.get("subnet") or {}

            return l["ip_address"], s.get("cidr")

    return None, None

def find(rule):

    c = [i for i in ifaces if i.get("name") == "bondm"] if rule == "bondm" else [i for i in ifaces if vid(i) == rule]

    if not c: return None, None, None

    for i in c:

        ip, cidr = link_of(i)

        if ip and cidr: return i, ip, cidr

    return c[0], *link_of(c[0])

print(f"\nMAAS space check — {SYS}\n")

ok = warn = miss = 0

for space, rule in SPACES:

    iface, ip, cidr = find(rule)

    if not iface:

        miss += 1; print(f"  MISSING  {space}")

    elif ip and cidr:

        ok += 1; print(f"  OK       {space:<16} {iface['name']:<20} {ip} {cidr}")

    elif ip:

        warn += 1; print(f"  NO-SUB   {space:<16} {iface['name']:<20} {ip}")

    else:

        warn += 1; print(f"  NO-IP    {space:<16} {iface['name']}")

print(f"\n{ok} OK | {warn} warn | {miss} missing / 9")

if miss == 0 and warn == 0: print("PASS"); sys.exit(0)

if miss == 0: print("PARTIAL"); sys.exit(1)

print("FAIL"); sys.exit(2)

PY

echo "exit code: $?"

Example output

MAAS space check — pe7nh3

  OK       oam              bondm                10.21.2.21 10.21.2.0/24
  OK       admin            bondm.3402           10.21.3.21 10.21.3.0/24
  OK       public           bond1.3404           10.21.8.15 10.21.8.0/24
  OK       ceph-access      bond1.3405           10.21.4.25 10.21.4.0/24
  OK       overlay          bond1.3407           10.21.6.15 10.21.6.0/24
  OK       internal         br-bond2.3403        10.21.7.15 10.21.7.0/24
  OK       ceph-replica     br-bond2.3406        10.21.5.25 10.21.5.0/24
  OK       tenant-storage   bond1.3408           10.21.9.24 10.21.9.0/24
  OK       provider         br-bond2.3409        91.189.88.5 91.189.88.0/28

9 OK | 0 warn | 0 missing / 9
PASS

#canonical openstack #ubuntu