mirror of
https://github.com/CloudNebulaProject/zmgr.git
synced 2026-04-10 13:10:42 +00:00
Refresh architecture, implementation-state, and gap-analysis docs to reflect all DX changes: validate, completions, JSON output, boot/halt, auto-width tables, confirmation flow, progress output, and partial failure handling. Move resolved gaps to the Resolved section. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
3.3 KiB
3.3 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, table formatting
config.rs Global config (/etc/zmgr/config.kdl)
template.rs Zone templates (/etc/zmgr/templates/*.kdl) — multi-net
pool.rs IPAM pools (/etc/zmgr/pools/*.kdl) — range + list modes
zone.rs Zone registry (/etc/zmgr/zones/*.kdl) — multi-net
publisher.rs IPS publishers (/etc/zmgr/publishers/*.kdl)
exec.rs System command wrappers (zonecfg, zoneadm, dladm)
import.rs Import existing zones into registry
validate.rs Config validation (syntax, integrity, pool sanity)
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, net blocks (each references a pool)
- For each net: load pool -> allocate next free IP from pool
- Build zonecfg commands with one
add netblock per network - Step-by-step execution with progress:
- Create VNICs via
dladm create-vnic - Configure zone via
zonecfg -z <name> - Install zone via
zoneadm -z <name> install - Write zone registry entry (KDL file)
- If autoboot,
zoneadm boot
- Create VNICs via
- On partial failure: print what succeeded + cleanup commands
Zone Destruction (zmgr destroy <name>)
- Load zone from registry
- Require confirmation (type zone name, or
--yes) - Step-by-step teardown with progress:
- Halt zone
- Uninstall zone
- Delete zone configuration
- Delete VNICs (one per net)
- Remove registry entry
Zone Import (zmgr import)
zoneadm list -cp-> get system zones- Filter out already-registered and bhyve zones
zonecfg -z <name> info-> extract config (multiple nets)- Match brand -> template, IP -> pool, net names -> template net names
- Write zone registry entry with current date
Validation (zmgr validate)
- Parse all KDL files (config, templates, pools, zones)
- Check referential integrity (template -> pool, config -> template)
- Check pool sanity (gateway in network, range in network)
- Check for duplicate IPs across zones
- Warn on high pool utilization (>90%)
Output Modes
- Human (default): auto-sized tables, key-value detail views
- JSON (
--json): structured output for scripting - Dry-run (
-n): shows commands without executing
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 <- 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
└── validate.rs <- config.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.