[Phase 2] Implement gNMI Set for atomic configuration changes #9

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

Description

Implement gNMI Set operation to apply configuration changes atomically.

Tasks

  • Implement Set with update operations
  • Implement Set with replace operations
  • Implement Set with delete operations
  • Support multiple operations in single transaction
  • Handle errors and provide meaningful messages
  • Implement dry-run mode (validate without applying)

API Design

class GNMIClient:
    async def set(
        self,
        updates: list[tuple[str, dict]] = None,
        replaces: list[tuple[str, dict]] = None,
        deletes: list[str] = None
    ) -> SetResponse:
        """Apply configuration changes atomically"""
        
    async def apply_changes(
        self, 
        changes: list[PlannedChange],
        dry_run: bool = False
    ) -> ApplyResult:
        """Apply planned changes from diff engine"""

Atomic Transaction

All changes in a single Set request are applied atomically:

  • Either all succeed or all fail
  • No partial application
  • Rollback on error

Error Handling

try:
    result = await client.set(updates=[...])
except GNMISetError as e:
    print(f"Failed to apply: {e.path}")
    print(f"Reason: {e.message}")

Output

  • src/gnmi/client.py (extend)
  • src/gnmi/transactions.py
## Description Implement gNMI Set operation to apply configuration changes atomically. ## Tasks - [ ] Implement Set with update operations - [ ] Implement Set with replace operations - [ ] Implement Set with delete operations - [ ] Support multiple operations in single transaction - [ ] Handle errors and provide meaningful messages - [ ] Implement dry-run mode (validate without applying) ## API Design ```python class GNMIClient: async def set( self, updates: list[tuple[str, dict]] = None, replaces: list[tuple[str, dict]] = None, deletes: list[str] = None ) -> SetResponse: """Apply configuration changes atomically""" async def apply_changes( self, changes: list[PlannedChange], dry_run: bool = False ) -> ApplyResult: """Apply planned changes from diff engine""" ``` ## Atomic Transaction All changes in a single Set request are applied atomically: - Either all succeed or all fail - No partial application - Rollback on error ## Error Handling ```python try: result = await client.set(updates=[...]) except GNMISetError as e: print(f"Failed to apply: {e.path}") print(f"Reason: {e.message}") ``` ## Output - `src/gnmi/client.py` (extend) - `src/gnmi/transactions.py`
Damien added the phase-2-minimal-reconciler label 2025-12-20 15:42:07 +00:00
Sign in to join this conversation.