## 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
This commit was merged in pull request #25.
This commit is contained in:
@@ -24,6 +24,8 @@ queries:
|
||||
file_path: infrahub/transforms/queries/interface_intent.gql
|
||||
- name: vxlan_intent
|
||||
file_path: infrahub/transforms/queries/vxlan_intent.gql
|
||||
- name: vrf_intent
|
||||
file_path: infrahub/transforms/queries/vrf_intent.gql
|
||||
|
||||
jinja2_transforms:
|
||||
- name: vlan_yang_transform
|
||||
@@ -38,3 +40,7 @@ jinja2_transforms:
|
||||
description: "Generate VXLAN/VTEP configuration payload from Infrahub intent"
|
||||
query: vxlan_intent
|
||||
template_path: infrahub/transforms/templates/vxlan_yang.j2
|
||||
- name: vrf_yang_transform
|
||||
description: "Generate VRF/L3VNI configuration payload from Infrahub intent"
|
||||
query: vrf_intent
|
||||
template_path: infrahub/transforms/templates/vrf_yang.j2
|
||||
|
||||
Reference in New Issue
Block a user