Commit Graph
16 Commits
Author SHA1 Message Date
DamienandClaude Sonnet 4.6 87748329c8 refactor: move transforms/ into infrahub/ and update all paths (#20)
Move transforms/{queries,templates,tests} under infrahub/transforms/ so all
Infrahub-managed content lives under the dedicated infrahub/ directory,
consistent with schemas/, objects/, and menus/.

Updated paths:
- .infrahub.yml: file_path and template_path entries now prefixed with
  infrahub/transforms/
- infrahub/transforms/tests/*/test.yml: directory references updated from
  transforms/tests/* to infrahub/transforms/tests/*

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-28 18:37:07 +01:00
DamienandClaude Sonnet 4.6 a492aa3c39 fix: rewrite transform tests to use correct Infrahub pytest format (#20)
Rewrite all three test.yml files to use the Infrahub SDK pytest format
(version: "1.0" / infrahub_tests) instead of the previous invalid
apiVersion/kind schema. Each test file now declares a smoke_check test
(jinja2-transform-smoke) and a unit render test (jinja2-transform-unit-render)
pointing to the local input/output JSON fixtures.

Update output.json files with the actual render output from the fixed templates:
- vlan_yang: trunk_groups is null (not []) for VLANs with no trunk groups set;
  key order reflects Python dict / tojson serialization order.
- interface_yang: corrected MLAG peer-link SVI IP (10.0.199.254/31), added
  iBGP SVI IP (10.0.3.0/31), removed stale Loopback1 IP address.
- vxlan_yang: source_address now includes /32 prefix as stored in Infrahub
  IPHost fields; key order matches tojson output.

Update input.json files to be consistent with the expected output:
- vlan_yang/input.json: trunk_groups.value set to null for VLAN 40.
- interface_yang/input.json: Loopback1 ip_addresses cleared; Vlan4090 IP
  updated to 10.0.199.254/31; Vlan4091 IP added as 10.0.3.0/31.
- vxlan_yang/input.json: source_address updated to 10.0.255.11/32.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-28 18:30:10 +01:00
DamienandClaude Sonnet 4.6 a415de85bd fix: use Jinja2 none instead of null and add defensive checks for optional relationships (#20)
Replace all `null` literals with `none` (valid Jinja2/Python) in all three
templates. Add explicit `is defined and is not none and .node is not none`
guards before accessing nested nodes on optional GraphQL relationships, to
avoid `Undefined is not JSON serializable` errors at render time.

Also add `| default(none)` on optional scalar attributes (speed, mode,
lacp_mode, mlag_id, mtu, description, virtual_router_address,
route_distinguisher, learn_restrict, vlan_type, trunk_groups) so that
Infrahub `Undefined` values from unset optional fields are safely coerced
to JSON null rather than crashing tojson serialization.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-28 17:41:19 +01:00
DamienandClaude Sonnet 4.6 584a4ad5a4 feat: Add Infrahub Jinja2 transforms for VLANs, interfaces, and VXLAN (#20)
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>
2026-02-28 11:00:24 +01:00
Damien ac1634b561 Add device roles to fabric links 2026-02-22 10:07:27 +01:00
DamienandClaude Sonnet 4.6 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 7cd0103d39 Update .gitignore 2026-02-20 18:42:27 +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
Damien b042e13b38 fea(infrahub): Add infrahub configuration 2026-02-20 16:12:07 +01:00