From 8029083536c1a7ad4cd5fe0dbdd121424471a361 Mon Sep 17 00:00:00 2001 From: Daniel Allaire Date: Tue, 30 Jun 2026 17:36:01 -0400 Subject: [PATCH] =?UTF-8?q?Adressage=20f=C3=A9d=C3=A9r=C3=A9=20:=20index?= =?UTF-8?q?=20d'instance=20(pr=C3=A9fixe=20VMID=20+=20supernet)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Le VMID n'est plus codé 9CSNN en dur : il prend le préfixe d'un `index` déclaré en tête de plan/nomenclature.yml. Convention : supernet = 10.(index*10).0.0/16, VMID = index·CSNN. Permet à N écosystèmes de coexister sans collision (Chezlepro=1, Technolibre=2). Sans index → 9CSNN (rétro-compatible, bacs à sable en 172.19.x). deriveServeur JS mort retiré. Doc multi-instances.md mise à jour. Co-Authored-By: Claude Opus 4.8 --- CHANGELOG.md | 7 +++++++ docs/multi-instances.md | 24 ++++++++++++++++++++++++ scripts/inventory_gui.py | 7 ------- scripts/inventory_rules.py | 6 +++++- 4 files changed, 36 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 780451a..631dce7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,13 @@ ## 2026-06-30 ### Ajouté +- **Adressage fédéré : index d'instance.** Le VMID n'est plus codé `9CSNN` en dur : + il prend le préfixe d'un `index` déclaré en tête de `plan/nomenclature.yml` + (`{index}{catégorie}{service}{séq}`). Convention : `supernet = 10.(index×10).0.0/16`, + `VMID = index·CSNN`. Permet à N écosystèmes de **coexister/s'interconnecter** sans + collision (Chezlepro=1 → `10.10`/`1xxxx`, Technolibre=2 → `10.20`/`2xxxx`). Sans + index → `9CSNN` (rétro-compatible ; bacs à sable, plages ad-hoc `172.19.x`). + Code mort retiré (`deriveServeur` JS). Voir `docs/multi-instances.md`. - **Doc `docs/multi-instances.md`** : cadrage « un moteur, N écosystèmes » — l'instance comme dépôt autonome, la bascule, l'isolation, et le socle multi-tenant. - **Bascule d'instance (`make instance-utiliser NOM=…`).** Repointe le symlink diff --git a/docs/multi-instances.md b/docs/multi-instances.md index 8ed4bad..99d27f4 100644 --- a/docs/multi-instances.md +++ b/docs/multi-instances.md @@ -88,6 +88,30 @@ moteur, isolé. C'est la base concrète de la **portabilité des tenants**. > (NetBox, AWX, un coffre type Vault HashiCorp) **à adopter aux seuils**, pas à > réimplémenter dans le moteur. Cf. [`positionnement.md`](positionnement.md). +## Adressage fédéré (index d'instance) + +Pour que plusieurs écosystèmes **coexistent et puissent s'interconnecter** sans +collision, chaque instance de production reçoit un **index** (déclaré en tête de +`plan/nomenclature.yml` : `index: N`). Il pilote : + +- le **supernet** : `10.(index × 10).0.0/16` (zéro chevauchement) ; +- le **préfixe VMID** : `index·catégorie·service·séq` (ex. `21101`) au lieu du `9` fixe. + +| Instance | index | Supernet | VMID | +| --- | --- | --- | --- | +| Chezlepro | 1 | `10.10.0.0/16` | `1CSNN` | +| Technolibre | 2 | `10.20.0.0/16` | `2CSNN` | +| … | N | `10.(N×10).0.0/16` | `N·CSNN` | +| Bacs à sable | *(aucun)* | `172.19.x` ad-hoc | `9CSNN` (défaut) | + +Sans `index` déclaré, on retombe sur `9CSNN` (rétro-compatible) : c'est ce qu'utilisent +les **bacs à sable**, qui vivent hors fédération (plages jetables `172.19.x`) et n'ont +pas vocation à s'interconnecter. + +Plafond : un index à 1 chiffre = **9 écosystèmes** prod fédérés (VMID à 5 chiffres) ; +élargir l'index pour davantage. Au-delà d'une poignée d'instances co-localisées, confier +l'allocation à un **IPAM** (NetBox) plutôt qu'au moteur — cf. `positionnement.md`. + ## Voir aussi - [`meta-classe.md`](meta-classe.md) — le plan d'une instance instancie sa flotte. - [`config-proxmox.md`](config-proxmox.md) — voûte unique + cible Proxmox par instance. diff --git a/scripts/inventory_gui.py b/scripts/inventory_gui.py index d3b2969..8083db4 100644 --- a/scripts/inventory_gui.py +++ b/scripts/inventory_gui.py @@ -1231,13 +1231,6 @@ HTML = r""" serveursModifie = false; } - function deriveServeur(nom, fonction) { - const info = infoFonction(fonction); - const seq = fonctionDe(nom).seq; - if (!info || seq == null) return {vmid: '?', ip: '?', vlan: '?'}; - const base3 = info.sous_reseau.split('.').slice(0, 3).join('.'); - return {vmid: '9' + info.categorie + info.service + String(seq).padStart(2, '0'), ip: base3 + '.' + (info.service * 10 + seq), vlan: String(info.vlan)}; - } function marquerServeursModifie() { serveursModifie = true; majIndicateurSauvegarde(); } function choisirServeur(i) { selServeur = i; dessiner(); } diff --git a/scripts/inventory_rules.py b/scripts/inventory_rules.py index a9cad2b..d475988 100644 --- a/scripts/inventory_rules.py +++ b/scripts/inventory_rules.py @@ -321,8 +321,12 @@ def deriver_nomenclature(fonction: str, seq: int, nomenclature: dict) -> dict | if not c: return None base3 = ".".join(str(c.get("sous_reseau", "")).split(".")[:3]) + # Prefixe VMID = index d'instance (federation multi-ecosystemes). Defaut 9 : + # retro-compatible (instances sans index, bacs a sable). 1 chiffre -> 9 instances + # prod federables avec un VMID a 5 chiffres ; elargir l'index pour davantage. + index = nomenclature.get("index", 9) return { - "vmid": f"9{cat}{svc}{int(seq):02d}", + "vmid": f"{index}{cat}{svc}{int(seq):02d}", "vlan": c.get("vlan"), "adresse_ip": f"{base3}.{svc * 10 + int(seq)}", "passerelle": c.get("passerelle"),