Add three GraphQL queries, Jinja2 templates, and integration tests for generating YANG-style JSON configuration payloads from Infrahub intent data, suitable for gNMI Set operations on Arista EOS devices. Queries (transforms/queries/): - vlan_intent.gql: Fetches VLANs for a device via VTEP mappings and SVI interfaces, including VNI associations. - interface_intent.gql: Fetches all interface types (loopback, ethernet, vlan, lag) with IP addresses and type-specific attributes. - vxlan_intent.gql: Fetches VTEP config, VLAN-to-VNI mappings, and VRF-to-VNI mappings (L3VNI) via VRF device assignments. Templates (transforms/templates/): - vlan_yang.j2: Merges VLANs from both VTEP and SVI sources, deduplicates by vlan_id, and emits a sorted JSON array. - interface_yang.j2: Emits a JSON array of interfaces sorted by name, with a "type" discriminator field for each interface kind. - vxlan_yang.j2: Emits a JSON object with vtep config, vlan_vni_mappings, and vrf_vni_mappings sections. Integration tests (transforms/tests/): - One test directory per transform with input.json (sample GraphQL response for leaf1), output.json (expected result), and test.yml config. - Test data reflects the lab topology: leaf1 VTEP 10.0.255.11, VLAN 40 / VNI 110040, MLAG VLANs 4090/4091, underlay Ethernet11/12. .infrahub.yml updated with queries and jinja2_transforms sections. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
41 lines
1.3 KiB
YAML
41 lines
1.3 KiB
YAML
---
|
|
schemas:
|
|
- infrahub/schemas
|
|
menus:
|
|
- infrahub/menus
|
|
objects:
|
|
- infrahub/objects/01-foundation.yml
|
|
- infrahub/objects/02-fabric.yml
|
|
- infrahub/objects/03-devices.yml
|
|
- infrahub/objects/04-interfaces.yml
|
|
- infrahub/objects/05-ipam.yml
|
|
- infrahub/objects/06-vlans-vxlan.yml
|
|
- infrahub/objects/07-interface-vlans.yml
|
|
- infrahub/objects/08-ipam-vlans.yml
|
|
- infrahub/objects/09-bgp.yml
|
|
- infrahub/objects/10-bgp-sessions.yml
|
|
- infrahub/objects/11-vrfs.yml
|
|
- infrahub/objects/12-mlag.yml
|
|
|
|
queries:
|
|
- name: vlan_intent
|
|
file_path: transforms/queries/vlan_intent.gql
|
|
- name: interface_intent
|
|
file_path: transforms/queries/interface_intent.gql
|
|
- name: vxlan_intent
|
|
file_path: transforms/queries/vxlan_intent.gql
|
|
|
|
jinja2_transforms:
|
|
- name: vlan_yang_transform
|
|
description: "Generate VLAN configuration payload from Infrahub intent"
|
|
query: vlan_intent
|
|
template_path: transforms/templates/vlan_yang.j2
|
|
- name: interface_yang_transform
|
|
description: "Generate interface configuration payload from Infrahub intent"
|
|
query: interface_intent
|
|
template_path: transforms/templates/interface_yang.j2
|
|
- name: vxlan_yang_transform
|
|
description: "Generate VXLAN/VTEP configuration payload from Infrahub intent"
|
|
query: vxlan_intent
|
|
template_path: transforms/templates/vxlan_yang.j2
|