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>
107 lines
2.1 KiB
JSON
107 lines
2.1 KiB
JSON
[
|
|
{
|
|
"type": "ethernet",
|
|
"name": "Ethernet1",
|
|
"description": "host1",
|
|
"enabled": true,
|
|
"mtu": null,
|
|
"speed": null,
|
|
"mode": "trunk",
|
|
"lag": "Port-Channel1",
|
|
"ip_addresses": []
|
|
},
|
|
{
|
|
"type": "ethernet",
|
|
"name": "Ethernet10",
|
|
"description": "mlag peer link",
|
|
"enabled": true,
|
|
"mtu": null,
|
|
"speed": null,
|
|
"mode": "trunk",
|
|
"lag": "Port-Channel999",
|
|
"ip_addresses": []
|
|
},
|
|
{
|
|
"type": "ethernet",
|
|
"name": "Ethernet11",
|
|
"description": "spine1",
|
|
"enabled": true,
|
|
"mtu": 9214,
|
|
"speed": null,
|
|
"mode": "routed",
|
|
"lag": null,
|
|
"ip_addresses": ["10.0.1.1/31"]
|
|
},
|
|
{
|
|
"type": "ethernet",
|
|
"name": "Ethernet12",
|
|
"description": "spine2",
|
|
"enabled": true,
|
|
"mtu": 9214,
|
|
"speed": null,
|
|
"mode": "routed",
|
|
"lag": null,
|
|
"ip_addresses": ["10.0.2.1/31"]
|
|
},
|
|
{
|
|
"type": "loopback",
|
|
"name": "Loopback0",
|
|
"description": "Router-ID",
|
|
"enabled": true,
|
|
"mtu": null,
|
|
"ip_addresses": ["10.0.250.11/32"]
|
|
},
|
|
{
|
|
"type": "loopback",
|
|
"name": "Loopback1",
|
|
"description": "VTEP",
|
|
"enabled": true,
|
|
"mtu": null,
|
|
"ip_addresses": ["10.0.255.11/32"]
|
|
},
|
|
{
|
|
"type": "lag",
|
|
"name": "Port-Channel1",
|
|
"description": "host1",
|
|
"enabled": true,
|
|
"mtu": null,
|
|
"lacp_mode": "active",
|
|
"mlag_id": 1,
|
|
"members": ["Ethernet1"],
|
|
"ip_addresses": []
|
|
},
|
|
{
|
|
"type": "lag",
|
|
"name": "Port-Channel999",
|
|
"description": "MLAG Peer",
|
|
"enabled": true,
|
|
"mtu": null,
|
|
"lacp_mode": "active",
|
|
"mlag_id": null,
|
|
"members": ["Ethernet10"],
|
|
"ip_addresses": []
|
|
},
|
|
{
|
|
"type": "vlan",
|
|
"name": "Vlan4090",
|
|
"description": "MLAG Peer-Link",
|
|
"enabled": true,
|
|
"mtu": null,
|
|
"vlan_id": 4090,
|
|
"virtual_router_address": null,
|
|
"autostate": false,
|
|
"ip_addresses": ["10.255.255.0/31"]
|
|
},
|
|
{
|
|
"type": "vlan",
|
|
"name": "Vlan4091",
|
|
"description": "MLAG iBGP Peering",
|
|
"enabled": true,
|
|
"mtu": 9214,
|
|
"vlan_id": 4091,
|
|
"virtual_router_address": null,
|
|
"autostate": true,
|
|
"ip_addresses": []
|
|
}
|
|
]
|