From f7b8438cbd38c95948ba7320cd97efb50bf43c18 Mon Sep 17 00:00:00 2001 From: Daniel Allaire Date: Sat, 4 Jul 2026 22:58:08 -0400 Subject: [PATCH] =?UTF-8?q?nomenclature=20:=20VMID=209=20chiffres=20ip-mir?= =?UTF-8?q?oir=20(opt-in,=20f=C3=A9d=C3=A9ration)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Nouveau schema VMID 'ip-miroir' (vmid_schema dans la nomenclature) : 9 chiffres I·VVV·HHH·NN = index·VLAN·octet-hote·sequence. Le VMID contient l'IP (10.(10+index).VLAN.hote) + le tenant → lecture directe. Defaut 'compact' (retro-compatible) : les instances existantes (lab) gardent leurs VMID. Co-Authored-By: Claude Opus 4.8 --- scripts/inventory_rules.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/scripts/inventory_rules.py b/scripts/inventory_rules.py index d475988..c7fa77d 100644 --- a/scripts/inventory_rules.py +++ b/scripts/inventory_rules.py @@ -325,10 +325,20 @@ def deriver_nomenclature(fonction: str, seq: int, nomenclature: dict) -> dict | # 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) + hote = svc * 10 + int(seq) + # Schema du VMID. 'ip-miroir' (opt-in) : 9 chiffres mnemotechniques encodant + # index + VLAN + octet-hote + sequence -> le VMID contient litteralement l'IP + # (10.(10+index).VLAN.hote) et le tenant. 'compact' (defaut, retro-compatible) : + # index.categorie.service.sequence (largeur variable, VMID des instances existantes). + schema = nomenclature.get("vmid_schema", "compact") + if schema == "ip-miroir": + vmid = f"{index}{int(c.get('vlan', 0)):03d}{hote:03d}{int(seq):02d}" + else: + vmid = f"{index}{cat}{svc}{int(seq):02d}" return { - "vmid": f"{index}{cat}{svc}{int(seq):02d}", + "vmid": vmid, "vlan": c.get("vlan"), - "adresse_ip": f"{base3}.{svc * 10 + int(seq)}", + "adresse_ip": f"{base3}.{hote}", "passerelle": c.get("passerelle"), "cidr": nomenclature.get("cidr_hote", 24), }