[Phase 2] Implement NetBox → YANG path mapper (VLANs only) #6

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

Description

Implement the mapper that converts NetBox ConfigContext data into gNMI YANG paths and values.

Scope (Phase 2)

Start with VLANs only to prove the pattern:

  • Parse VLAN intent from ConfigContext
  • Generate YANG path for VLAN creation
  • Generate YANG path for VLAN-to-VNI mapping
  • Generate YANG value (JSON payload)

Implementation

class YANGMapper:
    def map_vlan(self, vlan_intent: dict) -> list[GNMIOperation]:
        """Convert VLAN intent to gNMI operations"""
        ops = []
        
        # VLAN creation (OpenConfig)
        ops.append(GNMIOperation(
            path="/openconfig-network-instance:network-instances/...",
            value={"vlan-id": vlan_intent['id'], ...}
        ))
        
        # VNI mapping (Arista native)
        ops.append(GNMIOperation(
            path="/arista/eos/arista-exp-eos-vxlan:...",
            value={"vlan": vlan_intent['id'], "vni": vlan_intent['vni']}
        ))
        
        return ops

Dependencies

  • #3 (YANG paths documented)
  • #5 (NetBox schema defined)

Output

  • src/yang/mapper.py
## Description Implement the mapper that converts NetBox ConfigContext data into gNMI YANG paths and values. ## Scope (Phase 2) Start with VLANs only to prove the pattern: - [ ] Parse VLAN intent from ConfigContext - [ ] Generate YANG path for VLAN creation - [ ] Generate YANG path for VLAN-to-VNI mapping - [ ] Generate YANG value (JSON payload) ## Implementation ```python class YANGMapper: def map_vlan(self, vlan_intent: dict) -> list[GNMIOperation]: """Convert VLAN intent to gNMI operations""" ops = [] # VLAN creation (OpenConfig) ops.append(GNMIOperation( path="/openconfig-network-instance:network-instances/...", value={"vlan-id": vlan_intent['id'], ...} )) # VNI mapping (Arista native) ops.append(GNMIOperation( path="/arista/eos/arista-exp-eos-vxlan:...", value={"vlan": vlan_intent['id'], "vni": vlan_intent['vni']} )) return ops ``` ## Dependencies - #3 (YANG paths documented) - #5 (NetBox schema defined) ## Output - `src/yang/mapper.py`
Damien added the phase-2-minimal-reconciler label 2025-12-20 15:40:59 +00:00
Sign in to join this conversation.