fix: add human_friendly_id to 4 schemas for idempotent Repository sync (#29)

## Summary

- Add `local_identifier` attribute + `uniqueness_constraints` + `human_friendly_id` to **InfraVlanVniMapping**, **InfraEVPNInstance**, **InfraMlagInterface**, and **InfraUnderlayLink**, following the same pattern already used for `InfraBGPPeerGroup` and `InfraBGPSession`
- Populate `local_identifier` in all corresponding object YAML files with deterministic composite keys so Infrahub can upsert objects during Repository backend sync instead of creating duplicates

## Schema changes

| Schema file | Model | human_friendly_id |
|---|---|---|
| `infrahub/schemas/vlan_vxlan.yml` | `InfraVlanVniMapping` | `local_identifier__value` |
| `infrahub/schemas/vlan_vxlan.yml` | `InfraEVPNInstance` | `local_identifier__value` |
| `infrahub/schemas/mlag.yml` | `InfraMlagInterface` | `local_identifier__value` |
| `infrahub/schemas/extensions.yml` | `InfraUnderlayLink` | `local_identifier__value` |

## Object file changes

| Object file | Kind | Key format | Example |
|---|---|---|---|
| `infrahub/objects/06-vlans-vxlan.yml` | `InfraVlanVniMapping` | `{device}__vlan{vlan_id}__vni{vni_id}` | `leaf1__vlan40__vni110040` |
| `infrahub/objects/06-vlans-vxlan.yml` | `InfraEVPNInstance` | `{device}__vlan{vlan_id}` | `leaf1__vlan40` |
| `infrahub/objects/12-mlag.yml` | `InfraMlagInterface` | `mlag{id}__{device1}-{device2}` | `mlag1__leaf1-leaf2` |
| `infrahub/objects/14-fabric-links.yml` | `InfraUnderlayLink` | `{local_dev}-{local_intf}__{remote_dev}-{remote_intf}` | `spine1-eth1__leaf1-eth11` |

Note: `InfraMlagInterface` objects (4 entries, one per MLAG pair) and `InfraUnderlayLink` objects (16 entries, all spine↔leaf P2P links) are new additions to their respective files.

## Test plan

- [x] `infrahubctl schema load infrahub/schemas/*.yml` succeeds without errors
- [x] `infrahubctl object load infrahub/objects/06-vlans-vxlan.yml` succeeds
- [x] `infrahubctl object load infrahub/objects/12-mlag.yml` succeeds
- [x] `infrahubctl object load infrahub/objects/14-fabric-links.yml` succeeds
- [x] Re-running the same load is idempotent (no duplicate objects created)
- [x] Gitea Repository backend sync completes without import errors
This commit was merged in pull request #29.
This commit is contained in:
2026-03-03 16:26:46 +00:00
parent 370782da62
commit 12d927d460
6 changed files with 262 additions and 8 deletions

View File

@@ -116,19 +116,23 @@ spec:
kind: InfraVlanVniMapping
data:
# VLAN 40 <-> VNI 110040 on leaf1/2/5/6 (L2 VXLAN leafs)
- vtep: ["leaf1"]
- local_identifier: leaf1__vlan40__vni110040
vtep: ["leaf1"]
vlan: ["40"]
vni: ["110040"]
description: "VLAN 40 <-> VNI 110040"
- vtep: ["leaf2"]
- local_identifier: leaf2__vlan40__vni110040
vtep: ["leaf2"]
vlan: ["40"]
vni: ["110040"]
description: "VLAN 40 <-> VNI 110040"
- vtep: ["leaf5"]
- local_identifier: leaf5__vlan40__vni110040
vtep: ["leaf5"]
vlan: ["40"]
vni: ["110040"]
description: "VLAN 40 <-> VNI 110040"
- vtep: ["leaf6"]
- local_identifier: leaf6__vlan40__vni110040
vtep: ["leaf6"]
vlan: ["40"]
vni: ["110040"]
description: "VLAN 40 <-> VNI 110040"
@@ -140,26 +144,30 @@ spec:
data:
# EVPN instance for VLAN 40 on L2 VXLAN leafs
# leaf1: rd 65001:110040, rt both 40:110040
- device: ["leaf1"]
- local_identifier: leaf1__vlan40
device: ["leaf1"]
vlan: ["40"]
route_distinguisher: "65001:110040"
route_target_import: "40:110040"
route_target_export: "40:110040"
redistribute_learned: true
- device: ["leaf2"]
- local_identifier: leaf2__vlan40
device: ["leaf2"]
vlan: ["40"]
route_distinguisher: "65001:110040"
route_target_import: "40:110040"
route_target_export: "40:110040"
redistribute_learned: true
# leaf5/6: rd 65003:110040, rt both 40:110040
- device: ["leaf5"]
- local_identifier: leaf5__vlan40
device: ["leaf5"]
vlan: ["40"]
route_distinguisher: "65003:110040"
route_target_import: "40:110040"
route_target_export: "40:110040"
redistribute_learned: true
- device: ["leaf6"]
- local_identifier: leaf6__vlan40
device: ["leaf6"]
vlan: ["40"]
route_distinguisher: "65003:110040"
route_target_import: "40:110040"