feat: Add Infrahub Jinja2 transform for VRF/L3VNI configuration (#21) #25

Merged
Damien merged 1 commits from feat/infrahub-transforms-vrf-l3vni into main 2026-03-01 10:45:01 +00:00
Owner

Summary

Implements Infrahub Jinja2 Transform for VRF/L3VNI configuration, generating structured JSON payloads from Infrahub intent data. Closes #21.

What's included

  • GraphQL query (transforms/queries/vrf_intent.gql): Queries InfraVRFDeviceAssignment by device name, fetching VRF details, L3VNI, route targets, and device-specific route distinguisher
  • Jinja2 transform (transforms/templates/vrf_yang.j2): Renders VRF config payloads with defensive null handling (lessons learned from #20)
  • .infrahub.yml updated with the new query and transform definitions
  • Tests (transforms/tests/vrf_yang/) using correct Infrahub pytest format (jinja2-transform-smoke + jinja2-transform-unit-render)

Validation

All transforms render correctly:

Device Expected Result
leaf3 VRF gold, RD 10.0.250.13:1, L3VNI 100001
leaf7 VRF gold, RD 10.0.250.17:1, L3VNI 100001
leaf1 Empty array (no VRF assignment)
spine1 Empty array (no VRF assignment)

Usage

# Local debugging
infrahubctl render vrf_yang_transform device_name=leaf3

# API endpoint
GET /api/transform/jinja2/vrf_yang_transform?device_name=leaf3
  • Depends on: #20 (base transforms infrastructure, already merged)
  • Reference: Arista EVPN Type-5 / L3VXLAN configuration from lab topology
## Summary Implements Infrahub Jinja2 Transform for VRF/L3VNI configuration, generating structured JSON payloads from Infrahub intent data. Closes #21. ## What's included - **GraphQL query** (`transforms/queries/vrf_intent.gql`): Queries `InfraVRFDeviceAssignment` by device name, fetching VRF details, L3VNI, route targets, and device-specific route distinguisher - **Jinja2 transform** (`transforms/templates/vrf_yang.j2`): Renders VRF config payloads with defensive null handling (lessons learned from #20) - **`.infrahub.yml`** updated with the new query and transform definitions - **Tests** (`transforms/tests/vrf_yang/`) using correct Infrahub pytest format (`jinja2-transform-smoke` + `jinja2-transform-unit-render`) ## Validation All transforms render correctly: | Device | Expected | Result | |--------|----------|--------| | `leaf3` | VRF gold, RD `10.0.250.13:1`, L3VNI 100001 | ✅ | | `leaf7` | VRF gold, RD `10.0.250.17:1`, L3VNI 100001 | ✅ | | `leaf1` | Empty array (no VRF assignment) | ✅ | | `spine1` | Empty array (no VRF assignment) | ✅ | ## Usage ```bash # Local debugging infrahubctl render vrf_yang_transform device_name=leaf3 # API endpoint GET /api/transform/jinja2/vrf_yang_transform?device_name=leaf3 ``` ## Related - Depends on: #20 (base transforms infrastructure, already merged) - Reference: Arista EVPN Type-5 / L3VXLAN configuration from lab topology
Damien added 1 commit 2026-03-01 10:37:20 +00:00
- Add GraphQL query vrf_intent.gql: queries InfraVRFDeviceAssignment by
  device name, returning device-specific RD, VRF attributes (name,
  description, l3vni), and both device-level and VRF-level import/export
  route targets for fallback logic
- Add Jinja2 template vrf_yang.j2: renders a JSON array of VRF config
  objects with RD fallback (device → VRF-level) and RT merge logic
  (device-level if present, otherwise VRF-level); all optional
  relationships guarded with 'is defined and is not none' checks
- Update .infrahub.yml: register vrf_intent query and vrf_yang_transform
- Add unit test fixtures for leaf3: input.json (mock GraphQL response)
  and output.json (expected rendered JSON array)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Damien merged commit a105e44bbd into main 2026-03-01 10:45:01 +00:00
Damien deleted branch feat/infrahub-transforms-vrf-l3vni 2026-03-01 10:45:05 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Damien/arista-evpn-vxlan-clab#25