Implement backups, commit and restoration
This commit is contained in:
@@ -211,6 +211,25 @@ impl ClientStates {
|
||||
&self.reserved_addresses
|
||||
}
|
||||
|
||||
/// Restore conservative reservations from saved metadata without asserting
|
||||
/// that the running interface matches the saved snapshot.
|
||||
pub fn restore_persisted_reservations(
|
||||
&mut self,
|
||||
reservations: impl IntoIterator<Item = IpAddr>,
|
||||
) -> Result<(), DomainError> {
|
||||
let reservations = reservations.into_iter().collect::<BTreeSet<_>>();
|
||||
if reservations
|
||||
.iter()
|
||||
.any(|address| self.saved.addresses().any(|saved| saved == *address))
|
||||
{
|
||||
return Err(DomainError::ReservationConflictsWithSavedClient);
|
||||
}
|
||||
self.reserved_addresses = reservations;
|
||||
self.applied_snapshot = None;
|
||||
self.applied = RuntimeObservation::Unknown;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn draft_mut(&mut self) -> &mut Snapshot {
|
||||
&mut self.draft
|
||||
}
|
||||
@@ -297,6 +316,8 @@ pub enum DomainError {
|
||||
AddressUnavailable,
|
||||
#[error("verified applied clients do not match the saved snapshot")]
|
||||
AppliedSnapshotMismatch,
|
||||
#[error("persisted reservation conflicts with a saved client address")]
|
||||
ReservationConflictsWithSavedClient,
|
||||
}
|
||||
|
||||
/// Return the lowest available host in `range` without walking the subnet.
|
||||
|
||||
Reference in New Issue
Block a user