ProvisionOpnsenseVm

Provisions an OPNsense VM on a Proxmox host from a prebuilt raw disk image (/var/lib/vz/template/iso/opnsense.img, synced by NETSetup.Helpers.EnsureOpnsenseImage.EnsureOpnsenseImageOnProxmoxHost(ISystemHost,IFileProvider)). Single-NIC config: net0 → vmbr0 (WAN). LAN bridge wiring is out-of-scope for the first iteration; OPNsense uses default config until a config.xml seeding pass is added in a follow-up.

public static class ProvisionOpnsenseVm

1. Fields

1.1. DefaultBridge

Default Proxmox bridge for OPNsense WAN.

public const string DefaultBridge

1.2. LanBridge

LAN bridge created by UpdateMethods.EnsureLanBridgeVmbr1.

public const string LanBridge

1.3. OpnsenseImagePath

Source raw image path on the Proxmox host. Same directory as Nix and Windows ISOs (single sync target, all populated by EnsureXxxOnProxmoxHost helpers).

public const string OpnsenseImagePath

2. Methods

2.1. Run(Host, SystemManagement.Entities.Machine, NETSetupConfig, ISystemHost)

Full production entry point. Wires:

  • VM existence via Host.TryGetVirtualMachine.

  • VM create + import disk + start via direct /usr/sbin/qm invocations (no sh -c).

public static ProvisionOpnsenseVmResult Run(Host proxmoxHost, SystemManagement.Entities.Machine machine, NETSetupConfig config, ISystemHost sysHost)
Table 1. Parameters
Name Type Description

proxmoxHost

Host

machine

SystemManagement.Entities.Machine

config

NETSetupConfig

sysHost

ISystemHost

Returns: ProvisionOpnsenseVmResult

2.2. RunCore(SystemManagement.Entities.Machine, Func<bool>, Action<int, string>, Action<int>, ILogger)

Testable core. Each external action is a delegate seam unit tests can stub. Sequence: extract vmId, vmExists check (skip if true), createVm (qm create), importDiskAndStart (qm importdisk + qm set boot + qm start).

public static ProvisionOpnsenseVmResult RunCore(SystemManagement.Entities.Machine machine, Func<bool> vmExists, Action<int, string> createVm, Action<int> importDiskAndStart, ILogger logger)
Table 2. Parameters
Name Type Description

machine

SystemManagement.Entities.Machine

vmExists

Func<bool>

createVm

Action<int, string>

importDiskAndStart

Action<int>

logger

ILogger

Returns: ProvisionOpnsenseVmResult