Commit Graph

13 Commits

Author SHA1 Message Date
Damien
21e79e3536 feat: Add Infrahub Jinja2 transform for MLAG configuration (#22)
- Add GraphQL query mlag_intent.gql: queries InfraMlagPeerConfig by
  device name, returning local IP, peer address, heartbeat peer IP,
  MLAG domain (domain-id, virtual-mac, heartbeat VRF, dual-primary
  detection settings, peer/iBGP VLANs, peer devices), local interface
  SVI name, and peer-link LAG name
- Add Jinja2 template mlag_yang.j2: renders a JSON object targeting
  Arista-native YANG path /arista-mlag-augments:mlag/config; returns
  empty array [] for devices with no MLAG config (spines); all optional
  relationship accesses guarded with 'is defined and is not none' checks
- Update .infrahub.yml: register mlag_intent query and mlag_yang_transform
- Add unit test fixtures for leaf1 (full MLAG config) and spine1 (empty
  response → []) following jinja2-transform-unit-render format

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-01 11:59:21 +01:00
a105e44bbd feat: Add Infrahub Jinja2 transform for VRF/L3VNI configuration (#21) (#25)
## 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
2026-03-01 10:45:01 +00:00
668e9cbada feat: Add Infrahub Jinja2 transforms for VLANs, interfaces, and VXLAN (#20) (#24)
## Summary

Closes #20

Adds Infrahub Jinja2 transforms that query device intent from Infrahub via GraphQL and produce structured JSON payloads (YANG-style) suitable for gNMI Set operations on Arista EOS devices.

- **3 GraphQL queries** — `vlan_intent`, `interface_intent`, `vxlan_intent` — each parameterized by `$device_name`
- **3 Jinja2 templates** — `vlan_yang.j2`, `interface_yang.j2`, `vxlan_yang.j2` — producing JSON arrays/objects from the GraphQL response
- **Integration test fixtures** — one directory per transform with `input.json`, `output.json`, and `test.yml`, using leaf1 from the lab topology as sample device
- **`.infrahub.yml` updated** with `queries` and `jinja2_transforms` sections

## Files added

```
transforms/
├── queries/
│   ├── vlan_intent.gql       # VLANs via VTEP mappings + SVI interfaces
│   ├── interface_intent.gql  # All interface types with IPs
│   └── vxlan_intent.gql      # VTEP config + VLAN/VNI/VRF mappings
├── templates/
│   ├── vlan_yang.j2          # JSON array of VLANs (merged, deduplicated, sorted)
│   ├── interface_yang.j2     # JSON array of interfaces with type discriminator
│   └── vxlan_yang.j2         # JSON object: vtep + vlan_vni + vrf_vni mappings
└── tests/
    ├── vlan_yang/{input,output,test}.{json,yml}
    ├── interface_yang/{input,output,test}.{json,yml}
    └── vxlan_yang/{input,output,test}.{json,yml}
```

## Transform usage

```bash
# Render locally
infrahubctl render vlan_yang_transform device_name=leaf1
infrahubctl render interface_yang_transform device_name=leaf1
infrahubctl render vxlan_yang_transform device_name=leaf1

# Via API
GET /api/transform/jinja2/vlan_yang_transform?device_name=leaf1
GET /api/transform/jinja2/interface_yang_transform?device_name=leaf1
GET /api/transform/jinja2/vxlan_yang_transform?device_name=leaf1
```

## Test plan

- [x] Load branch into Infrahub (`infrahubctl schema load` + `infrahubctl object load`)
- [x] Run `infrahubctl render vlan_yang_transform device_name=leaf1` and verify JSON output matches expected VLANs (40, 4090, 4091)
- [x] Run `infrahubctl render interface_yang_transform device_name=leaf1` and verify all interface types are present with correct attributes
- [x] Run `infrahubctl render vxlan_yang_transform device_name=leaf1` and verify VTEP source address, UDP port, and VLAN-VNI mapping for VLAN 40 / VNI 110040
- [x] Run `infrahubctl render vxlan_yang_transform device_name=leaf3` and verify VRF gold / L3VNI 100001 appears in `vrf_vni_mappings`
- ~~[ ] Verify `infrahubctl test` passes for all three test fixtures~~

Reviewed-on: #24
2026-02-28 17:42:08 +00:00
Damien
ac1634b561 Add device roles to fabric links 2026-02-22 10:07:27 +01:00
Damien
9a0b6dd1e6 feat(schema): add bidirectional relationship identifiers and fabric-device links
- LocationSite: add devices (device__site) and fabrics (fabric__sites) reverse relationships
- InfraDevice.site: add identifier device__site
- InfraDevice: add fabric relationship (fabric__devices)
- InfraFabric.sites: add identifier fabric__sites; add devices reverse relationship (fabric__devices)
- InfraInterfaceVlan.vlan: add identifier vlan__svi
- InfraVLAN: add svi_interfaces reverse relationship (vlan__svi)
- Add 14-fabric-links.yml to assign all 10 devices to the evpn-lab fabric

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-21 20:59:10 +01:00
Damien
2c1fccee5b Remove IP addresses from interfaces and add new IPAM links file 2026-02-21 18:08:53 +01:00
Damien
e778fedf71 Add IP addresses to loopback and VLAN interfaces 2026-02-21 18:03:19 +01:00
Damien
4aecc544da Refactor interface references to use structured format
Refactored all interface references in IPAM configuration to use the
structured format with kind and data fields instead of simple lists.
This improves consistency and makes the configuration more maintainable.
2026-02-21 17:41:11 +01:00
Damien
807f3ce8a1 refactor(ipam): simplify interface references to compact array format
Replace verbose interface definitions using node/kind objects with
concise [device, interface] array notation across all IPAM address
entries. This reduces verbosity and improves readability of the
IP address assignments for loopbacks and P2P underlay links.
2026-02-21 16:13:31 +01:00
Damien
e9dad132ea feat(ipam): add interface associations to IP addresses
Add interface node and kind to all IP address entries in the IPAM configuration file. This change enhances the IPAM configuration by explicitly associating each IP address with its corresponding interface, improving clarity and maintainability of the network configuration.

The changes include:
- Adding interface node and kind for all Router-ID Loopback0 addresses
- Adding interface node and kind for all VTEP Loopback1 addresses
- Adding interface node and kind for all spine and leaf P2P underlay addresses
- Maintaining consistent format across all IP address entries
2026-02-21 16:02:54 +01:00
Damien
e353ef0a90 Update MLAG schema to use IPHost instead of IPNetwork for local
interface IP
2026-02-21 11:48:13 +01:00
Damien
6dd4cc96ef fix(InfraBGPSessionUpsert): changeing load order of objects 2026-02-21 10:02:17 +01:00
Damien
1b25c92965 build(infrahub): update file paths to match new directory structure
Refactor the .infrahub.yml configuration file to prefix all schema, menu, and object paths with the 'infrahub/' directory. This change aligns the configuration with the reorganized project structure where Infrahub resources have been moved into a dedicated subfolder.
2026-02-20 18:33:37 +01:00