DhcpReservationFileStore

Per-customer persistence of DHCP static-map reservations on the Proxmox host. The provisioning flow (qm guest-agent IP discovery + qm config MAC lookup) appends entries here after each VM comes up; OpnsenseConvergeBridge loads the file before each converge and hands it to Build(NETSetupConfig, IReadOnlyList<DhcpReservation>).

Note
File path: /NETSetup/Config/{configName}/dhcp-reservations.json. Missing file → empty list (no reservations pushed). Identity = MAC; Upsert(ConfigName, DhcpReservation) replaces by MAC.
public static class DhcpReservationFileStore

1. Fields

1.1. FileName

File name of the per-customer reservation list.

public const string FileName

1.2. RootDir

Root dir under which per-customer state lives on the Proxmox host.

public const string RootDir

2. Methods

2.1. GetPath(ConfigName)

Absolute path of the reservation file for the given customer.

public static AbsolutePath GetPath(ConfigName configName)
Table 1. Parameters
Name Type Description

configName

ConfigName

Returns: AbsolutePath

2.2. Load(ConfigName)

Loads the reservations. Missing or unparseable file → empty list.

public static IReadOnlyList<DhcpReservation> Load(ConfigName configName)
Table 2. Parameters
Name Type Description

configName

ConfigName

Returns: IReadOnlyList<DhcpReservation>

2.3. LoadFromFile(AbsolutePath)

Path-based load. Used by Load(ConfigName) and by tests that need a temp-dir path. Missing or unparseable file → empty list.

public static IReadOnlyList<DhcpReservation> LoadFromFile(AbsolutePath path)
Table 3. Parameters
Name Type Description

path

AbsolutePath

Returns: IReadOnlyList<DhcpReservation>

2.4. Remove(ConfigName, string)

Removes the reservation with the given MAC. No-op when absent. Returns the persisted list.

public static IReadOnlyList<DhcpReservation> Remove(ConfigName configName, string mac)
Table 4. Parameters
Name Type Description

configName

ConfigName

mac

string

Returns: IReadOnlyList<DhcpReservation>

2.5. RemoveFromFile(AbsolutePath, string)

Path-based remove. Used by Remove(ConfigName, string) and by tests.

public static IReadOnlyList<DhcpReservation> RemoveFromFile(AbsolutePath path, string mac)
Table 5. Parameters
Name Type Description

path

AbsolutePath

mac

string

Returns: IReadOnlyList<DhcpReservation>

2.6. Save(ConfigName, IReadOnlyList<DhcpReservation>)

Writes the full reservation set, creating the customer directory if needed.

public static void Save(ConfigName configName, IReadOnlyList<DhcpReservation> reservations)
Table 6. Parameters
Name Type Description

configName

ConfigName

reservations

IReadOnlyList<DhcpReservation>

2.7. SaveToFile(AbsolutePath, IReadOnlyList<DhcpReservation>)

Path-based save. Used by Save(ConfigName, IReadOnlyList<DhcpReservation>) and by tests. Creates parent dir if missing.

public static void SaveToFile(AbsolutePath path, IReadOnlyList<DhcpReservation> reservations)
Table 7. Parameters
Name Type Description

path

AbsolutePath

reservations

IReadOnlyList<DhcpReservation>

2.8. Upsert(ConfigName, DhcpReservation)

Replaces (or inserts) the reservation matching reservation.Mac. MAC comparison is case-insensitive. Returns the persisted list.

public static IReadOnlyList<DhcpReservation> Upsert(ConfigName configName, DhcpReservation reservation)
Table 8. Parameters
Name Type Description

configName

ConfigName

reservation

DhcpReservation

Returns: IReadOnlyList<DhcpReservation>

2.9. UpsertInFile(AbsolutePath, DhcpReservation)

Path-based upsert. Used by Upsert(ConfigName, DhcpReservation) and by tests.

public static IReadOnlyList<DhcpReservation> UpsertInFile(AbsolutePath path, DhcpReservation reservation)
Table 9. Parameters
Name Type Description

path

AbsolutePath

reservation

DhcpReservation

Returns: IReadOnlyList<DhcpReservation>