[Phase 2] Build diff engine (current vs desired state) #7

Open
opened 2025-12-20 15:41:08 +00:00 by Damien · 0 comments
Owner

Description

Build the diff engine that compares current device state against desired state from NetBox.

Tasks

  • Normalize current state (from gNMI Get) into comparable format
  • Normalize desired state (from NetBox) into comparable format
  • Compute diff: what to CREATE, UPDATE, DELETE
  • Handle nested structures (VLANs within network-instance, etc.)
  • Generate human-readable diff output

Diff Types

class ChangeType(Enum):
    CREATE = "create"   # Exists in desired, not in current
    UPDATE = "update"   # Exists in both, values differ
    DELETE = "delete"   # Exists in current, not in desired
    NOOP = "noop"       # Identical

Example Output

Device: leaf1
  VLANs:
    + VLAN 40 (CREATE): name="test-l2-vxlan", vni=100040
    ~ VLAN 50 (UPDATE): name changed "old" -> "new"
    - VLAN 99 (DELETE): will be removed

Implementation Considerations

  • Deep comparison for nested YANG structures
  • Handle list ordering (YANG lists are often unordered)
  • Ignore operational state fields (only compare config)

Output

  • src/reconciler/diff.py
## Description Build the diff engine that compares current device state against desired state from NetBox. ## Tasks - [ ] Normalize current state (from gNMI Get) into comparable format - [ ] Normalize desired state (from NetBox) into comparable format - [ ] Compute diff: what to CREATE, UPDATE, DELETE - [ ] Handle nested structures (VLANs within network-instance, etc.) - [ ] Generate human-readable diff output ## Diff Types ```python class ChangeType(Enum): CREATE = "create" # Exists in desired, not in current UPDATE = "update" # Exists in both, values differ DELETE = "delete" # Exists in current, not in desired NOOP = "noop" # Identical ``` ## Example Output ``` Device: leaf1 VLANs: + VLAN 40 (CREATE): name="test-l2-vxlan", vni=100040 ~ VLAN 50 (UPDATE): name changed "old" -> "new" - VLAN 99 (DELETE): will be removed ``` ## Implementation Considerations - Deep comparison for nested YANG structures - Handle list ordering (YANG lists are often unordered) - Ignore operational state fields (only compare config) ## Output - `src/reconciler/diff.py`
Damien added the phase-2-minimal-reconciler label 2025-12-20 15:41:20 +00:00
Sign in to join this conversation.