mirror of
https://github.com/CloudNebulaProject/zmgr.git
synced 2026-04-10 13:10:42 +00:00
Rust CLI that creates/destroys/imports illumos zones from KDL template configs with automatic IP allocation from named pools. Registry lives under /etc/zmgr as flat KDL files — zone entries double as the IPAM ledger. Includes default templates for ipkg (OI) and nlipkg (OFL) brands, matching the existing shell scripts. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2.2 KiB
2.2 KiB
Architecture
Overview
zmgr is a single Rust binary that manages illumos zones via flat KDL config files under /etc/zmgr. No daemon, no database — just a CLI that reads configs, calls system commands (zonecfg, zoneadm, dladm), and writes registry entries.
Module Layout
src/
main.rs CLI entry point (clap), command dispatch
config.rs Global config (/etc/zmgr/config.kdl)
template.rs Zone templates (/etc/zmgr/templates/*.kdl)
pool.rs IPAM pools (/etc/zmgr/pools/*.kdl)
zone.rs Zone registry (/etc/zmgr/zones/*.kdl)
publisher.rs IPS publishers (/etc/zmgr/publishers/*.kdl)
exec.rs System command wrappers (zonecfg, zoneadm, dladm)
import.rs Import existing zones into registry
kdl_util.rs KDL document parsing helpers
error.rs Error types (miette diagnostics)
Data Flow
Zone Creation (zmgr create <name>)
- Load global config → get default template name
- Load template → get brand, autoboot, pool reference
- Load pool → get network, gateway, stub, IP range
- Scan zone registry → find allocated IPs
- Allocate next free IP from pool range
dladm create-vnic→ create VNIC on stubzonecfg -z <name>→ pipe zone configurationzoneadm -z <name> install→ install zone- Write zone registry entry (KDL file)
- If autoboot,
zoneadm boot
Zone Import (zmgr import)
zoneadm list -cp→ get system zones- Filter out already-registered and bhyve zones
zonecfg -z <name> info→ extract config- Match brand → template, IP → pool
- Write zone registry entry
Dependency Graph
main.rs
├── config.rs ← kdl_util.rs, error.rs
├── template.rs ← kdl_util.rs, error.rs
├── pool.rs ← kdl_util.rs, error.rs, zone.rs
├── zone.rs ← kdl_util.rs, error.rs
├── publisher.rs ← kdl_util.rs, error.rs
├── exec.rs ← error.rs
└── import.rs ← exec.rs, pool.rs, template.rs, zone.rs
Boundary with vm-manager
zmgr manages zone brands (ipkg, nlipkg, etc.) — native illumos zones. vm-manager manages bhyve brand zones — virtual machines. Import logic skips bhyve zones to avoid overlap.