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

- 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>
This commit is contained in:
Damien
2026-03-01 11:30:39 +01:00
parent 668e9cbada
commit 7b40c5fbe1
6 changed files with 246 additions and 0 deletions

View File

@@ -0,0 +1,50 @@
query VrfIntent($device_name: String!) {
InfraVRFDeviceAssignment(device__name__value: $device_name) {
edges {
node {
route_distinguisher { value }
vrf {
node {
name { value }
description { value }
route_distinguisher { value }
l3vni {
node {
vni { value }
vni_type { value }
}
}
import_targets {
edges {
node {
target { value }
}
}
}
export_targets {
edges {
node {
target { value }
}
}
}
}
}
import_targets {
edges {
node {
target { value }
}
}
}
export_targets {
edges {
node {
target { value }
}
}
}
}
}
}
}