Files
harmony/opnsense-config/src/error.rs
Jean-Gabriel Gill-Couture c608975d30 feat(opnsense-config): replace XML backend with REST API
Replace opnsense-config-xml dependency with opnsense-api. All
configuration CRUD now goes through the OPNsense REST API instead
of SSH + XML editing of /conf/config.xml.

Key changes:
- Config struct holds OpnsenseClient + SSH shell (for file ops only)
- Module handlers (dnsmasq, haproxy, caddy, tftp, node_exporter) are
  now API-backed with async methods
- apply()/save() are no-ops — each module calls reconfigure after mutations
- install_package uses firmware API with polling
- LoadBalancer uses new domain types (LbFrontend, LbBackend, LbServer,
  LbHealthCheck) instead of XML types, with UUID chaining via API
- Dnsmasq conflict detection logic preserved, adapted for API HashMap
- RwLock<Config> replaced with Arc<Config> — Config is now stateless

Benefits over XML approach:
- Per-module soft reload instead of "reload all services"
- Server-side validation of all changes
- No more hash-based race condition detection
- No more fragile XML schema coupling

SSH retained for: file uploads, PXE config writing.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 19:35:40 -04:00

22 lines
606 B
Rust

use thiserror::Error;
#[derive(Error, Debug)]
pub enum Error {
#[error("API error: {0}")]
Api(#[from] opnsense_api::Error),
#[error("SSH error: {0}")]
Ssh(#[from] russh::Error),
#[error("SSH Client error: {0}")]
SftpClient(#[from] russh_sftp::client::error::Error),
#[error("Command failed: {0}")]
Command(String),
#[error("I/O error: {0}")]
Io(#[from] std::io::Error),
#[error("Config error: {0}")]
Config(String),
#[error("Unexpected error: {0}")]
Unexpected(String),
#[error("Package installation failed: {0}")]
PackageInstall(String),
}