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), }