## Summary Closes #22. Implements Infrahub Jinja2 transforms for MLAG configuration, generating Arista-native YANG-compatible JSON payloads from Infrahub intent data. | File | Description | |------|-------------| | `infrahub/transforms/queries/mlag_intent.gql` | GraphQL query — fetches `InfraMlagPeerConfig` by `$device_name`, including MLAG domain attributes, peer/iBGP VLANs, local interface SVI, and peer-link LAG | | `infrahub/transforms/templates/mlag_yang.j2` | Jinja2 template — renders a JSON object targeting `/arista-mlag-augments:mlag/config`; returns `[]` for devices with no MLAG (spines) | | `infrahub/transforms/tests/mlag_yang/test.yml` | Test spec: smoke check + unit render tests for `leaf1` and `spine1` | | `infrahub/transforms/tests/mlag_yang/leaf1/` | Mock input + expected output for leaf1 (full MLAG config, domain `leafs-1-2`) | | `infrahub/transforms/tests/mlag_yang/spine1/` | Mock input (empty edges) + expected output `[]` for spine1 | | `.infrahub.yml` | Registers `mlag_intent` query and `mlag_yang_transform` jinja2 transform | ## Output shape (leaf1) ```json { "mlag": { "config": { "domain-id": "leafs-1-2", "peer-link": "Port-Channel999", "local-interface": "Vlan4090", "peer-address": "10.0.199.255", "shutdown": false }, "dual_primary_detection": { "enabled": true, "delay": 10, "action": "errdisable", "heartbeat_peer_ip": "172.16.0.50", "heartbeat_vrf": "mgmt" }, "virtual_mac": "c001.cafe.babe", "peer_vlan_id": 4090, "ibgp_vlan_id": 4091, "local_interface_ip": "10.0.199.254/31" } } ``` ## Validation ```bash infrahubctl render mlag_yang_transform device_name=leaf1 # → MLAG config JSON infrahubctl render mlag_yang_transform device_name=spine1 # → [] ``` ## Design notes - Follows identical conventions to existing transforms (#20 VLAN/interface/VXLAN, #21 VRF/L3VNI) - All optional relationship accesses wrapped in `is defined and is not none` guards - Spine/non-MLAG devices return `[]` (empty array) — consistent with the "no data → empty collection" pattern used in vxlan_yang for devices without VTEP
53 lines
1.9 KiB
YAML
53 lines
1.9 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: infrahub/transforms/queries/vlan_intent.gql
|
|
- name: interface_intent
|
|
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
|
|
- name: mlag_intent
|
|
file_path: infrahub/transforms/queries/mlag_intent.gql
|
|
|
|
jinja2_transforms:
|
|
- name: vlan_yang_transform
|
|
description: "Generate VLAN configuration payload from Infrahub intent"
|
|
query: vlan_intent
|
|
template_path: infrahub/transforms/templates/vlan_yang.j2
|
|
- name: interface_yang_transform
|
|
description: "Generate interface configuration payload from Infrahub intent"
|
|
query: interface_intent
|
|
template_path: infrahub/transforms/templates/interface_yang.j2
|
|
- name: vxlan_yang_transform
|
|
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
|
|
- name: mlag_yang_transform
|
|
description: "Generate MLAG configuration payload from Infrahub intent"
|
|
query: mlag_intent
|
|
template_path: infrahub/transforms/templates/mlag_yang.j2
|