carte celeste : la couche 3 des sites et de leurs locataires en une page
make carte rassemble ce que les plans declarent : zones de chaque site, frontiere, tunnels, VRF des locataires (heberges ou en reprise) et l'adresse de chaque machine, en un atlas celeste autonome. Une vue (AGENTS §12) : tout vient de contexte.py et des derivations du moteur, rien n'est saisi ; la page ne mesure rien. - SITE= borne la carte a un site, ses locataires et ses reprises ; - refus d'ecrire dans le moteur public hors de tmp/ : la carte porte des adresses internes ; - polices OFL embarquees : aucun appel exterieur, la page s'ouvre hors ligne ; - ni voute lue, ni cle publique reportee, ni </script> venu d'un plan ; - un underlay.yml monte par lien (le moteur) n'est pas un site. P83 et P31 ont refuse la cible tant qu'elle n'etait ni exemptee de la console (motif ecrit) ni documentee dans docs/usage.md. test_carte_reseaux.py : 9 cas. make verifier : 95 OK, 0 echec. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
a490ba883c
commit
883be725b4
19 changed files with 1741 additions and 2 deletions
21
CHANGELOG.md
21
CHANGELOG.md
|
|
@ -1,3 +1,24 @@
|
|||
## 2026-10-19 (177) — La carte céleste : ce que les plans déclarent, en une page qu'on peut remettre
|
||||
|
||||
**95 preuves.** `make verifier` : 95 OK, 0 échec. Une nouvelle garde, `test_carte_reseaux.py` (9 cas, sur des écosystèmes fictifs aux adresses de documentation), vérifie la collecte, la portée et l'étanchéité de la page.
|
||||
|
||||
**Ce qui manquait.** Personne ne voyait d'un coup d'œil la couche 3 de la flotte : zones de chaque site, frontières et tunnels, VRF des locataires, adresse de chaque machine. L'information existait, mais dispersée dans six fichiers par site et deux par locataire. `make carte` la rassemble en un atlas céleste : la frontière est un astre majeur, chaque zone une nébuleuse, chaque machine une étoile avec son adresse, et chaque site porte le nom de son étoile (`etoiles.domaine_site`). La page sert à livrer un site ou à ouvrir un partenariat.
|
||||
|
||||
**Une vue, pas une fonction (AGENTS §12).** Rien n'est saisi ni déduit. Sites et locataires viennent de `contexte.Site` et `Locataire`. Les sous-réseaux, passerelles, VNet et VNI viennent des dérivations du moteur (`underlay.charger_resolu`, `inventory_rules`, `devis_sdn`). Un locataire paraît hébergé chez son hébergeur actif, et en reprise chez le site qui le déclare aussi. La page dit ce que les plans déclarent ; les devis restent les juges du réel.
|
||||
|
||||
**Le moteur se dessinait en troisième site.** Son `underlay.yml` est le lien qui monte la carte de `SITE-Chezlepro`. Une découverte par `*/underlay.yml` le comptait comme un site, double de celui qu'il monte (mesuré à la première collecte). Une carte montée par lien n'est plus un site ; un cas le garde.
|
||||
|
||||
**Ce que la page ne fuit pas.**
|
||||
|
||||
- Elle porte des adresses internes : `carte_reseaux.py` refuse de l'écrire dans ce dépôt public hors de `tmp/` (code 2). Sa place est le dépôt privé du site, ou la remise en main propre.
|
||||
- `SITE=` la borne à un site, à ses locataires et à ses reprises. Un partenaire reçoit son site, pas les adresses des autres écosystèmes.
|
||||
- Aucune voûte n'est lue, aucune clé publique WireGuard n'est reportée, et un `</script>` venu d'un plan ne ferme pas le script.
|
||||
- Les polices (OFL, sous-ensemble latin, `scripts/carte/polices/`, licences jointes) sont embarquées : la page s'ouvre hors ligne et n'appelle aucun service. Le chargement depuis Google Fonts aurait signalé chaque ouverture d'une livraison.
|
||||
|
||||
**Deux gardes ont fait leur travail.** P83 a refusé une cible documentée qu'aucun runbook ne porte. La carte en est exemptée avec son motif : lancée depuis la console, elle resterait sur le runner, loin de qui doit la remettre. P31 a ensuite refusé une cible absente de `docs/usage.md`.
|
||||
|
||||
**Témoin.** La carte complète des plans du jour porte 2 sites, 2 locataires hébergés, 26 zones et 44 machines ; celle bornée à `SITE-Technolibre`, 9 machines et 2 VRF de reprise. Le même jour, avant ce code, les 44 adresses ont été confrontées au réel depuis le poste : les 18 machines des sites ont déclaré leur nom et leur adresse par SSH, et les 26 des locataires ont répondu au ping.
|
||||
|
||||
## 2026-10-19 (176) — Le site de TechnoLibre déployé sous `achird31`, et ce que le renommage a révélé
|
||||
|
||||
**95 preuves.** `make verifier` : 95 OK, 0 échec. `test_step_ca_identite.py` passe à 5 cas (l'adresse que retient le `step` de l'autorité).
|
||||
|
|
|
|||
9
Makefile
9
Makefile
|
|
@ -337,6 +337,7 @@ test: ## Lance les tests unitaires (derivation de nomenclature et d'inventaire)
|
|||
python3 scripts/tests/test_console_venv.py
|
||||
python3 scripts/tests/test_etoiles.py
|
||||
python3 scripts/tests/test_step_ca_identite.py
|
||||
python3 scripts/tests/test_carte_reseaux.py
|
||||
python3 scripts/tests/test_forge_cles.py
|
||||
python3 scripts/tests/test_devis_placement.py
|
||||
python3 scripts/tests/test_sonder.py
|
||||
|
|
@ -540,6 +541,14 @@ instance-courante: ## Affiche vers quel ecosysteme pointe l'instance active
|
|||
instances: ## Liste les ecosystemes decouverts (dossiers freres) et signale les collisions d'index
|
||||
@python3 scripts/instances.py
|
||||
|
||||
# LA CARTE CELESTE (2026-10-19) : la couche 3 des sites et de leurs locataires en une page
|
||||
# autonome — zones, frontieres, tunnels, VRF, machines et adresses, tirees des plans. Une VUE :
|
||||
# elle ne mesure rien. Elle porte des adresses internes : jamais dans ce depot public (sortie
|
||||
# par defaut dans tmp/, ignore par git) ; sa place est le depot prive du site, ou la remise.
|
||||
.PHONY: carte
|
||||
carte: ## La carte celeste des reseaux (couche 3) en une page autonome — [SITE=<depot>] [VERS=<fichier.html>]
|
||||
@python3 scripts/carte_reseaux.py $(if $(SITE),--site "$(SITE)",) $(if $(VERS),--vers "$(VERS)",)
|
||||
|
||||
# (Re)génère le plan de recette (docs/audit/plan-de-recette.md) depuis les exercices
|
||||
# du wiki. La preuve P22 vérifie qu'il reste à jour.
|
||||
plan-recette: ## Regenere docs/audit/plan-de-recette.md depuis le wiki
|
||||
|
|
|
|||
|
|
@ -1134,6 +1134,10 @@ hors_assistant:
|
|||
racines: >-
|
||||
La vue « Confiance » du GUI la porte deja : racines, empreintes, etat des magasins.
|
||||
Un assistant en serait une seconde copie, qui finirait par dire autre chose.
|
||||
carte: >-
|
||||
Elle ecrit un fichier sur la machine qui l'execute : lancee depuis la console, la carte
|
||||
resterait sur le runner, loin de la personne qui doit la remettre. Elle se fait au
|
||||
poste, qui porte les depots freres et le depot prive du site ou la verser.
|
||||
racines-importer: >-
|
||||
Meme raison, et une de plus : l'import touche les magasins du navigateur LOCAL. La vue
|
||||
« Confiance » le garde (`navigateur-local`) ; un assistant lance depuis un serveur
|
||||
|
|
|
|||
|
|
@ -32,11 +32,11 @@ toujours `set -o pipefail; make … < /dev/null 2>&1 | cat`. Sans tube, l'échec
|
|||
| `GROUPE` | un groupe Ansible (= un playbook de `playbooks/groupes/`) | `deployer-groupe`, `appliquer`, `site-appliquer` |
|
||||
| `TENANT` | le dépôt d'un locataire (`OPS-X`) vu depuis le site | `locataire-creer`, `inseminer`, `placement-plan`, … |
|
||||
| `INSTANCE` | le nom court d'un écosystème, exigé par les cibles destructives | `raser`, `locataire-raser`, `parefeu-*-flotte` |
|
||||
| `SITE` | le dépôt d'un site, exigé par `site-raser` | `site-raser` |
|
||||
| `SITE` | le dépôt d'un site, exigé par `site-raser` ; borne `carte` à ce site | `site-raser`, `carte` |
|
||||
| `CONFIRMER` | `true` pour écrire | toute cible `-appliquer` ou destructive |
|
||||
| `LIMITE` | motif d'hôtes Ansible | `faits`, `verifier-hote` |
|
||||
| `MACHINE` | une seule machine (vide = toutes les machines actives) | `mises-a-jour`, `site-mises-a-jour`, et leur `-appliquer` |
|
||||
| `VERS` | un répertoire de destination (support externe) | `cles-exporter`, `voutes-exporter`, `remise-paquet`, … |
|
||||
| `VERS` | un répertoire de destination (support externe) ; pour `carte`, le fichier HTML à écrire | `cles-exporter`, `voutes-exporter`, `remise-paquet`, `carte`, … |
|
||||
| `DEPOT` | un seul dépôt du génome | `publier`, `genome-pousser` |
|
||||
| `PARALLELE` | nombre de VM créées à la fois | `flotte-creer`, `locataire-creer` |
|
||||
| `NOM`, `MODELE`, `INDEX` | nouvel écosystème | `instance-creer`, `instance-utiliser`, `model-creer` |
|
||||
|
|
@ -136,6 +136,7 @@ documente ses options (`--help`) dans sa docstring.
|
|||
| `make instance-utiliser` | Bascule l'instance active (symlink instance/) vers un dossier frere — NOM=<dossier> |
|
||||
| `make instance-courante` | Affiche vers quel ecosysteme pointe l'instance active |
|
||||
| `make instances` | Liste les ecosystemes decouverts (dossiers freres) et signale les collisions d'index |
|
||||
| `make carte` | La carte céleste des réseaux (couche 3) : chaque site, ses zones, sa frontière, ses tunnels, les VRF de ses locataires et l'adresse de chaque machine, en une page autonome (polices embarquées, aucun appel extérieur). Tirée des plans, elle ne mesure rien. `SITE=<dépôt>` la borne à un site, ses locataires et ses reprises ; `VERS=<fichier.html>` (défaut : `tmp/carte-des-reseaux.html`). Elle porte des adresses internes : refusée dans ce dépôt public hors de `tmp/` |
|
||||
| `make model-creer` | Cree un modele d'ecosysteme — MODE=<mode> NOM=<nom> |
|
||||
| `make genome` | Les depots requis a la reproduction de cet ecosysteme, et leur etat |
|
||||
| `make genome-inscrire` | Inscrit la parente dans l'instance (instance/parente.yml) |
|
||||
|
|
|
|||
766
scripts/carte/gabarit.html
Normal file
766
scripts/carte/gabarit.html
Normal file
|
|
@ -0,0 +1,766 @@
|
|||
<!doctype html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover">
|
||||
<title>Carte céleste des réseaux</title>
|
||||
<!-- GENERE par scripts/carte_reseaux.py (make carte). Ne pas editer : regenerer.
|
||||
Page autonome : polices embarquees (OFL), aucun appel exterieur. Elle porte des adresses
|
||||
internes : ne pas la publier. -->
|
||||
<style>
|
||||
/*__POLICES__*/
|
||||
</style>
|
||||
<style>
|
||||
/* Un atlas céleste : chaque site est une colonne du ciel, sa frontière un astre majeur, ses
|
||||
zones des nébuleuses ; les VRF des locataires sont des bandes sous les hyperviseurs.
|
||||
Un seul monde visuel, la nuit : thème sombre assumé. */
|
||||
:root {
|
||||
color-scheme: dark;
|
||||
--nuit: #0A0E1C;
|
||||
--nuit-2: #121831;
|
||||
--nuit-3: #1B2346;
|
||||
--astre: #F2ECDD;
|
||||
--astre-2:#BEC0D4;
|
||||
--astre-3:#7D83A6;
|
||||
--filet: #2C3560;
|
||||
--or: #F2C878;
|
||||
--site: #8FC4FF;
|
||||
--t0: #7FE3B6;
|
||||
--t1: #E9A3DA;
|
||||
--t2: #F0B37E;
|
||||
--t3: #C8E07A;
|
||||
--tunnel: #B7A2FF;
|
||||
--f-titre: "IM Fell English SC", "IM Fell English", Georgia, serif;
|
||||
--f-orne: "IM Fell English", Georgia, serif;
|
||||
--f-txt: "Spectral", Georgia, "Times New Roman", serif;
|
||||
--f-mono: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
|
||||
}
|
||||
html, body { background: var(--nuit); color: var(--astre); margin: 0; }
|
||||
body { font-family: var(--f-txt); font-size: 16px; line-height: 1.55; -webkit-font-smoothing: antialiased; }
|
||||
.page { max-width: 96rem; margin: 0 auto; padding-inline: clamp(16px, 3vw, 40px); padding-block: clamp(20px, 4vw, 48px) 56px;
|
||||
display: flex; flex-direction: column; gap: 28px; }
|
||||
|
||||
header.tete { display: grid; gap: 10px; max-width: 62rem; }
|
||||
.sur { font-family: var(--f-mono); font-size: .72rem; letter-spacing: .16em; text-transform: uppercase; color: var(--astre-3); }
|
||||
h1 { font-family: var(--f-titre); font-weight: 400; font-size: clamp(2.2rem, 6vw, 4rem); line-height: 1.02; margin: 0;
|
||||
letter-spacing: .01em; text-wrap: balance; }
|
||||
h1 em { font-family: var(--f-orne); font-style: italic; color: var(--or); }
|
||||
.chapeau { font-weight: 300; font-size: 1.12rem; color: var(--astre-2); max-width: 60ch; margin: 0; }
|
||||
.compte { display: flex; flex-wrap: wrap; gap: 8px 18px; font-family: var(--f-mono); font-size: .8rem; color: var(--astre-2); margin-top: 4px; }
|
||||
.compte b { color: var(--astre); font-weight: 400; }
|
||||
|
||||
.ciel { display: flex; flex-direction: column; gap: 10px; }
|
||||
.outils { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
|
||||
.outils label { font-family: var(--f-mono); font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; color: var(--astre-3); }
|
||||
.outils input { flex: 1 1 16rem; min-width: 0; max-width: 26rem; background: var(--nuit-2); border: 1px solid var(--filet); color: var(--astre);
|
||||
font-family: var(--f-mono); font-size: .85rem; padding: 8px 10px; border-radius: 3px; }
|
||||
.outils input::placeholder { color: var(--astre-3); }
|
||||
.outils button { background: var(--nuit-2); border: 1px solid var(--filet); color: var(--astre); font-family: var(--f-mono);
|
||||
font-size: .85rem; padding: 7px 11px; border-radius: 3px; cursor: pointer; min-width: 2.4rem; }
|
||||
.outils button:hover { border-color: var(--or); color: var(--or); }
|
||||
.outils :focus-visible, .registre summary:focus-visible { outline: 2px solid var(--or); outline-offset: 2px; }
|
||||
.outils .trouve { font-family: var(--f-mono); font-size: .78rem; color: var(--astre-3); }
|
||||
.cadre { position: relative; border: 1px solid var(--filet); border-radius: 4px; overflow: hidden; background: var(--nuit);
|
||||
height: min(80vh, 980px); min-height: 420px; touch-action: none; cursor: grab; }
|
||||
.cadre.tire { cursor: grabbing; }
|
||||
.cadre svg { display: block; width: 100%; height: 100%; user-select: none; }
|
||||
.aide { font-family: var(--f-mono); font-size: .72rem; color: var(--astre-3); }
|
||||
|
||||
svg text { font-family: var(--f-txt); fill: var(--astre); }
|
||||
.t-region { font-family: var(--f-titre); fill: var(--astre); opacity: .055; letter-spacing: .18em; }
|
||||
.t-astre { font-family: var(--f-titre); font-size: 26px; fill: var(--or); }
|
||||
.t-astre-s { font-family: var(--f-orne); font-style: italic; font-size: 14px; fill: var(--astre-2); }
|
||||
.t-zone { font-family: var(--f-titre); font-size: 17px; }
|
||||
.t-mono { font-family: var(--f-mono); font-size: 11.5px; fill: var(--astre-2); }
|
||||
.t-mono-f { font-family: var(--f-mono); font-size: 11px; fill: var(--astre-3); }
|
||||
.t-vm { font-size: 13px; fill: var(--astre); }
|
||||
.t-ip { font-family: var(--f-mono); font-size: 11.5px; fill: var(--astre-2); }
|
||||
.t-cart { font-family: var(--f-titre); font-size: 15px; fill: var(--astre); }
|
||||
.t-ligne { font-family: var(--f-orne); font-style: italic; font-size: 13px; fill: var(--astre-2); }
|
||||
.t-horizon { font-family: var(--f-titre); font-size: 15px; letter-spacing: .6em; fill: var(--astre-3); }
|
||||
.t-pub { font-family: var(--f-mono); font-size: 12px; fill: var(--astre); }
|
||||
.t-pub-s { font-family: var(--f-orne); font-style: italic; font-size: 12.5px; fill: var(--astre-3); }
|
||||
|
||||
.fond-etoile { fill: var(--astre); }
|
||||
.rayon { fill: none; stroke: var(--or); stroke-width: 1; opacity: .28; }
|
||||
.trame { fill: none; stroke: var(--astre-3); stroke-width: .8; opacity: .45; }
|
||||
.anycast { fill: none; stroke: var(--site); stroke-width: 1; stroke-dasharray: 2 5; opacity: .5; }
|
||||
.transit { stroke: var(--or); stroke-width: 2; opacity: .55; }
|
||||
.tun { fill: none; stroke: var(--tunnel); stroke-width: 1.6; stroke-dasharray: 6 4; opacity: .85; }
|
||||
.arc-sites { fill: none; stroke: url(#aurore); stroke-width: 3.5; filter: url(#lueur); }
|
||||
.pub-fil { fill: none; stroke: var(--astre-3); stroke-width: .8; stroke-dasharray: 1 4; opacity: .9; }
|
||||
.constel { fill: none; stroke-width: .8; opacity: .45; }
|
||||
.cart-fond { fill: var(--nuit-2); fill-opacity: .82; stroke: var(--filet); stroke-width: 1; }
|
||||
.bande { fill: var(--nuit); fill-opacity: .78; stroke-width: 1.2; }
|
||||
.bande.fantome { fill-opacity: .55; stroke-dasharray: 3 6; }
|
||||
.neb-trait { fill: none; stroke-width: 1; stroke-dasharray: 2 4; opacity: .7; }
|
||||
.vm .glyphe { filter: url(#lueur-f); }
|
||||
.vm:hover .t-vm, .vm:focus .t-vm { fill: var(--or); }
|
||||
.vm:focus { outline: none; }
|
||||
svg.cherche .vm, svg.cherche .neb-titre { opacity: .18; transition: opacity .2s; }
|
||||
svg.cherche .vm.touche { opacity: 1; }
|
||||
svg.cherche .vm.touche .t-vm { fill: var(--or); }
|
||||
svg.cherche .vm.touche .glyphe { transform-box: fill-box; transform-origin: center; transform: scale(1.8); }
|
||||
.aurore-voile { opacity: .26; }
|
||||
@media (prefers-reduced-motion: no-preference) {
|
||||
.aurore-voile { animation: onde 14s ease-in-out infinite alternate; }
|
||||
.scint { animation: scint 5s ease-in-out infinite alternate; }
|
||||
}
|
||||
@keyframes onde { from { opacity: .16; } to { opacity: .34; } }
|
||||
@keyframes scint { from { opacity: .25; } to { opacity: .9; } }
|
||||
|
||||
.registre { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 34rem), 1fr)); gap: 18px; }
|
||||
.registre details { background: var(--nuit-2); border: 1px solid var(--filet); border-radius: 4px; padding: 14px 16px; min-width: 0; }
|
||||
.registre summary { cursor: pointer; list-style: none; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
|
||||
.registre summary::-webkit-details-marker { display: none; }
|
||||
.registre summary h2 { font-family: var(--f-titre); font-weight: 400; font-size: 1.35rem; margin: 0; }
|
||||
.registre summary .meta { font-family: var(--f-mono); font-size: .76rem; color: var(--astre-3); }
|
||||
.registre summary::after { content: "+"; margin-left: auto; color: var(--astre-3); font-family: var(--f-mono); }
|
||||
.registre details[open] summary::after { content: "−"; }
|
||||
.pastille { display: inline-block; width: .7rem; height: .7rem; border-radius: 50%; transform: translateY(1px); }
|
||||
.defile { overflow-x: auto; margin-top: 10px; }
|
||||
table { border-collapse: collapse; width: 100%; font-size: .86rem; font-variant-numeric: tabular-nums; }
|
||||
th { text-align: left; font-family: var(--f-mono); font-weight: 400; font-size: .68rem; letter-spacing: .12em; text-transform: uppercase;
|
||||
color: var(--astre-3); padding: 6px 8px; border-bottom: 1px solid var(--filet); }
|
||||
td { padding: 6px 8px; border-bottom: 1px solid var(--nuit-3); vertical-align: top; }
|
||||
td.m { font-family: var(--f-mono); font-size: .8rem; color: var(--astre-2); white-space: nowrap; }
|
||||
td.z { font-family: var(--f-titre); font-size: .98rem; white-space: nowrap; }
|
||||
td .vmn { white-space: nowrap; }
|
||||
td .vmn + .vmn::before { content: " · "; color: var(--astre-3); }
|
||||
.vmn code { font-family: var(--f-mono); font-size: .78rem; color: var(--astre-2); }
|
||||
.note { font-size: .9rem; color: var(--astre-2); margin: 10px 0 0; }
|
||||
|
||||
footer { display: grid; gap: 8px; font-size: .88rem; color: var(--astre-3); max-width: 75ch; border-top: 1px solid var(--filet); padding-top: 16px; }
|
||||
footer code { font-family: var(--f-mono); font-size: .8rem; color: var(--astre-2); }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="page">
|
||||
<header class="tete">
|
||||
<div class="sur" id="sur"></div>
|
||||
<h1>Carte céleste <em>des réseaux</em></h1>
|
||||
<p class="chapeau" id="chapeau"></p>
|
||||
<div class="compte" id="compte"></div>
|
||||
</header>
|
||||
|
||||
<section class="ciel" aria-label="Carte des réseaux">
|
||||
<div class="outils">
|
||||
<label for="q">Chercher</label>
|
||||
<input id="q" type="search" placeholder="un nom ou une adresse : dns, 10.17.19, mon-01…" autocomplete="off">
|
||||
<span class="trouve" id="trouve" aria-live="polite"></span>
|
||||
<button type="button" id="zplus" aria-label="Rapprocher">+</button>
|
||||
<button type="button" id="zmoins" aria-label="Éloigner">−</button>
|
||||
<button type="button" id="zfit" aria-label="Voir tout le ciel">Tout</button>
|
||||
<button type="button" id="zplein" aria-label="Plein écran">Plein écran</button>
|
||||
</div>
|
||||
<div class="cadre" id="cadre"><svg id="ciel" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="Plan de la couche 3 : sites, locataires, zones, machines et adresses"></svg></div>
|
||||
<div class="aide">Glisser pour se déplacer · molette ou +/− pour s'approcher · Entrée dans la recherche centre la première étoile trouvée · survoler une étoile donne son VMID et son nœud.</div>
|
||||
</section>
|
||||
|
||||
<section class="registre" id="registre" aria-label="Registre des adresses"></section>
|
||||
|
||||
<footer id="pied"></footer>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
const D = __DONNEES__;
|
||||
const NS = "http://www.w3.org/2000/svg";
|
||||
const svg = document.getElementById("ciel");
|
||||
|
||||
// --- outils de dessin ----------------------------------------------------------------------
|
||||
function el(tag, attrs, parent) {
|
||||
const e = document.createElementNS(NS, tag);
|
||||
for (const k in attrs) if (attrs[k] !== undefined && attrs[k] !== null) e.setAttribute(k, attrs[k]);
|
||||
(parent || svg).appendChild(e);
|
||||
return e;
|
||||
}
|
||||
function tx(x, y, s, cls, parent, anchor) {
|
||||
const t = el("text", { x, y, class: cls, "text-anchor": anchor || "middle" }, parent);
|
||||
t.textContent = s;
|
||||
return t;
|
||||
}
|
||||
function surChemin(id, texte, cls, dy, parent) {
|
||||
const t = el("text", { class: cls, dy }, parent);
|
||||
const p = el("textPath", { href: "#" + id, startOffset: "50%", "text-anchor": "middle" }, t);
|
||||
p.textContent = texte;
|
||||
}
|
||||
const oct = ip => "." + String(ip || "").split("/")[0].split(".").pop();
|
||||
const esc = s => String(s ?? "").replace(/[&<>"]/g, c => ({ "&": "&", "<": "<", ">": ">", '"': """ }[c]));
|
||||
const majuscule = s => s ? s.charAt(0).toUpperCase() + s.slice(1) : s;
|
||||
const nomEtoile = s => majuscule(String(s.etoile || "").replace(/\d+$/, ""));
|
||||
function etoile4(x, y, r) {
|
||||
const k = r * 0.22;
|
||||
return `M${x},${y - r} Q${x + k},${y - k} ${x + r},${y} Q${x + k},${y + k} ${x},${y + r} Q${x - k},${y + k} ${x - r},${y} Q${x - k},${y - k} ${x},${y - r}Z`;
|
||||
}
|
||||
function etoile8(x, y, r) {
|
||||
let d = "";
|
||||
for (let i = 0; i < 16; i++) {
|
||||
const a = -Math.PI / 2 + i * Math.PI / 8;
|
||||
const rr = i % 2 ? r * 0.22 : (i % 4 ? r * 0.55 : r);
|
||||
d += (i ? "L" : "M") + (x + rr * Math.cos(a)).toFixed(1) + "," + (y + rr * Math.sin(a)).toFixed(1);
|
||||
}
|
||||
return d + "Z";
|
||||
}
|
||||
function enLignes(items, max) {
|
||||
const out = []; let cur = "";
|
||||
for (const it of items) {
|
||||
if (cur && (cur + " · " + it).length > max) { out.push(cur); cur = it; }
|
||||
else cur = cur ? cur + " · " + it : it;
|
||||
}
|
||||
if (cur) out.push(cur);
|
||||
return out;
|
||||
}
|
||||
|
||||
// --- vocabulaire --------------------------------------------------------------------------
|
||||
const NOMS_ZONE = { pilotage: "Pilotage", autorite: "Autorité", genome: "Génome", service: "Service",
|
||||
sauvegarde: "Sauvegarde", supervision: "Supervision", publication: "Publication" };
|
||||
const nomZone = n => { const k = String(n).replace(/^site-/, ""); return NOMS_ZONE[k] || majuscule(k); };
|
||||
const NOMS_TZONE = { Frontiere: "Frontière", Identite: "Identité", Donnees: "Données", Observabilite: "Observabilité" };
|
||||
const nomTZone = l => NOMS_TZONE[l] || l;
|
||||
const COURT = { "transit-frontiere": "transit", "underlay-vxlan": "vxlan", management: "mgmt", "grappe-controle": "grappe" };
|
||||
const court = n => COURT[n] || n;
|
||||
|
||||
// Une teinte par locataire, la même partout où il paraît (hébergé ou repris).
|
||||
const nomsLoc = [...new Set(D.sites.flatMap(s => [...s.locataires, ...s.reprises].map(t => t.nom)))].sort();
|
||||
const teinte = nom => "t" + (nomsLoc.indexOf(nom) % 4);
|
||||
|
||||
// --- géométrie ------------------------------------------------------------------------------
|
||||
const CW = 104, RH = 56, CORRIDOR = 150, GAP_Z = 16, GAP_T = 26, FY = 330, MARGE = 40, ECART = 110;
|
||||
function taille(n) {
|
||||
const cols = n <= 1 ? 1 : 2, rows = Math.max(1, Math.ceil(n / 2));
|
||||
return { cols, rows, w: cols === 1 ? 140 : 230, h: rows === 1 ? 100 : 156 };
|
||||
}
|
||||
const largeurCart = c => Math.min(470, Math.max(300, Math.max(c.titre.length * 7.6, ...c.lignes.map(l => l.length * 7)) + 34));
|
||||
const hauteurCart = c => 30 + c.lignes.length * 17;
|
||||
|
||||
function ranger(zones, cible) {
|
||||
const rangs = []; let cur = [], w = 0;
|
||||
for (const z of zones) {
|
||||
const zw = taille(z.vms.length).w;
|
||||
if (cur.length && w + GAP_Z + zw + CORRIDOR > cible) { rangs.push(cur); cur = []; w = 0; }
|
||||
w += (cur.length ? GAP_Z : 0) + zw; cur.push(z);
|
||||
}
|
||||
if (cur.length) rangs.push(cur);
|
||||
return rangs.map(r => {
|
||||
const larg = zs => zs.reduce((a, z) => a + taille(z.vms.length).w, 0) + Math.max(0, zs.length - 1) * GAP_Z;
|
||||
let meilleur = null;
|
||||
for (let k = 0; k <= r.length; k++) {
|
||||
const wl = larg(r.slice(0, k)), wr = larg(r.slice(k));
|
||||
if (!meilleur || Math.abs(wl - wr) < meilleur.ecart - 0.1) meilleur = { k, wl, wr, ecart: Math.abs(wl - wr) };
|
||||
}
|
||||
return { gauche: r.slice(0, meilleur.k), droite: r.slice(meilleur.k), wl: meilleur.wl, wr: meilleur.wr,
|
||||
h: Math.max(...r.map(z => taille(z.vms.length).h)) };
|
||||
});
|
||||
}
|
||||
|
||||
function cartFabric(f, s) {
|
||||
const hs = f.hotes.map(h => `${h.nom} ${oct(h.ip)}${h.etat === "reserve" ? " (réserve)" : ""}`);
|
||||
return { titre: `${f.nom} · ${f.sous_reseau || "—"}`, couleur: f.tunnel ? "var(--tunnel)" : "var(--or)",
|
||||
lignes: [`${f.tunnel ? "WireGuard" : (f.vlan ? "VLAN " + f.vlan : "non étiqueté")}${f.mtu ? " · MTU " + f.mtu : ""}`, ...enLignes(hs, 46)] };
|
||||
}
|
||||
function cartAdmins(s) {
|
||||
const a = s.admins;
|
||||
const arrivee = s.publiques.length ? [`point d'arrivée : ${s.publiques[0].ip}:${a.port}`] : [];
|
||||
return { titre: `admins · ${a.reseau}`, couleur: "var(--tunnel)",
|
||||
lignes: [`WireGuard :${a.port}${a.mtu ? " · MTU " + a.mtu : ""}`,
|
||||
...enLignes([`${s.frontiere} ${oct(a.frontiere)}`, ...a.pairs.map(p => `${p.nom} ${oct(p.adresse)}`)], 46), ...arrivee] };
|
||||
}
|
||||
function cartTunnels(s) {
|
||||
const l = [];
|
||||
s.locataires.filter(t => t.tunnel && t.tunnel.reseau).forEach(t => {
|
||||
l.push(`${t.tunnel.reseau} :${t.tunnel.port} · ${t.nom}`);
|
||||
l.push(...enLignes(t.tunnel.pairs.map(p => `${p.nom} ${oct(p.adresse)}`), 42).map(x => " " + x));
|
||||
});
|
||||
return { titre: "tunnels des locataires", couleur: "var(--tunnel)", lignes: l };
|
||||
}
|
||||
|
||||
// 1. Chaque colonne se mesure seule.
|
||||
const cols = D.sites.map((s, i) => {
|
||||
const c = { s, i };
|
||||
// Les cartouches vont du côté libre : à l'opposé du relais (toujours dessiné à gauche des
|
||||
// adresses), sinon à l'opposé du site pair. Un pair absent de la carte part du côté libre.
|
||||
const pairs = s.liens.map(l => D.sites.findIndex(x => x.nom === l.pair.site)).filter(j => j >= 0);
|
||||
const pairReel = pairs.length ? (pairs.some(j => j < i) ? -1 : 1) : 0;
|
||||
c.coteCart = s.relais ? 1 : (pairReel ? -pairReel : -1);
|
||||
c.cotePair = pairReel || -c.coteCart;
|
||||
c.cartsSousArc = c.cotePair === c.coteCart;
|
||||
const seulsHyp = f => f.hotes.length && f.hotes.every(h => h.role === "hyperviseur");
|
||||
c.hautes = s.fabric.filter(f => !f.transit && f.fabric !== "stockage" && !seulsHyp(f)).map(f => cartFabric(f, s));
|
||||
if (s.admins) c.hautes.push(cartAdmins(s));
|
||||
c.basses = s.locataires.some(t => t.tunnel && t.tunnel.reseau) ? [cartTunnels(s)] : [];
|
||||
const stock = s.fabric.filter(f => f.fabric === "stockage");
|
||||
c.cartStock = stock.length ? { titre: `fabric de stockage${stock[0].mtu ? " · MTU " + stock[0].mtu : ""}`, couleur: "var(--astre-3)",
|
||||
lignes: stock.map(f => `${f.nom} · VLAN ${f.vlan} · ${f.sous_reseau}`) } : null;
|
||||
c.cartSdn = s.sdn && s.sdn.controleur ? { titre: `SDN ${s.sdn.controleur}`, couleur: "var(--site)",
|
||||
lignes: [`ASN ${s.sdn.asn}`, "un VRF par locataire", "passerelle .1 anycast", "sur chaque hyperviseur"] } : null;
|
||||
const wH = Math.max(0, ...c.hautes.map(largeurCart)), wB = Math.max(0, ...c.basses.map(largeurCart));
|
||||
const wS = c.cartStock ? largeurCart(c.cartStock) : 0, wD = c.cartSdn ? largeurCart(c.cartSdn) : 0;
|
||||
c.wH = wH; c.wB = wB; c.wS = wS; c.wD = wD;
|
||||
const tw = t => t.zones.reduce((a, z) => a + taille(z.vms.length).w, 0) + (t.zones.length - 1) * GAP_T + 80;
|
||||
c.largT = Math.max(0, ...s.locataires.map(tw));
|
||||
c.rangs = ranger(s.zones, Math.max(1000, c.largT));
|
||||
const nH = Math.max(1, s.hyperviseurs.length);
|
||||
c.pasH = 300;
|
||||
const demiH = (nH - 1) * c.pasH / 2 + 95;
|
||||
const nPub = s.publiques.length;
|
||||
c.largPub = (s.relais ? 190 : 0) + Math.max(0, nPub - 1) * 150;
|
||||
const ext = [
|
||||
[210 + (c.coteCart < 0 ? wH : 0), 210 + (c.coteCart > 0 ? wH : 0)],
|
||||
[c.coteCart > 0 ? 210 + wB : 0, c.coteCart < 0 ? 210 + wB : 0],
|
||||
...c.rangs.map(r => [CORRIDOR / 2 + r.wl, CORRIDOR / 2 + r.wr]),
|
||||
[c.largT / 2, c.largT / 2],
|
||||
[demiH + (wS ? wS + 30 : 0), demiH + (wD ? wD + 30 : 0)],
|
||||
[c.largPub / 2 + 90, c.largPub / 2 + 90],
|
||||
[s.reprises.length ? 470 : 0, s.reprises.length ? 470 : 0],
|
||||
[520, 520],
|
||||
];
|
||||
c.extG = Math.max(...ext.map(e => e[0])); c.extD = Math.max(...ext.map(e => e[1]));
|
||||
return c;
|
||||
});
|
||||
|
||||
// 2. Les colonnes se posent côte à côte ; chacune déroule son ciel de haut en bas.
|
||||
let xCourant = MARGE;
|
||||
cols.forEach(c => {
|
||||
c.gauche = xCourant; c.cx = xCourant + c.extG; c.droite = c.cx + c.extD; xCourant = c.droite + ECART;
|
||||
let y = c.cartsSousArc ? FY + 40 : 186;
|
||||
c.posHautes = c.hautes.map(k => { const p = { x: c.coteCart < 0 ? c.cx - 210 - c.wH : c.cx + 210, y, w: c.wH }; y += hauteurCart(k) + 10; return p; });
|
||||
const basHautes = y;
|
||||
y = FY + 40;
|
||||
c.posBasses = c.basses.map(k => { const p = { x: c.coteCart > 0 ? c.cx - 210 - c.wB : c.cx + 210, y, w: c.wB }; y += hauteurCart(k) + 10; return p; });
|
||||
const basBasses = y;
|
||||
let yt = Math.max(FY + 160, basHautes + 50, basBasses + 50);
|
||||
c.yRangs = c.rangs.map(r => { const cy = yt + 46 + r.h / 2; yt = cy + r.h / 2 + 40; return cy; });
|
||||
c.TY = yt + 40;
|
||||
c.HY = c.TY + 66;
|
||||
const lignesH = Math.max(1, ...c.s.hyperviseurs.map(h => Object.keys(h.adresses).length + 1));
|
||||
const basHyp = c.HY + 10 + 34 + lignesH * 15;
|
||||
const basCarts = c.TY - 42 + Math.max(c.cartStock ? hauteurCart(c.cartStock) : 0, c.cartSdn ? hauteurCart(c.cartSdn) : 0);
|
||||
y = Math.max(basHyp, basCarts) + 46;
|
||||
c.bandes = c.s.locataires.map(t => {
|
||||
const rangs = rangerT(t.zones, c.droite - c.gauche - 60);
|
||||
const h = 64 + rangs.reduce((a, r) => a + 50 + r.h, 0) + 14;
|
||||
const b = { t, y, h, rangs }; y += h + 24; return b;
|
||||
});
|
||||
c.fantomes = c.s.reprises.map(t => {
|
||||
const h = Math.max(112, 34 + Math.ceil(t.zones.length / 3) * 40 + 18);
|
||||
const b = { t, y, h }; y += h + 22; return b;
|
||||
});
|
||||
c.bas = y;
|
||||
});
|
||||
function rangerT(zones, largeur) {
|
||||
const rangs = []; let cur = [], w = 0;
|
||||
for (const z of zones) {
|
||||
const zw = taille(z.vms.length).w;
|
||||
if (cur.length && w + GAP_T + zw > largeur) { rangs.push(cur); cur = []; w = 0; }
|
||||
w += (cur.length ? GAP_T : 0) + zw; cur.push(z);
|
||||
}
|
||||
if (cur.length) rangs.push(cur);
|
||||
return rangs.map(r => ({ zones: r, w: r.reduce((a, z) => a + taille(z.vms.length).w, 0) + (r.length - 1) * GAP_T,
|
||||
h: Math.max(...r.map(z => taille(z.vms.length).h)) }));
|
||||
}
|
||||
|
||||
// La légende va sous la colonne la plus courte, si elle y tient ; sinon sous tout le ciel.
|
||||
const LEG = { w: 900, h: 190 };
|
||||
const plusCourte = cols.reduce((a, c) => (!a || c.bas < a.bas ? c : a), null);
|
||||
const W = (cols.length ? cols[cols.length - 1].droite : 900) + MARGE;
|
||||
let legende;
|
||||
if (plusCourte && plusCourte.droite - plusCourte.gauche >= LEG.w) {
|
||||
legende = { x: plusCourte.gauche + (plusCourte.droite - plusCourte.gauche - LEG.w) / 2, y: plusCourte.bas + 8 };
|
||||
} else {
|
||||
legende = { x: MARGE, y: Math.max(0, ...cols.map(c => c.bas)) + 10 };
|
||||
}
|
||||
const H = Math.max(legende.y + LEG.h + 30, ...cols.map(c => c.bas + 20));
|
||||
|
||||
// --- 3. dessin ------------------------------------------------------------------------------
|
||||
const defs = el("defs", {});
|
||||
defs.innerHTML = `
|
||||
<linearGradient id="aurore" x1="0" x2="1" y1="0" y2="0">
|
||||
<stop offset="0" stop-color="var(--t0)"/><stop offset=".5" stop-color="var(--tunnel)"/><stop offset="1" stop-color="var(--t1)"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="voile" x1="0" x2="0" y1="0" y2="1">
|
||||
<stop offset="0" stop-color="var(--t0)" stop-opacity="0"/><stop offset=".45" stop-color="var(--t0)" stop-opacity=".55"/>
|
||||
<stop offset="1" stop-color="var(--tunnel)" stop-opacity="0"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="voile2" x1="0" x2="0" y1="0" y2="1">
|
||||
<stop offset="0" stop-color="var(--t1)" stop-opacity="0"/><stop offset=".5" stop-color="var(--tunnel)" stop-opacity=".5"/>
|
||||
<stop offset="1" stop-color="var(--tunnel)" stop-opacity="0"/>
|
||||
</linearGradient>
|
||||
<radialGradient id="voie" cx=".5" cy=".5" r=".5">
|
||||
<stop offset="0" stop-color="var(--nuit-3)" stop-opacity=".9"/><stop offset="1" stop-color="var(--nuit)" stop-opacity="0"/>
|
||||
</radialGradient>
|
||||
${["site", "t0", "t1", "t2", "t3"].map(c => `
|
||||
<radialGradient id="neb-${c}" cx=".5" cy=".55" r=".55">
|
||||
<stop offset="0" stop-color="var(--${c})" stop-opacity=".22"/><stop offset=".6" stop-color="var(--${c})" stop-opacity=".08"/>
|
||||
<stop offset="1" stop-color="var(--${c})" stop-opacity="0"/>
|
||||
</radialGradient>`).join("")}
|
||||
<filter id="lueur" x="-20%" y="-50%" width="140%" height="200%">
|
||||
<feGaussianBlur stdDeviation="4" result="b"/><feMerge><feMergeNode in="b"/><feMergeNode in="SourceGraphic"/></feMerge>
|
||||
</filter>
|
||||
<filter id="lueur-f" x="-200%" y="-200%" width="500%" height="500%">
|
||||
<feGaussianBlur stdDeviation="2.2" result="b"/><feMerge><feMergeNode in="b"/><feMergeNode in="SourceGraphic"/></feMerge>
|
||||
</filter>
|
||||
<filter id="flou-large"><feGaussianBlur stdDeviation="28"/></filter>`;
|
||||
const monde = el("g", { id: "monde" });
|
||||
|
||||
// Le fond : voie lactée, champ d'étoiles (tirage fixe : la même carte donne le même ciel), aurore.
|
||||
(function fond() {
|
||||
const g = el("g", { "aria-hidden": "true" }, monde);
|
||||
el("rect", { x: -600, y: -600, width: W + 1200, height: H + 1200, fill: "var(--nuit)" }, g);
|
||||
el("ellipse", { cx: W * .52, cy: H * .55, rx: W * .7, ry: 260, fill: "url(#voie)", transform: `rotate(-14 ${W * .52} ${H * .55})` }, g);
|
||||
let s = 31037;
|
||||
const alea = () => (s = (s * 16807) % 2147483647) / 2147483647;
|
||||
const n = Math.round(W * H / 5800);
|
||||
for (let i = 0; i < n; i++) {
|
||||
const x = alea() * W, y = alea() * H, r = alea() < .93 ? alea() * .9 + .25 : alea() * 1.4 + 1;
|
||||
const c = el("circle", { cx: x.toFixed(1), cy: y.toFixed(1), r: r.toFixed(2), class: "fond-etoile", opacity: (alea() * .55 + .15).toFixed(2) }, g);
|
||||
if (i % 23 === 0) { c.setAttribute("class", "fond-etoile scint"); c.style.animationDelay = (alea() * 5).toFixed(2) + "s"; }
|
||||
}
|
||||
const a = el("g", { class: "aurore-voile", filter: "url(#flou-large)" }, g);
|
||||
el("path", { d: `M-50,40 C ${W * .17},180 ${W * .33},-20 ${W * .5},110 S ${W * .83},10 ${W + 50},120 L ${W + 50},240 C ${W * .78},150 ${W * .62},250 ${W * .45},200 S ${W * .12},260 -50,170Z`, fill: "url(#voile)" }, a);
|
||||
el("path", { d: `M${W * .12},0 C ${W * .29},120 ${W * .54},40 ${W * .7},140 S ${W * .95},60 ${W},90 L ${W},180 C ${W * .87},160 ${W * .7},240 ${W * .54},150 S ${W * .25},190 ${W * .12},90Z`, fill: "url(#voile2)" }, a);
|
||||
})();
|
||||
|
||||
// L'horizon : au-dessus, Internet et les adresses publiques.
|
||||
el("path", { d: `M0,168 Q ${W / 2},118 ${W},168`, fill: "none", stroke: "var(--astre-3)", "stroke-width": .8, opacity: .5 }, monde);
|
||||
tx(W / 2, 40, "INTERNET", "t-horizon", monde);
|
||||
tx(W / 2, 60, "au-dessus de l'horizon, les adresses publiques", "t-pub-s", monde);
|
||||
|
||||
// Le nom de chaque site, en filigrane.
|
||||
cols.forEach(c => {
|
||||
if (!c.yRangs.length) return;
|
||||
const t = tx(c.cx, c.yRangs[c.yRangs.length - 1] + 120, `${nomEtoile(c.s).toUpperCase()} ${c.s.index}`, "t-region", monde);
|
||||
t.setAttribute("font-size", Math.round(Math.min(150, (c.droite - c.gauche) / 7)));
|
||||
});
|
||||
|
||||
const etoilesVM = [];
|
||||
function nebuleuse(z, cx, cy, coul, titre, sous, ecosys, porteur) {
|
||||
const t = taille(z.vms.length);
|
||||
const g = el("g", { class: "neb" }, monde);
|
||||
el("ellipse", { cx, cy, rx: t.w / 2 + 6, ry: t.h / 2 + 4, fill: `url(#neb-${coul})` }, g);
|
||||
el("ellipse", { cx, cy, rx: t.w / 2, ry: t.h / 2, class: "neb-trait", stroke: `var(--${coul})` }, g);
|
||||
const top = cy - t.h / 2;
|
||||
const gt = el("g", { class: "neb-titre" }, g);
|
||||
tx(cx, top - 40, titre, "t-zone", gt).setAttribute("fill", `var(--${coul})`);
|
||||
tx(cx, top - 23, sous[0], "t-mono-f", gt);
|
||||
tx(cx, top - 9, sous[1], "t-mono-f", gt);
|
||||
const pos = z.vms.map((v, i) => {
|
||||
const row = Math.floor(i / 2), col = i % 2;
|
||||
const seul = (z.vms.length % 2 === 1) && i === z.vms.length - 1;
|
||||
return [t.cols === 1 || seul ? cx : cx + (col ? CW / 2 : -CW / 2), cy - (t.rows - 1) * RH / 2 + row * RH];
|
||||
});
|
||||
if (pos.length > 1) el("path", { d: "M" + pos.map(p => `${p[0]},${p[1] - 11}`).join(" L"), class: "constel", stroke: `var(--${coul})` }, g);
|
||||
z.vms.forEach((v, i) => {
|
||||
const [x, y] = pos[i];
|
||||
const gv = el("g", { class: "vm", tabindex: 0 }, g);
|
||||
gv.dataset.k = `${v.nom} ${v.ip} ${ecosys} ${titre}`.toLowerCase();
|
||||
gv.dataset.x = x; gv.dataset.y = y;
|
||||
el("title", {}, gv).textContent = `${v.nom} — ${v.ip}\n${ecosys} · zone ${titre}\nVMID ${v.vmid ?? "—"} · nœud ${v.noeud ?? "—"}\npasserelle ${z.passerelle} (${porteur})`;
|
||||
const gl = el("g", { class: "glyphe" }, gv);
|
||||
el("path", { d: etoile4(x, y - 11, 8), fill: `var(--${coul})` }, gl);
|
||||
el("circle", { cx: x, cy: y - 11, r: 1.8, fill: "var(--astre)" }, gl);
|
||||
tx(x, y + 8, v.nom, "t-vm", gv);
|
||||
tx(x, y + 22, v.ip, "t-ip", gv);
|
||||
etoilesVM.push(gv);
|
||||
});
|
||||
}
|
||||
function cartouche(p, c) {
|
||||
const g = el("g", {}, monde);
|
||||
const h = hauteurCart(c);
|
||||
el("rect", { x: p.x, y: p.y, width: p.w, height: h, rx: 3, class: "cart-fond" }, g);
|
||||
el("rect", { x: p.x, y: p.y, width: 3, height: h, fill: c.couleur, opacity: .8 }, g);
|
||||
tx(p.x + 14, p.y + 20, c.titre, "t-cart", g, "start");
|
||||
c.lignes.forEach((l, i) => tx(p.x + 14, p.y + 38 + i * 17, l, "t-mono", g, "start"));
|
||||
return { ...p, h };
|
||||
}
|
||||
function astre(x, y, nom, sous) {
|
||||
const g = el("g", {}, monde);
|
||||
el("circle", { cx: x, cy: y, r: 34, fill: "var(--or)", opacity: .08 }, g);
|
||||
el("circle", { cx: x, cy: y, r: 18, fill: "var(--or)", opacity: .14 }, g);
|
||||
el("path", { d: etoile8(x, y, 26), fill: "var(--or)", filter: "url(#lueur)" }, g);
|
||||
el("circle", { cx: x, cy: y, r: 3.5, fill: "var(--astre)" }, g);
|
||||
tx(x, y + 52, nom, "t-astre", g);
|
||||
sous.forEach((s, i) => tx(x, y + 72 + i * 17, s, i ? "t-mono-f" : "t-astre-s", g));
|
||||
}
|
||||
function petitAstre(x, y, nom, lignes, couleur, r) {
|
||||
const g = el("g", {}, monde);
|
||||
el("circle", { cx: x, cy: y, r: r + 8, fill: couleur, opacity: .1 }, g);
|
||||
el("path", { d: etoile8(x, y, r), fill: couleur, filter: "url(#lueur-f)" }, g);
|
||||
tx(x, y + r + 18, nom, "t-cart", g);
|
||||
lignes.forEach((s, i) => tx(x, y + r + 34 + i * 15, s, "t-mono-f", g));
|
||||
}
|
||||
|
||||
// Les liens entre les sites : un arc d'aurore entre deux frontières de la carte, ou un départ
|
||||
// vers un site qu'elle ne montre pas.
|
||||
cols.forEach(c => c.s.liens.forEach((l, k) => {
|
||||
const j = cols.findIndex(o => o.s.nom === l.pair.site);
|
||||
if (j >= 0 && j < c.i) return; // dessiné depuis l'autre bout
|
||||
const id = `lien-${c.i}-${k}`;
|
||||
const reciproque = j >= 0 ? cols[j].s.liens.find(m => m.pair.site === c.s.nom) : null;
|
||||
const initie = l.pair.point_arrivee ? `${l.local.nom} l'initie vers ${l.pair.point_arrivee}`
|
||||
: (reciproque && reciproque.pair.point_arrivee ? `${reciproque.local.nom} l'initie vers ${reciproque.pair.point_arrivee}` : "");
|
||||
const sous = [l.dns_public ? "réplication du DNS public" : "", initie].filter(Boolean).join(" · ");
|
||||
if (j >= 0) {
|
||||
const o = cols[j], ax = c.cx + 30, bx = o.cx - 30, d = bx - ax, hy = 200 - 30 * (j - c.i - 1);
|
||||
el("path", { d: `M${ax},${FY - 10} C ${ax + d * .3},${hy} ${bx - d * .4},${hy} ${bx},${FY - 10}`, class: "arc-sites", id }, monde);
|
||||
tx(ax + 16, FY - 30, oct(l.local.ip), "t-mono", monde, "start");
|
||||
tx(bx - 10, FY + 4, oct(l.pair.ip), "t-mono", monde, "end");
|
||||
} else {
|
||||
const s = c.cotePair, bx = c.cx + s * ((s > 0 ? c.extD : c.extG) - 20), ax = c.cx + s * 30;
|
||||
el("path", { d: `M${ax},${FY - 10} C ${ax + s * 200},${210} ${bx - s * 160},${210} ${bx},${200}`, class: "arc-sites", id }, monde);
|
||||
tx(bx, 186, `vers ${l.pair.site} · ${l.pair.nom} ${oct(l.pair.ip)}`, "t-ligne", monde, s > 0 ? "end" : "start");
|
||||
tx(ax + s * 16, FY - 30, oct(l.local.ip), "t-mono", monde, s > 0 ? "start" : "end");
|
||||
}
|
||||
surChemin(id, `inter-sites · ${l.sous_reseau} · WireGuard${l.mtu ? " · MTU " + l.mtu : ""}`, "t-ligne", -10, monde);
|
||||
if (sous) surChemin(id, sous, "t-mono-f", 20, monde);
|
||||
}));
|
||||
|
||||
cols.forEach(c => {
|
||||
const s = c.s, cx = c.cx;
|
||||
|
||||
// Les adresses publiques du site, et le relais s'il les lui apporte.
|
||||
const nP = s.publiques.length;
|
||||
let x0 = cx - c.largPub / 2;
|
||||
const nomsHeberges = new Set(s.locataires.map(t => t.nom)), nomsRepris = new Set(s.reprises.map(t => t.nom));
|
||||
const quoi = p => p.pour === s.nom ? ["site" + (s.dns_public_nom && p === s.publiques[0] ? " · " + s.dns_public_nom : ""), false]
|
||||
: p.pour === "libre" ? ["libre", true]
|
||||
: nomsRepris.has(p.pour) && !nomsHeberges.has(p.pour) ? ["reprise · " + p.pour, false] : [p.pour, false];
|
||||
if (s.relais) {
|
||||
const rx = x0, ry = 98;
|
||||
petitAstre(rx, ry, s.relais.nom, [`console ${s.relais.console}`], "var(--tunnel)", 11);
|
||||
x0 += 190;
|
||||
const id = `relais-${c.i}`;
|
||||
el("path", { d: `M${rx + 8},${ry + 34} C ${rx + 120},${ry + 170} ${cx - 160},${FY - 120} ${cx - 26},${FY - 14}`, class: "tun", id }, monde);
|
||||
surChemin(id, `${s.relais.nom} · ${s.relais.sous_reseau}${s.relais.mtu ? " · MTU " + s.relais.mtu : ""}`, "t-ligne", -6, monde);
|
||||
tx(rx + 34, ry + 84, oct(s.relais.ip), "t-mono", monde, "start");
|
||||
tx(cx - 50, FY - 34, oct(s.relais.ip_frontiere), "t-mono", monde, "end");
|
||||
tx(x0 + (nP - 1) * 75, 152, `relayées par ${s.relais.nom} jusqu'à ${s.frontiere}`, "t-pub-s", monde);
|
||||
}
|
||||
s.publiques.forEach((p, i) => {
|
||||
const x = x0 + i * 150, y = 98, [legende, libre] = quoi(p);
|
||||
const vers = s.relais ? `M${x - 6},${y} Q ${(x + x0 - 190) / 2},${y + 30} ${x0 - 176},${y}` : `M${x},${y + 8} Q ${(x + cx) / 2},${(y + FY) / 2 - 10} ${cx},${FY - 30}`;
|
||||
el("path", { d: vers, class: "pub-fil", opacity: libre ? .35 : .9 }, monde);
|
||||
el("path", { d: etoile4(x, y, libre ? 5 : 7), fill: libre ? "var(--astre-3)" : (s.relais ? "var(--tunnel)" : "var(--or)"), filter: "url(#lueur-f)" }, monde);
|
||||
tx(x, y - 16, p.ip, "t-pub", monde).setAttribute("opacity", libre ? .55 : 1);
|
||||
tx(x, y + 26, legende, "t-pub-s", monde);
|
||||
});
|
||||
|
||||
// Les rayons de la frontière vers ses zones, puis les zones.
|
||||
const poser = (r, cy, dessin) => {
|
||||
let x = cx - CORRIDOR / 2;
|
||||
for (let i = r.gauche.length - 1; i >= 0; i--) { const w = taille(r.gauche[i].vms.length).w; dessin(r.gauche[i], x - w / 2, cy); x -= w + GAP_Z; }
|
||||
x = cx + CORRIDOR / 2;
|
||||
for (const z of r.droite) { const w = taille(z.vms.length).w; dessin(z, x + w / 2, cy); x += w + GAP_Z; }
|
||||
};
|
||||
c.rangs.forEach((r, k) => poser(r, c.yRangs[k], (z, zx, zy) =>
|
||||
el("path", { d: `M${cx},${FY + 30} Q ${(cx + zx) / 2},${FY + 70} ${zx},${zy - r.h / 2 - 52}`, class: "rayon" }, monde)));
|
||||
c.rangs.forEach((r, k) => poser(r, c.yRangs[k], (z, zx, zy) =>
|
||||
nebuleuse(z, zx, zy, "site", nomZone(z.nom), [z.sous_reseau, `VLAN ${z.vlan}`], s.nom, s.frontiere)));
|
||||
|
||||
const dom = s.domaine && s.domaine !== s.etoile ? `${s.domaine} → ${s.etoile}` : s.etoile;
|
||||
astre(cx, FY, s.frontiere, [`${s.opnsense ? "OPNsense · " : ""}frontière de ${s.nom}`, `${dom} · .1 sur ${s.zones.length} zones`]);
|
||||
|
||||
c.hautes.forEach((k, n) => { const p = cartouche(c.posHautes[n], k);
|
||||
const bord = c.coteCart < 0 ? p.x + p.w : p.x;
|
||||
el("path", { d: `M${bord},${p.y + p.h / 2} Q ${bord - c.coteCart * 110},${p.y + p.h / 2} ${cx + c.coteCart * 34},${FY}`, class: "trame" }, monde); });
|
||||
c.basses.forEach((k, n) => { const p = cartouche(c.posBasses[n], k);
|
||||
const bord = c.coteCart > 0 ? p.x + p.w : p.x;
|
||||
el("path", { d: `M${bord},${p.y + p.h / 2} Q ${bord + c.coteCart * 90},${p.y + 20} ${cx - c.coteCart * 34},${FY + 6}`, class: "trame" }, monde); });
|
||||
|
||||
// Le transit et les hyperviseurs.
|
||||
const TY = c.TY, HY = c.HY;
|
||||
const xT0 = c.gauche + (c.wS ? c.wS + 30 : 60), xT1 = c.droite - (c.wD ? c.wD + 30 : 60);
|
||||
el("line", { x1: xT0, y1: TY, x2: xT1, y2: TY, class: "transit" }, monde);
|
||||
el("line", { x1: cx, y1: FY + 100, x2: cx, y2: TY, class: "transit", "stroke-dasharray": "2 5" }, monde);
|
||||
if (s.transit.nom) tx(xT0 + 8, TY - 8, `${s.transit.nom} · VLAN ${s.transit.vlan} · ${s.transit.sous_reseau}`, "t-ligne", monde, "start");
|
||||
tx(cx + 8, TY - 8, `${oct(s.transit.sortie)} ${s.frontiere}`, "t-mono", monde, "start");
|
||||
const ft = s.fabric.find(f => f.transit);
|
||||
const autres = ft ? ft.hotes.filter(h => h.role === "frontiere" && h.nom !== s.frontiere) : [];
|
||||
if (autres.length) tx(xT1 - 4, TY + 18, autres.map(h => `${h.nom} ${oct(h.ip)}${h.etat === "reserve" ? " (réserve)" : ""}`).join(" · "), "t-mono-f", monde, "end");
|
||||
const n = s.hyperviseurs.length;
|
||||
const sorties = (s.sdn && s.sdn.noeuds_de_sortie) || [];
|
||||
c.xHyp = s.hyperviseurs.map((h, k) => cx + (k - (n - 1) / 2) * c.pasH);
|
||||
s.hyperviseurs.forEach((h, k) => {
|
||||
const x = c.xHyp[k];
|
||||
el("line", { x1: x, y1: TY, x2: x, y2: HY - 14, class: "transit", opacity: .4 }, monde);
|
||||
const role = sorties.includes(h.nom) ? (n === 1 ? "sortie unique" : h.nom === s.sdn.sortie_primaire ? "sortie primaire" : "sortie") : "";
|
||||
petitAstre(x, HY, h.nom, [...Object.entries(h.adresses).map(([r, ip]) => `${court(r)} ${ip}`), role].filter(Boolean), "var(--site)", 10);
|
||||
});
|
||||
if (c.cartStock) cartouche({ x: c.gauche, y: TY - 42, w: c.wS }, c.cartStock);
|
||||
if (c.cartSdn) cartouche({ x: c.droite - c.wD, y: TY - 42, w: c.wD }, c.cartSdn);
|
||||
|
||||
// Les VRF des locataires hébergés.
|
||||
c.bandes.forEach(b => {
|
||||
const t = b.t, coul = teinte(t.nom), g = el("g", {}, monde);
|
||||
c.xHyp.forEach(x => el("path", { d: `M${x},${HY + 60} C ${x},${b.y - 30} ${x},${b.y - 30} ${x + (cx - x) * .15},${b.y}`, class: "anycast" }, g));
|
||||
el("rect", { x: c.gauche, y: b.y, width: c.droite - c.gauche, height: b.h, rx: 26, class: "bande", stroke: `var(--${coul})`, "stroke-opacity": .55 }, g);
|
||||
const tt = tx(c.gauche + 26, b.y + 32, `VRF ${t.vrf}`, "t-zone", g, "start"); tt.setAttribute("fill", `var(--${coul})`); tt.setAttribute("font-size", 22);
|
||||
tx(c.gauche + 120, b.y + 32, `${t.nom} · ${t.domaine} · ${t.supernet} · VNI ${t.vni}`, "t-mono", g, "start");
|
||||
const droite = [t.ip_publique ? `face publique ${t.ip_publique}` : "", t.dns_public && t.dns_public.primaire ? `DNS public ${t.dns_public.primaire}:${t.dns_public.port}` : ""].filter(Boolean).join(" · ");
|
||||
if (droite) tx(c.droite - 24, b.y + 52, droite, "t-mono-f", g, "end");
|
||||
let y = b.y + 64;
|
||||
b.rangs.forEach(r => {
|
||||
const cy = y + 50 + r.h / 2;
|
||||
let x = cx - r.w / 2;
|
||||
r.zones.forEach(z => {
|
||||
const w = taille(z.vms.length).w;
|
||||
nebuleuse(z, x + w / 2, cy, coul, nomTZone(z.libelle), [z.sous_reseau, `${z.vnet} · VNI ${z.tag}`], t.nom, "anycast " + t.vrf);
|
||||
x += w + GAP_T;
|
||||
});
|
||||
y = cy + r.h / 2;
|
||||
});
|
||||
});
|
||||
|
||||
// Les VRF que ce site peut reprendre : réservées, rien n'y tourne.
|
||||
c.fantomes.forEach(b => {
|
||||
const t = b.t, coul = teinte(t.nom), g = el("g", {}, monde);
|
||||
c.xHyp.forEach(x => el("path", { d: `M${x},${HY + 60} C ${x},${b.y - 20} ${x},${b.y - 20} ${x + (cx - x) * .2},${b.y}`, class: "anycast", opacity: .35 }, g));
|
||||
el("rect", { x: c.gauche, y: b.y, width: c.droite - c.gauche, height: b.h, rx: 22, class: "bande fantome", stroke: `var(--${coul})`, "stroke-opacity": .5 }, g);
|
||||
const tt = tx(c.gauche + 26, b.y + 32, `VRF ${t.vrf} · reprise`, "t-zone", g, "start"); tt.setAttribute("fill", `var(--${coul})`); tt.setAttribute("opacity", .75);
|
||||
tx(c.gauche + 26, b.y + 56, `${t.nom} · ${t.supernet} · mêmes zones, mêmes adresses`, "t-mono", g, "start");
|
||||
tx(c.gauche + 26, b.y + 78, `aucune machine en temps normal${t.ip_publique ? " · face publique de reprise " + t.ip_publique : ""}`, "t-mono-f", g, "start");
|
||||
t.zones.forEach((sr, i) => {
|
||||
const x = c.droite - 3 * 120 + 40 + (i % 3) * 120, y = b.y + 34 + Math.floor(i / 3) * 40;
|
||||
el("ellipse", { cx: x, cy: y, rx: 52, ry: 15, fill: `url(#neb-${coul})`, stroke: `var(--${coul})`, "stroke-opacity": .35, "stroke-dasharray": "2 4" }, g);
|
||||
tx(x, y + 4, sr.replace(".0/24", ""), "t-mono-f", g);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// La légende.
|
||||
(function () {
|
||||
const { x: x0, y: y0 } = legende, g = el("g", {}, monde);
|
||||
el("rect", { x: x0, y: y0, width: LEG.w, height: LEG.h, rx: 4, class: "cart-fond" }, g);
|
||||
tx(x0 + 22, y0 + 28, "Légende", "t-cart", g, "start");
|
||||
const items = [["astre", "var(--or)", "frontière : porte le .1 de chaque zone de son site"], ["e4", "var(--site)", "machine d'un site · zone en bleu"],
|
||||
...nomsLoc.map(n => ["e4", `var(--${teinte(n)})`, `machine de ${n}`]),
|
||||
["tun", "", "tunnel WireGuard"], ["tr", "", "transit : la seule sortie des VRF"], ["any", "", "passerelle anycast du SDN"], ["arc", "", "lien entre les sites"]];
|
||||
items.forEach(([k, c, s], i) => {
|
||||
const x = x0 + 30 + (i % 2) * 440, y = y0 + 58 + Math.floor(i / 2) * 28;
|
||||
if (k === "astre") el("path", { d: etoile8(x, y - 4, 10), fill: c }, g);
|
||||
if (k === "e4") el("path", { d: etoile4(x, y - 4, 7), fill: c }, g);
|
||||
if (k === "tun") el("line", { x1: x - 14, y1: y - 4, x2: x + 14, y2: y - 4, class: "tun" }, g);
|
||||
if (k === "tr") el("line", { x1: x - 14, y1: y - 4, x2: x + 14, y2: y - 4, class: "transit" }, g);
|
||||
if (k === "any") el("line", { x1: x - 14, y1: y - 4, x2: x + 14, y2: y - 4, class: "anycast", opacity: 1 }, g);
|
||||
if (k === "arc") el("rect", { x: x - 14, y: y - 6, width: 28, height: 4, rx: 2, fill: "url(#aurore)" }, g);
|
||||
tx(x + 26, y, s, "t-mono", g, "start");
|
||||
});
|
||||
})();
|
||||
|
||||
// --- 4. vue : déplacement et zoom ---------------------------------------------------------
|
||||
const cadre = document.getElementById("cadre");
|
||||
let vb = { x: 0, y: 0, w: W, h: H };
|
||||
const poserVue = () => svg.setAttribute("viewBox", `${vb.x} ${vb.y} ${vb.w} ${vb.h}`);
|
||||
function toutVoir() {
|
||||
const r = cadre.getBoundingClientRect(), ratio = r.width / Math.max(1, r.height);
|
||||
if (ratio > W / H) { vb.h = H; vb.w = H * ratio; vb.x = (W - vb.w) / 2; vb.y = 0; }
|
||||
else { vb.w = W; vb.h = W / ratio; vb.x = 0; vb.y = (H - vb.h) / 2; }
|
||||
poserVue();
|
||||
}
|
||||
function zoom(f, px, py) {
|
||||
const r = cadre.getBoundingClientRect();
|
||||
const fx = px === undefined ? .5 : (px - r.left) / r.width, fy = py === undefined ? .5 : (py - r.top) / r.height;
|
||||
const nw = Math.min(Math.max(vb.w * f, 240), W * 2.2), nh = nw * vb.h / vb.w;
|
||||
vb.x += (vb.w - nw) * fx; vb.y += (vb.h - nh) * fy; vb.w = nw; vb.h = nh;
|
||||
poserVue();
|
||||
}
|
||||
function centrer(x, y, largeur) {
|
||||
const r = cadre.getBoundingClientRect();
|
||||
vb.w = largeur; vb.h = largeur * r.height / Math.max(1, r.width); vb.x = x - vb.w / 2; vb.y = y - vb.h / 2;
|
||||
poserVue();
|
||||
}
|
||||
cadre.addEventListener("wheel", e => { e.preventDefault(); zoom(e.deltaY > 0 ? 1.15 : 1 / 1.15, e.clientX, e.clientY); }, { passive: false });
|
||||
let tire = null;
|
||||
cadre.addEventListener("pointerdown", e => { tire = { x: e.clientX, y: e.clientY, vx: vb.x, vy: vb.y }; cadre.setPointerCapture(e.pointerId); cadre.classList.add("tire"); });
|
||||
cadre.addEventListener("pointermove", e => {
|
||||
if (!tire) return;
|
||||
const r = cadre.getBoundingClientRect();
|
||||
vb.x = tire.vx - (e.clientX - tire.x) * vb.w / r.width; vb.y = tire.vy - (e.clientY - tire.y) * vb.h / r.height;
|
||||
poserVue();
|
||||
});
|
||||
const lacher = () => { tire = null; cadre.classList.remove("tire"); };
|
||||
cadre.addEventListener("pointerup", lacher);
|
||||
cadre.addEventListener("pointercancel", lacher);
|
||||
cadre.addEventListener("dblclick", e => zoom(1 / 1.8, e.clientX, e.clientY));
|
||||
document.getElementById("zplus").onclick = () => zoom(1 / 1.3);
|
||||
document.getElementById("zmoins").onclick = () => zoom(1.3);
|
||||
document.getElementById("zfit").onclick = toutVoir;
|
||||
document.getElementById("zplein").onclick = () => { const p = cadre.requestFullscreen ? cadre.requestFullscreen() : null; if (p && p.catch) p.catch(() => {}); };
|
||||
document.addEventListener("fullscreenchange", () => setTimeout(toutVoir, 60));
|
||||
window.addEventListener("resize", toutVoir);
|
||||
toutVoir();
|
||||
|
||||
// --- 5. recherche ----------------------------------------------------------------------------
|
||||
const q = document.getElementById("q"), trouve = document.getElementById("trouve");
|
||||
q.addEventListener("input", () => {
|
||||
const s = q.value.trim().toLowerCase(); let n = 0;
|
||||
etoilesVM.forEach(g => { const ok = !!s && g.dataset.k.includes(s); g.classList.toggle("touche", ok); if (ok) n++; });
|
||||
svg.classList.toggle("cherche", !!s);
|
||||
trouve.textContent = s ? (n ? `${n} étoile${n > 1 ? "s" : ""}` : "aucune étoile") : "";
|
||||
});
|
||||
q.addEventListener("keydown", e => {
|
||||
if (e.key !== "Enter") return;
|
||||
const h = etoilesVM.find(g => g.classList.contains("touche"));
|
||||
if (h) centrer(+h.dataset.x, +h.dataset.y, 900);
|
||||
});
|
||||
|
||||
// --- 6. registre, en-tête, pied ------------------------------------------------------------------
|
||||
const reg = document.getElementById("registre");
|
||||
function bloc(titre, meta, coul, lignes, note) {
|
||||
const d = document.createElement("details");
|
||||
d.open = true;
|
||||
d.innerHTML = `<summary><span class="pastille" style="background:var(--${coul})"></span><h2>${esc(titre)}</h2><span class="meta">${esc(meta)}</span></summary>
|
||||
<div class="defile"><table><thead><tr><th>Zone</th><th>Réseau</th><th>Sous-réseau</th><th>Passerelle</th><th>Machines</th></tr></thead>
|
||||
<tbody>${lignes.map(l => `<tr><td class="z">${esc(l[0])}</td><td class="m">${esc(l[1])}</td><td class="m">${esc(l[2])}</td><td class="m">${esc(l[3])}</td>
|
||||
<td>${l[4].map(v => `<span class="vmn">${esc(v.nom)} <code>${esc(v.ip)}</code></span>`).join("")}</td></tr>`).join("")}</tbody></table></div>
|
||||
${note ? `<p class="note">${esc(note)}</p>` : ""}`;
|
||||
reg.appendChild(d);
|
||||
}
|
||||
D.sites.forEach(s => {
|
||||
const l = s.zones.map(z => [nomZone(z.nom), `VLAN ${z.vlan}`, z.sous_reseau, `${z.passerelle} ${s.frontiere}`, z.vms]);
|
||||
s.fabric.forEach(f => l.push([f.nom, f.tunnel ? "WireGuard" : (f.vlan ? `VLAN ${f.vlan}` : "non étiqueté"), f.sous_reseau || "—", f.mtu ? `MTU ${f.mtu}` : "",
|
||||
f.hotes.map(h => ({ nom: h.nom + (h.etat === "reserve" ? " (réserve)" : ""), ip: h.ip }))]));
|
||||
s.liens.forEach(k => l.push(["inter-sites", "WireGuard", k.sous_reseau, k.mtu ? `MTU ${k.mtu}` : "",
|
||||
[{ nom: k.local.nom, ip: k.local.ip }, { nom: `${k.pair.nom} (${k.pair.site})`, ip: k.pair.ip }]]));
|
||||
if (s.relais) l.push([s.relais.nom, "WireGuard", s.relais.sous_reseau, s.relais.mtu ? `MTU ${s.relais.mtu}` : "",
|
||||
[{ nom: s.relais.nom, ip: s.relais.ip }, { nom: s.frontiere, ip: s.relais.ip_frontiere }]]);
|
||||
if (s.admins) l.push(["admins", `WireGuard :${s.admins.port}`, s.admins.reseau, s.admins.mtu ? `MTU ${s.admins.mtu}` : "",
|
||||
[{ nom: s.frontiere, ip: s.admins.frontiere }, ...s.admins.pairs.map(p => ({ nom: p.nom, ip: p.adresse }))]]);
|
||||
const pub = s.publiques.map(p => `${p.ip} (${p.pour})`).join(", ");
|
||||
const note = [pub ? `Adresses publiques${s.relais ? `, relayées par ${s.relais.nom} (${s.relais.console})` : ""} : ${pub}.` : "",
|
||||
s.sdn && s.sdn.controleur ? `SDN ${s.sdn.controleur}, ASN ${s.sdn.asn}, nœuds ${s.noeuds.join(", ")}.` : "",
|
||||
s.reprises.length ? `Peut reprendre : ${s.reprises.map(t => `${t.nom} (${t.vrf}, ${t.supernet})`).join(", ")}.` : "",
|
||||
s.absents.length ? `Déclarés sans dépôt frère : ${s.absents.join(", ")}.` : ""].filter(Boolean).join(" ");
|
||||
bloc(`Site ${nomEtoile(s)} · ${s.nom}`, `index ${s.index} · ${s.domaine} · ${s.frontiere}`, "site", l, note);
|
||||
s.locataires.forEach(t => bloc(`Locataire ${t.nom}`, `VRF ${t.vrf} · VNI ${t.vni} · ${t.supernet} · ${t.domaine}`, teinte(t.nom),
|
||||
t.zones.map(z => [nomTZone(z.libelle), `${z.vnet} · ${z.tag}`, z.sous_reseau, `${z.passerelle} anycast`, z.vms]),
|
||||
[`Hébergé par ${s.nom}.`, t.ip_publique ? `Face publique ${t.ip_publique}.` : "",
|
||||
t.tunnel && t.tunnel.reseau ? `Tunnel d'administration ${t.tunnel.reseau}, port ${t.tunnel.port} : ${t.tunnel.pairs.map(p => `${p.nom} ${p.adresse}`).join(", ") || "aucun pair"}.` : "",
|
||||
t.dns_public && t.dns_public.primaire ? `DNS public primaire ${t.dns_public.primaire}:${t.dns_public.port} (${(t.dns_public.zones || []).join(", ")}).` : ""].filter(Boolean).join(" ")));
|
||||
});
|
||||
|
||||
const tous = D.sites.flatMap(s => [s, ...s.locataires]);
|
||||
const nVM = tous.reduce((a, g) => a + g.zones.reduce((b, z) => b + z.vms.length, 0), 0);
|
||||
const nZ = tous.reduce((a, g) => a + g.zones.length, 0);
|
||||
const nLoc = D.sites.reduce((a, s) => a + s.locataires.length, 0);
|
||||
const bordure = [...D.sites.map(s => s.frontiere), ...D.sites.filter(s => s.relais).map(s => s.relais.nom)];
|
||||
const nHyp = D.sites.reduce((a, s) => a + s.hyperviseurs.length, 0);
|
||||
document.getElementById("sur").textContent = `Couche 3 · ${D.portee ? D.portee + " et ses locataires" : "tous les sites"} · plans du ${D.date}`;
|
||||
document.getElementById("chapeau").textContent = "Chaque frontière y est un astre majeur, chaque zone une nébuleuse, chaque machine une étoile qui porte son adresse. "
|
||||
+ (D.sites.length > 1 ? "Chaque site porte le nom de son étoile : " : "Le site porte le nom de son étoile : ")
|
||||
+ D.sites.map(s => `${nomEtoile(s)} pour l'index ${s.index}`).join(", ") + ".";
|
||||
const pl = (n, s, p) => `<span><b>${n}</b> ${n > 1 ? p : s}</span>`;
|
||||
document.getElementById("compte").innerHTML = pl(D.sites.length, "site", "sites") + pl(nLoc, "locataire hébergé", "locataires hébergés")
|
||||
+ pl(nZ, "zone", "zones") + pl(nVM, "machine virtuelle", "machines virtuelles")
|
||||
+ `<span><b>${bordure.length}</b> routeurs de bordure : ${esc(bordure.join(", "))}</span>` + pl(nHyp, "hyperviseur", "hyperviseurs");
|
||||
const transitsPartages = [...new Set(D.sites.map(s => s.transit.sous_reseau).filter((sr, i, t) => sr && t.indexOf(sr) !== i))];
|
||||
const provenance = [...D.sites, ...D.sites.flatMap(s => s.locataires)].map(g => `<code>${esc(g.nom)}@${esc(g.commit || "?")}</code>`);
|
||||
document.getElementById("pied").innerHTML = `
|
||||
<div>Tiré des dépôts le ${esc(D.date)}, sans saisie à la main : ${provenance.join(", ")}. Un <code>+</code> signale un dépôt qui portait des modifications non commitées.</div>
|
||||
<div>Cette carte dit ce que les plans déclarent ; elle ne mesure rien. Le réel se confronte par <code>make underlay-plan</code>, <code>make sdn-plan</code> et <code>make frontiere-plan</code>.</div>
|
||||
${D.portee ? `<div>Portée : ${esc(D.portee)}, ses locataires et ses reprises. Les autres sites n'y figurent pas.</div>` : ""}
|
||||
${(D.hors_carte || []).length ? `<div>Hors de la carte : ${D.hors_carte.map(h => `<code>${esc(h.nom)}</code> (index ${esc(h.index)}, ${esc(h.raison)})`).join(", ")}.</div>` : ""}
|
||||
${transitsPartages.length ? `<div>${esc(transitsPartages.join(", "))} : même adresse de transit sur plusieurs sites. Chaque site a le sien ; ils ne se voient jamais, seuls les tunnels inter-sites relient les sites.</div>` : ""}
|
||||
<div>Généré par <code>make carte</code> (Set-OPS). Elle porte des adresses internes : la remettre en main propre, ou la verser au dépôt privé du site.</div>`;
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
15
scripts/carte/polices/LICENCES.md
Normal file
15
scripts/carte/polices/LICENCES.md
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
# Polices de la carte céleste
|
||||
|
||||
Embarquées par `scripts/carte_reseaux.py` dans chaque carte, pour qu'elle s'ouvre hors ligne
|
||||
et n'appelle aucun service. Toutes sont libres, sous **SIL Open Font License 1.1** ; le texte
|
||||
de chaque licence, avec son avis de droit d'auteur, est dans le fichier `OFL-*.txt` voisin.
|
||||
|
||||
Sous-ensemble **latin** seulement (français compris), au format WOFF2, tel que le distribue
|
||||
Google Fonts. Relevé le 2026-10-19.
|
||||
|
||||
| Fichier | Famille | Licence |
|
||||
|---|---|---|
|
||||
| `imfellenglishsc-400.woff2` | IM Fell English SC — Igino Marini | `OFL-imfellenglishsc.txt` |
|
||||
| `imfellenglish-italic-400.woff2` | IM Fell English, italique — Igino Marini | `OFL-imfellenglish.txt` |
|
||||
| `spectral-300.woff2`, `spectral-italic-300.woff2`, `spectral-400.woff2`, `spectral-600.woff2` | Spectral — Production Type | `OFL-spectral.txt` |
|
||||
| `jetbrainsmono-400.woff2` | JetBrains Mono — JetBrains | `OFL-jetbrainsmono.txt` |
|
||||
93
scripts/carte/polices/OFL-imfellenglish.txt
Normal file
93
scripts/carte/polices/OFL-imfellenglish.txt
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
Copyright (c) 2010, Igino Marini (mail@iginomarini.com)
|
||||
|
||||
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
||||
This license is copied below, and is also available with a FAQ at:
|
||||
http://scripts.sil.org/OFL
|
||||
|
||||
|
||||
-----------------------------------------------------------
|
||||
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
||||
-----------------------------------------------------------
|
||||
|
||||
PREAMBLE
|
||||
The goals of the Open Font License (OFL) are to stimulate worldwide
|
||||
development of collaborative font projects, to support the font creation
|
||||
efforts of academic and linguistic communities, and to provide a free and
|
||||
open framework in which fonts may be shared and improved in partnership
|
||||
with others.
|
||||
|
||||
The OFL allows the licensed fonts to be used, studied, modified and
|
||||
redistributed freely as long as they are not sold by themselves. The
|
||||
fonts, including any derivative works, can be bundled, embedded,
|
||||
redistributed and/or sold with any software provided that any reserved
|
||||
names are not used by derivative works. The fonts and derivatives,
|
||||
however, cannot be released under any other type of license. The
|
||||
requirement for fonts to remain under this license does not apply
|
||||
to any document created using the fonts or their derivatives.
|
||||
|
||||
DEFINITIONS
|
||||
"Font Software" refers to the set of files released by the Copyright
|
||||
Holder(s) under this license and clearly marked as such. This may
|
||||
include source files, build scripts and documentation.
|
||||
|
||||
"Reserved Font Name" refers to any names specified as such after the
|
||||
copyright statement(s).
|
||||
|
||||
"Original Version" refers to the collection of Font Software components as
|
||||
distributed by the Copyright Holder(s).
|
||||
|
||||
"Modified Version" refers to any derivative made by adding to, deleting,
|
||||
or substituting -- in part or in whole -- any of the components of the
|
||||
Original Version, by changing formats or by porting the Font Software to a
|
||||
new environment.
|
||||
|
||||
"Author" refers to any designer, engineer, programmer, technical
|
||||
writer or other person who contributed to the Font Software.
|
||||
|
||||
PERMISSION & CONDITIONS
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
||||
redistribute, and sell modified and unmodified copies of the Font
|
||||
Software, subject to the following conditions:
|
||||
|
||||
1) Neither the Font Software nor any of its individual components,
|
||||
in Original or Modified Versions, may be sold by itself.
|
||||
|
||||
2) Original or Modified Versions of the Font Software may be bundled,
|
||||
redistributed and/or sold with any software, provided that each copy
|
||||
contains the above copyright notice and this license. These can be
|
||||
included either as stand-alone text files, human-readable headers or
|
||||
in the appropriate machine-readable metadata fields within text or
|
||||
binary files as long as those fields can be easily viewed by the user.
|
||||
|
||||
3) No Modified Version of the Font Software may use the Reserved Font
|
||||
Name(s) unless explicit written permission is granted by the corresponding
|
||||
Copyright Holder. This restriction only applies to the primary font name as
|
||||
presented to the users.
|
||||
|
||||
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
||||
Software shall not be used to promote, endorse or advertise any
|
||||
Modified Version, except to acknowledge the contribution(s) of the
|
||||
Copyright Holder(s) and the Author(s) or with their explicit written
|
||||
permission.
|
||||
|
||||
5) The Font Software, modified or unmodified, in part or in whole,
|
||||
must be distributed entirely under this license, and must not be
|
||||
distributed under any other license. The requirement for fonts to
|
||||
remain under this license does not apply to any document created
|
||||
using the Font Software.
|
||||
|
||||
TERMINATION
|
||||
This license becomes null and void if any of the above conditions are
|
||||
not met.
|
||||
|
||||
DISCLAIMER
|
||||
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
||||
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
||||
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
||||
OTHER DEALINGS IN THE FONT SOFTWARE.
|
||||
93
scripts/carte/polices/OFL-imfellenglishsc.txt
Normal file
93
scripts/carte/polices/OFL-imfellenglishsc.txt
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
Copyright (c) 2010, Igino Marini (mail@iginomarini.com)
|
||||
|
||||
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
||||
This license is copied below, and is also available with a FAQ at:
|
||||
http://scripts.sil.org/OFL
|
||||
|
||||
|
||||
-----------------------------------------------------------
|
||||
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
||||
-----------------------------------------------------------
|
||||
|
||||
PREAMBLE
|
||||
The goals of the Open Font License (OFL) are to stimulate worldwide
|
||||
development of collaborative font projects, to support the font creation
|
||||
efforts of academic and linguistic communities, and to provide a free and
|
||||
open framework in which fonts may be shared and improved in partnership
|
||||
with others.
|
||||
|
||||
The OFL allows the licensed fonts to be used, studied, modified and
|
||||
redistributed freely as long as they are not sold by themselves. The
|
||||
fonts, including any derivative works, can be bundled, embedded,
|
||||
redistributed and/or sold with any software provided that any reserved
|
||||
names are not used by derivative works. The fonts and derivatives,
|
||||
however, cannot be released under any other type of license. The
|
||||
requirement for fonts to remain under this license does not apply
|
||||
to any document created using the fonts or their derivatives.
|
||||
|
||||
DEFINITIONS
|
||||
"Font Software" refers to the set of files released by the Copyright
|
||||
Holder(s) under this license and clearly marked as such. This may
|
||||
include source files, build scripts and documentation.
|
||||
|
||||
"Reserved Font Name" refers to any names specified as such after the
|
||||
copyright statement(s).
|
||||
|
||||
"Original Version" refers to the collection of Font Software components as
|
||||
distributed by the Copyright Holder(s).
|
||||
|
||||
"Modified Version" refers to any derivative made by adding to, deleting,
|
||||
or substituting -- in part or in whole -- any of the components of the
|
||||
Original Version, by changing formats or by porting the Font Software to a
|
||||
new environment.
|
||||
|
||||
"Author" refers to any designer, engineer, programmer, technical
|
||||
writer or other person who contributed to the Font Software.
|
||||
|
||||
PERMISSION & CONDITIONS
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
||||
redistribute, and sell modified and unmodified copies of the Font
|
||||
Software, subject to the following conditions:
|
||||
|
||||
1) Neither the Font Software nor any of its individual components,
|
||||
in Original or Modified Versions, may be sold by itself.
|
||||
|
||||
2) Original or Modified Versions of the Font Software may be bundled,
|
||||
redistributed and/or sold with any software, provided that each copy
|
||||
contains the above copyright notice and this license. These can be
|
||||
included either as stand-alone text files, human-readable headers or
|
||||
in the appropriate machine-readable metadata fields within text or
|
||||
binary files as long as those fields can be easily viewed by the user.
|
||||
|
||||
3) No Modified Version of the Font Software may use the Reserved Font
|
||||
Name(s) unless explicit written permission is granted by the corresponding
|
||||
Copyright Holder. This restriction only applies to the primary font name as
|
||||
presented to the users.
|
||||
|
||||
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
||||
Software shall not be used to promote, endorse or advertise any
|
||||
Modified Version, except to acknowledge the contribution(s) of the
|
||||
Copyright Holder(s) and the Author(s) or with their explicit written
|
||||
permission.
|
||||
|
||||
5) The Font Software, modified or unmodified, in part or in whole,
|
||||
must be distributed entirely under this license, and must not be
|
||||
distributed under any other license. The requirement for fonts to
|
||||
remain under this license does not apply to any document created
|
||||
using the Font Software.
|
||||
|
||||
TERMINATION
|
||||
This license becomes null and void if any of the above conditions are
|
||||
not met.
|
||||
|
||||
DISCLAIMER
|
||||
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
||||
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
||||
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
||||
OTHER DEALINGS IN THE FONT SOFTWARE.
|
||||
93
scripts/carte/polices/OFL-jetbrainsmono.txt
Normal file
93
scripts/carte/polices/OFL-jetbrainsmono.txt
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
Copyright 2020 The JetBrains Mono Project Authors (https://github.com/JetBrains/JetBrainsMono)
|
||||
|
||||
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
||||
|
||||
This license is copied below, and is also available with a FAQ at: https://scripts.sil.org/OFL
|
||||
|
||||
|
||||
-----------------------------------------------------------
|
||||
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
||||
-----------------------------------------------------------
|
||||
|
||||
PREAMBLE
|
||||
The goals of the Open Font License (OFL) are to stimulate worldwide
|
||||
development of collaborative font projects, to support the font creation
|
||||
efforts of academic and linguistic communities, and to provide a free and
|
||||
open framework in which fonts may be shared and improved in partnership
|
||||
with others.
|
||||
|
||||
The OFL allows the licensed fonts to be used, studied, modified and
|
||||
redistributed freely as long as they are not sold by themselves. The
|
||||
fonts, including any derivative works, can be bundled, embedded,
|
||||
redistributed and/or sold with any software provided that any reserved
|
||||
names are not used by derivative works. The fonts and derivatives,
|
||||
however, cannot be released under any other type of license. The
|
||||
requirement for fonts to remain under this license does not apply
|
||||
to any document created using the fonts or their derivatives.
|
||||
|
||||
DEFINITIONS
|
||||
"Font Software" refers to the set of files released by the Copyright
|
||||
Holder(s) under this license and clearly marked as such. This may
|
||||
include source files, build scripts and documentation.
|
||||
|
||||
"Reserved Font Name" refers to any names specified as such after the
|
||||
copyright statement(s).
|
||||
|
||||
"Original Version" refers to the collection of Font Software components as
|
||||
distributed by the Copyright Holder(s).
|
||||
|
||||
"Modified Version" refers to any derivative made by adding to, deleting,
|
||||
or substituting -- in part or in whole -- any of the components of the
|
||||
Original Version, by changing formats or by porting the Font Software to a
|
||||
new environment.
|
||||
|
||||
"Author" refers to any designer, engineer, programmer, technical
|
||||
writer or other person who contributed to the Font Software.
|
||||
|
||||
PERMISSION & CONDITIONS
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
||||
redistribute, and sell modified and unmodified copies of the Font
|
||||
Software, subject to the following conditions:
|
||||
|
||||
1) Neither the Font Software nor any of its individual components,
|
||||
in Original or Modified Versions, may be sold by itself.
|
||||
|
||||
2) Original or Modified Versions of the Font Software may be bundled,
|
||||
redistributed and/or sold with any software, provided that each copy
|
||||
contains the above copyright notice and this license. These can be
|
||||
included either as stand-alone text files, human-readable headers or
|
||||
in the appropriate machine-readable metadata fields within text or
|
||||
binary files as long as those fields can be easily viewed by the user.
|
||||
|
||||
3) No Modified Version of the Font Software may use the Reserved Font
|
||||
Name(s) unless explicit written permission is granted by the corresponding
|
||||
Copyright Holder. This restriction only applies to the primary font name as
|
||||
presented to the users.
|
||||
|
||||
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
||||
Software shall not be used to promote, endorse or advertise any
|
||||
Modified Version, except to acknowledge the contribution(s) of the
|
||||
Copyright Holder(s) and the Author(s) or with their explicit written
|
||||
permission.
|
||||
|
||||
5) The Font Software, modified or unmodified, in part or in whole,
|
||||
must be distributed entirely under this license, and must not be
|
||||
distributed under any other license. The requirement for fonts to
|
||||
remain under this license does not apply to any document created
|
||||
using the Font Software.
|
||||
|
||||
TERMINATION
|
||||
This license becomes null and void if any of the above conditions are
|
||||
not met.
|
||||
|
||||
DISCLAIMER
|
||||
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
||||
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
||||
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
||||
OTHER DEALINGS IN THE FONT SOFTWARE.
|
||||
93
scripts/carte/polices/OFL-spectral.txt
Normal file
93
scripts/carte/polices/OFL-spectral.txt
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
Copyright 2017 The Spectral Project Authors (https://github.com/productiontype/Spectral)
|
||||
|
||||
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
||||
This license is copied below, and is also available with a FAQ at:
|
||||
https://openfontlicense.org
|
||||
|
||||
|
||||
-----------------------------------------------------------
|
||||
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
||||
-----------------------------------------------------------
|
||||
|
||||
PREAMBLE
|
||||
The goals of the Open Font License (OFL) are to stimulate worldwide
|
||||
development of collaborative font projects, to support the font creation
|
||||
efforts of academic and linguistic communities, and to provide a free and
|
||||
open framework in which fonts may be shared and improved in partnership
|
||||
with others.
|
||||
|
||||
The OFL allows the licensed fonts to be used, studied, modified and
|
||||
redistributed freely as long as they are not sold by themselves. The
|
||||
fonts, including any derivative works, can be bundled, embedded,
|
||||
redistributed and/or sold with any software provided that any reserved
|
||||
names are not used by derivative works. The fonts and derivatives,
|
||||
however, cannot be released under any other type of license. The
|
||||
requirement for fonts to remain under this license does not apply
|
||||
to any document created using the fonts or their derivatives.
|
||||
|
||||
DEFINITIONS
|
||||
"Font Software" refers to the set of files released by the Copyright
|
||||
Holder(s) under this license and clearly marked as such. This may
|
||||
include source files, build scripts and documentation.
|
||||
|
||||
"Reserved Font Name" refers to any names specified as such after the
|
||||
copyright statement(s).
|
||||
|
||||
"Original Version" refers to the collection of Font Software components as
|
||||
distributed by the Copyright Holder(s).
|
||||
|
||||
"Modified Version" refers to any derivative made by adding to, deleting,
|
||||
or substituting -- in part or in whole -- any of the components of the
|
||||
Original Version, by changing formats or by porting the Font Software to a
|
||||
new environment.
|
||||
|
||||
"Author" refers to any designer, engineer, programmer, technical
|
||||
writer or other person who contributed to the Font Software.
|
||||
|
||||
PERMISSION & CONDITIONS
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
||||
redistribute, and sell modified and unmodified copies of the Font
|
||||
Software, subject to the following conditions:
|
||||
|
||||
1) Neither the Font Software nor any of its individual components,
|
||||
in Original or Modified Versions, may be sold by itself.
|
||||
|
||||
2) Original or Modified Versions of the Font Software may be bundled,
|
||||
redistributed and/or sold with any software, provided that each copy
|
||||
contains the above copyright notice and this license. These can be
|
||||
included either as stand-alone text files, human-readable headers or
|
||||
in the appropriate machine-readable metadata fields within text or
|
||||
binary files as long as those fields can be easily viewed by the user.
|
||||
|
||||
3) No Modified Version of the Font Software may use the Reserved Font
|
||||
Name(s) unless explicit written permission is granted by the corresponding
|
||||
Copyright Holder. This restriction only applies to the primary font name as
|
||||
presented to the users.
|
||||
|
||||
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
||||
Software shall not be used to promote, endorse or advertise any
|
||||
Modified Version, except to acknowledge the contribution(s) of the
|
||||
Copyright Holder(s) and the Author(s) or with their explicit written
|
||||
permission.
|
||||
|
||||
5) The Font Software, modified or unmodified, in part or in whole,
|
||||
must be distributed entirely under this license, and must not be
|
||||
distributed under any other license. The requirement for fonts to
|
||||
remain under this license does not apply to any document created
|
||||
using the Font Software.
|
||||
|
||||
TERMINATION
|
||||
This license becomes null and void if any of the above conditions are
|
||||
not met.
|
||||
|
||||
DISCLAIMER
|
||||
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
||||
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
||||
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
||||
OTHER DEALINGS IN THE FONT SOFTWARE.
|
||||
BIN
scripts/carte/polices/imfellenglish-italic-400.woff2
Normal file
BIN
scripts/carte/polices/imfellenglish-italic-400.woff2
Normal file
Binary file not shown.
BIN
scripts/carte/polices/imfellenglishsc-400.woff2
Normal file
BIN
scripts/carte/polices/imfellenglishsc-400.woff2
Normal file
Binary file not shown.
BIN
scripts/carte/polices/jetbrainsmono-400.woff2
Normal file
BIN
scripts/carte/polices/jetbrainsmono-400.woff2
Normal file
Binary file not shown.
BIN
scripts/carte/polices/spectral-300.woff2
Normal file
BIN
scripts/carte/polices/spectral-300.woff2
Normal file
Binary file not shown.
BIN
scripts/carte/polices/spectral-400.woff2
Normal file
BIN
scripts/carte/polices/spectral-400.woff2
Normal file
Binary file not shown.
BIN
scripts/carte/polices/spectral-600.woff2
Normal file
BIN
scripts/carte/polices/spectral-600.woff2
Normal file
Binary file not shown.
BIN
scripts/carte/polices/spectral-italic-300.woff2
Normal file
BIN
scripts/carte/polices/spectral-italic-300.woff2
Normal file
Binary file not shown.
332
scripts/carte_reseaux.py
Normal file
332
scripts/carte_reseaux.py
Normal file
|
|
@ -0,0 +1,332 @@
|
|||
#!/usr/bin/env python3
|
||||
"""La carte celeste des reseaux : la couche 3 des sites et de leurs locataires, en une page.
|
||||
|
||||
POURQUOI (2026-10-19). Personne ne voyait d'un coup d'oeil ce que les plans declarent : les
|
||||
zones de chaque site, ses frontieres et tunnels, les VRF de ses locataires, et l'adresse de
|
||||
chaque machine. L'information existait, dispersee dans six fichiers par site et deux par
|
||||
locataire. Cette page la rassemble pour la livraison d'un site ou l'ouverture d'un partenariat.
|
||||
|
||||
UNE VUE, PAS UNE FONCTION (AGENTS §12). Rien n'est saisi ni deduit ici : chaque adresse vient
|
||||
d'un plan, d'une carte (`underlay.yml`) ou d'une face reseau publiee, et se derive par les
|
||||
fonctions memes du moteur (`underlay.charger_resolu`, `inventory_rules`, `devis_sdn`,
|
||||
`etoiles`). La carte dit ce que les plans DECLARENT ; elle ne mesure rien. Les devis
|
||||
(`make underlay-plan`, `make sdn-plan`, `make frontiere-plan`) confrontent au reel.
|
||||
|
||||
LA CARTE PORTE DES ADRESSES INTERNES. Elle ne s'ecrit donc jamais dans le moteur public, sauf
|
||||
dans `tmp/` (ignore par git) : sa place est le depot prive du site, ou la remise en main
|
||||
propre. `--site` borne la carte a un site, ses locataires et ses reprises : un partenaire
|
||||
recoit son site, pas les adresses des autres ecosystemes.
|
||||
|
||||
Aucune voute n'est lue, aucune cle publique WireGuard n'est reportee. Les polices (OFL) sont
|
||||
embarquees : la page s'ouvre hors ligne et n'appelle aucun service.
|
||||
|
||||
Usage :
|
||||
python3 scripts/carte_reseaux.py # tous les sites, -> tmp/
|
||||
python3 scripts/carte_reseaux.py --site SITE-Technolibre # un site et ses locataires
|
||||
python3 scripts/carte_reseaux.py --vers ../SITE-X/carte-des-reseaux.html
|
||||
python3 scripts/carte_reseaux.py --json # les donnees seules
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import base64
|
||||
import datetime
|
||||
import ipaddress
|
||||
import json
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
||||
import yaml # noqa: E402
|
||||
|
||||
import contexte # noqa: E402
|
||||
import etoiles # noqa: E402
|
||||
import underlay as underlay_mod # noqa: E402
|
||||
from devis_sdn import vnet_de, zone_de # noqa: E402
|
||||
from inventory_rules import passerelle_de, sous_reseau_de, supernet_de, vlan_de # noqa: E402
|
||||
|
||||
RACINE = Path(__file__).resolve().parents[1]
|
||||
GABARIT = RACINE / "scripts" / "carte" / "gabarit.html"
|
||||
POLICES = RACINE / "scripts" / "carte" / "polices"
|
||||
SORTIE_DEFAUT = RACINE / "tmp" / "carte-des-reseaux.html"
|
||||
# (famille CSS, style, graisse, fichier) — sous-ensemble latin, licence OFL (polices/LICENCES.md).
|
||||
FACES = (
|
||||
("IM Fell English SC", "normal", 400, "imfellenglishsc-400.woff2"),
|
||||
("IM Fell English", "italic", 400, "imfellenglish-italic-400.woff2"),
|
||||
("Spectral", "normal", 300, "spectral-300.woff2"),
|
||||
("Spectral", "italic", 300, "spectral-italic-300.woff2"),
|
||||
("Spectral", "normal", 400, "spectral-400.woff2"),
|
||||
("Spectral", "normal", 600, "spectral-600.woff2"),
|
||||
("JetBrains Mono", "normal", 400, "jetbrainsmono-400.woff2"),
|
||||
)
|
||||
|
||||
|
||||
class CarteRefusee(Exception):
|
||||
"""Une demande que la carte ne doit pas satisfaire (portee inconnue, sortie publique)."""
|
||||
|
||||
|
||||
def _yaml(chemin: Path) -> dict:
|
||||
if not chemin.is_file():
|
||||
return {}
|
||||
d = yaml.safe_load(chemin.read_text(encoding="utf-8"))
|
||||
return d if isinstance(d, dict) else {}
|
||||
|
||||
|
||||
def _commit(depot: Path) -> str:
|
||||
"""Le commit court du depot, suivi de `+` si l'arbre porte des modifications."""
|
||||
r = subprocess.run(["git", "-C", str(depot), "rev-parse", "--short", "HEAD"],
|
||||
capture_output=True, text=True)
|
||||
if r.returncode != 0:
|
||||
return ""
|
||||
sale = subprocess.run(["git", "-C", str(depot), "status", "--porcelain"],
|
||||
capture_output=True, text=True).stdout.strip()
|
||||
return r.stdout.strip() + ("+" if sale else "")
|
||||
|
||||
|
||||
def _tri_ip(vms: list[dict]) -> list[dict]:
|
||||
return sorted(vms, key=lambda v: ipaddress.ip_address(v["ip"]))
|
||||
|
||||
|
||||
def _hote(h: dict) -> dict:
|
||||
"""Un hote de la carte, sans sa cle publique : la carte n'en a pas l'usage."""
|
||||
out = {"nom": h.get("nom"), "ip": h.get("ip"), "role": h.get("role", "")}
|
||||
if h.get("etat"):
|
||||
out["etat"] = h["etat"]
|
||||
return out
|
||||
|
||||
|
||||
# --- SITE ---------------------------------------------------------------------------------
|
||||
|
||||
def _site(site: contexte.Site) -> dict:
|
||||
carte = underlay_mod.charger_resolu(site.underlay) or {}
|
||||
intrants = site.lire_plan("10-intrants.yml")
|
||||
opn = _yaml(site.depot / "opnsense.yml")
|
||||
px = _yaml(site.depot / "proxmox-hebergeur.yml")
|
||||
serveurs = site.lire_plan("serveurs.yml").get("serveurs") or {}
|
||||
index = carte.get("index")
|
||||
reseaux = carte.get("reseaux") or []
|
||||
hotes = carte.get("hotes") or []
|
||||
transit = underlay_mod.reseau_transit(carte) or {}
|
||||
|
||||
frontieres = [h for h in hotes if h.get("role") == "frontiere"]
|
||||
frontiere = next((h["nom"] for h in frontieres if h.get("reseau") == "management"),
|
||||
frontieres[0]["nom"] if frontieres else "frontière")
|
||||
|
||||
zones, fabric, liens, relais = [], [], [], None
|
||||
for r in reseaux:
|
||||
hs = [_hote(h) for h in hotes if h.get("reseau") == r.get("nom")]
|
||||
if r.get("nature") == "site":
|
||||
vms = [{"nom": n, "ip": d["ip"], "noeud": d.get("noeud"), "vmid": d.get("vmid")}
|
||||
for n, d in serveurs.items()
|
||||
if isinstance(d, dict) and d.get("reseau") == r["nom"]
|
||||
and d.get("etat", "actif") == "actif" and d.get("ip")]
|
||||
zones.append({"nom": r["nom"], "vlan": r.get("vlan"), "sous_reseau": r.get("sous_reseau"),
|
||||
"passerelle": r.get("passerelle"), "description": r.get("description", ""),
|
||||
"vms": _tri_ip(vms)})
|
||||
continue
|
||||
fab = underlay_mod.fabric_de(r)
|
||||
if fab == "inter-sites":
|
||||
local = next((h for h in hotes if h.get("reseau") == r["nom"] and h.get("role") == "frontiere"), {})
|
||||
pair = next((h for h in hotes if h.get("reseau") == r["nom"] and h.get("role") == "frontiere_pair"), {})
|
||||
pairs_dns = {str(p.get("site")) for p in (intrants.get("dns_public_pairs") or [])
|
||||
if isinstance(p, dict) and p.get("etat") == "actif"}
|
||||
liens.append({"sous_reseau": r.get("sous_reseau"), "mtu": r.get("mtu"),
|
||||
"local": {"nom": local.get("nom"), "ip": local.get("ip")},
|
||||
"pair": {"nom": pair.get("nom"), "ip": pair.get("ip"), "site": pair.get("site"),
|
||||
"point_arrivee": pair.get("point_arrivee")},
|
||||
"dns_public": pair.get("site") in pairs_dns})
|
||||
continue
|
||||
rel = next((h for h in hotes if h.get("reseau") == r["nom"] and h.get("role") == "relais"), None)
|
||||
if rel:
|
||||
bout = next((h for h in hotes if h.get("reseau") == r["nom"] and h.get("role") == "frontiere"), {})
|
||||
relais = {"nom": rel.get("nom"), "console": rel.get("console"), "ip": rel.get("ip"),
|
||||
"ip_frontiere": bout.get("ip"), "sous_reseau": r.get("sous_reseau"), "mtu": r.get("mtu")}
|
||||
continue
|
||||
fabric.append({"nom": r["nom"], "vlan": r.get("vlan"), "sous_reseau": r.get("sous_reseau"),
|
||||
"mtu": r.get("mtu"), "tunnel": r.get("tunnel"), "fabric": fab,
|
||||
"transit": r.get("nom") == transit.get("nom"),
|
||||
"description": r.get("description", ""), "hotes": hs})
|
||||
|
||||
hyperviseurs: dict[str, dict] = {}
|
||||
for h in hotes:
|
||||
if h.get("role") == "hyperviseur":
|
||||
hyperviseurs.setdefault(h["nom"], {"nom": h["nom"], "adresses": {}})["adresses"][h["reseau"]] = h["ip"]
|
||||
|
||||
pool = opn.get("opnsense_ips_publiques") or {}
|
||||
publiques = ([{"ip": opn["opnsense_wan_ip"], "pour": site.nom}] if opn.get("opnsense_wan_ip") else [])
|
||||
publiques += [{"ip": ip, "pour": str(pour)} for ip, pour in pool.items()]
|
||||
|
||||
vpn = intrants.get("acces_admin_vpn") or {}
|
||||
admins = None
|
||||
if vpn.get("reseau"):
|
||||
admins = {"reseau": vpn["reseau"], "port": vpn.get("port"), "mtu": vpn.get("mtu"),
|
||||
"frontiere": str(vpn.get("adresse_frontiere") or "").split("/")[0],
|
||||
"pairs": [{"nom": p.get("nom"), "adresse": str(p.get("adresse", "")).split("/")[0]}
|
||||
for p in vpn.get("pairs") or []
|
||||
if isinstance(p, dict) and p.get("etat", "present") == "present"]}
|
||||
|
||||
locataires, reprises = [], []
|
||||
for loc in site.locataires():
|
||||
if loc.nom_hebergeur() == site.nom:
|
||||
t = _locataire(loc)
|
||||
if t:
|
||||
locataires.append(t)
|
||||
else:
|
||||
reprises.append(_reprise(loc, pool))
|
||||
|
||||
return {
|
||||
"nom": site.nom, "commit": _commit(site.depot), "index": index,
|
||||
"etoile": etoiles.domaine_site(index) if isinstance(index, int) else "",
|
||||
"domaine": intrants.get("domaine_interne", ""), "organisation": intrants.get("organisation", ""),
|
||||
"frontiere": frontiere, "opnsense": bool(opn),
|
||||
"dns_public_nom": intrants.get("dns_public_nom"),
|
||||
"transit": {"nom": transit.get("nom"), "vlan": transit.get("vlan"),
|
||||
"sous_reseau": transit.get("sous_reseau"), "sortie": transit.get("passerelle_sortie")},
|
||||
"hyperviseurs": list(hyperviseurs.values()),
|
||||
"sdn": px.get("proxmox_sdn") or {}, "noeuds": px.get("proxmox_noeuds") or [],
|
||||
"publiques": publiques, "relais": relais, "admins": admins, "liens": liens,
|
||||
"fabric": fabric, "zones": zones,
|
||||
"locataires": locataires, "reprises": reprises, "absents": site.locataires_absents(),
|
||||
}
|
||||
|
||||
|
||||
# --- LOCATAIRE ------------------------------------------------------------------------------
|
||||
|
||||
def _categories(face: dict) -> list[tuple[int, str]]:
|
||||
cats = ((face.get("nomenclature") or {}).get("categories")) or {}
|
||||
return sorted((int(k), str((v or {}).get("libelle", f"zone-{k}"))) for k, v in cats.items())
|
||||
|
||||
|
||||
def _locataire(loc: contexte.Locataire) -> dict | None:
|
||||
"""Un locataire heberge ICI, d'apres la face qu'il publie pour son site. Sans face publiee,
|
||||
rien : le site ne lit pas les fichiers internes de ses locataires (§2.4)."""
|
||||
face = loc.face_publiee()
|
||||
if not face:
|
||||
return None
|
||||
index = face.get("index")
|
||||
machines = face.get("machines") or {}
|
||||
fiche = loc.fiche_du_site() or {}
|
||||
domaine = next((str((m.get("clonage") or {}).get("SETOPS_DOMAINE") or "") for m in machines.values()
|
||||
if (m.get("clonage") or {}).get("SETOPS_DOMAINE")), "") or loc.domaine_interne()
|
||||
zones = []
|
||||
for k, libelle in _categories(face):
|
||||
gw = passerelle_de(index, k)
|
||||
vms = [{"nom": n, "ip": m["ip"], "noeud": (m.get("materialisation") or {}).get("proxmox_noeud"),
|
||||
"vmid": (m.get("materialisation") or {}).get("proxmox_vmid")}
|
||||
for n, m in machines.items()
|
||||
if m.get("etat") == "actif" and (m.get("materialisation") or {}).get("proxmox_passerelle") == gw]
|
||||
zones.append({"libelle": libelle, "sous_reseau": sous_reseau_de(index, k), "passerelle": gw,
|
||||
"vnet": vnet_de(index, libelle), "tag": vlan_de(index, k), "vms": _tri_ip(vms)})
|
||||
adm = face.get("administration") or {}
|
||||
return {
|
||||
"nom": loc.nom, "commit": _commit(loc.depot), "index": index, "domaine": domaine,
|
||||
"vrf": zone_de(index), "vni": index, "supernet": supernet_de(index),
|
||||
"ip_publique": ((fiche.get("attribue") or {}).get("ip_publique")),
|
||||
"tunnel": {"reseau": (adm.get("tunnel") or [None])[0], "port": adm.get("port_tunnel"),
|
||||
"pairs": [{"nom": n, "adresse": str(p.get("adresse", "")).split("/")[0]}
|
||||
for n, p in (adm.get("pairs") or {}).items()
|
||||
if isinstance(p, dict) and p.get("etat", "present") == "present"]},
|
||||
"dns_public": face.get("dns_public") or {},
|
||||
"zones": zones,
|
||||
}
|
||||
|
||||
|
||||
def _reprise(loc: contexte.Locataire, pool: dict) -> dict:
|
||||
"""Un locataire que ce site peut REPRENDRE : ses zones lui sont reservees, rien n'y tourne."""
|
||||
index = loc.index
|
||||
face = loc.face_publiee() or {"nomenclature": loc.nomenclature()}
|
||||
return {"nom": loc.nom, "index": index, "vrf": zone_de(index), "supernet": supernet_de(index),
|
||||
"zones": [sous_reseau_de(index, k) for k, _ in _categories(face)],
|
||||
"ip_publique": next((ip for ip, pour in pool.items() if str(pour) == loc.nom), None)}
|
||||
|
||||
|
||||
# --- LA CARTE ---------------------------------------------------------------------------------
|
||||
|
||||
def collecter(dossier: Path = contexte.DOSSIER_ECOSYSTEMES, site: str | None = None) -> dict:
|
||||
"""Les donnees de la carte : tous les sites freres, ou le seul site nomme."""
|
||||
# Un lien `underlay.yml` est un MONTAGE (le moteur monte la carte de son site) : le site
|
||||
# est le depot qui porte la carte elle-meme. Sans ce filtre, le moteur se dessinait en
|
||||
# troisieme site, double de celui qu'il monte.
|
||||
sites = [contexte.Site(p.parent) for p in sorted(Path(dossier).glob("*/underlay.yml"))
|
||||
if not p.is_symlink()]
|
||||
if site:
|
||||
sites = [s for s in sites if s.nom == site]
|
||||
if not sites:
|
||||
raise CarteRefusee(f"site « {site} » introuvable : pas de {Path(dossier) / site}/underlay.yml")
|
||||
donnees = {"date": datetime.date.today().isoformat(), "portee": site, "sites": [_site(s) for s in sites]}
|
||||
if not site:
|
||||
# Ce qui reste hors de la carte, et pourquoi : un filtre qui oublie en silence est un defaut.
|
||||
vus = {t["nom"] for s in donnees["sites"] for t in s["locataires"] + s["reprises"]}
|
||||
hors = []
|
||||
for nomen in sorted(Path(dossier).glob("*/plan/nomenclature.yml")):
|
||||
depot = nomen.parent.parent
|
||||
if depot.name in vus:
|
||||
continue
|
||||
federe = _yaml(nomen).get("federe", True)
|
||||
hors.append({"nom": depot.name, "index": _yaml(nomen).get("index"),
|
||||
"raison": "bac à sable local, non fédéré" if federe is False
|
||||
else "déclaré par aucun site"})
|
||||
donnees["hors_carte"] = hors
|
||||
return donnees
|
||||
|
||||
|
||||
def _polices() -> str:
|
||||
regles = []
|
||||
for famille, style, graisse, fichier in FACES:
|
||||
b64 = base64.b64encode((POLICES / fichier).read_bytes()).decode("ascii")
|
||||
regles.append(f"@font-face{{font-family:\"{famille}\";font-style:{style};font-weight:{graisse};"
|
||||
f"font-display:swap;src:url(data:font/woff2;base64,{b64}) format(\"woff2\");}}")
|
||||
return "\n".join(regles)
|
||||
|
||||
|
||||
def rendre(donnees: dict) -> str:
|
||||
"""La page autonome : gabarit + polices embarquees + donnees."""
|
||||
page = GABARIT.read_text(encoding="utf-8")
|
||||
# `</` echappe : une valeur du plan ne peut pas fermer le <script> qui la porte.
|
||||
brut = json.dumps(donnees, ensure_ascii=False).replace("</", "<\\/")
|
||||
return page.replace("/*__POLICES__*/", _polices()).replace("__DONNEES__", brut)
|
||||
|
||||
|
||||
def verifier_sortie(vers: Path) -> Path:
|
||||
"""Refuse d'ecrire la carte dans le moteur public, hors de `tmp/` (ignore par git)."""
|
||||
cible = vers.expanduser().resolve()
|
||||
if cible.is_relative_to(RACINE) and not cible.is_relative_to(RACINE / "tmp"):
|
||||
raise CarteRefusee(
|
||||
f"{cible} est dans le moteur public : la carte porte des adresses internes. "
|
||||
f"Ecrire dans tmp/, dans le depot prive du site, ou hors des depots.")
|
||||
return cible
|
||||
|
||||
|
||||
def main(argv: list[str] | None = None) -> int:
|
||||
ap = argparse.ArgumentParser(description="La carte celeste des reseaux (couche 3).")
|
||||
ap.add_argument("--site", help="borner la carte a ce site (dossier frere), ses locataires et ses reprises")
|
||||
ap.add_argument("--vers", type=Path, default=SORTIE_DEFAUT, help="fichier HTML a ecrire")
|
||||
ap.add_argument("--json", action="store_true", help="afficher les donnees, ne rien ecrire")
|
||||
a = ap.parse_args(argv)
|
||||
try:
|
||||
donnees = collecter(site=a.site)
|
||||
if a.json:
|
||||
json.dump(donnees, sys.stdout, ensure_ascii=False, indent=1)
|
||||
print()
|
||||
return 0
|
||||
cible = verifier_sortie(a.vers)
|
||||
except CarteRefusee as e:
|
||||
print(f"refus : {e}", file=sys.stderr)
|
||||
return 2
|
||||
cible.parent.mkdir(parents=True, exist_ok=True)
|
||||
cible.write_text(rendre(donnees), encoding="utf-8")
|
||||
nb_vm = sum(len(z["vms"]) for s in donnees["sites"]
|
||||
for g in [s, *s["locataires"]] for z in g["zones"])
|
||||
nb_loc = sum(len(s["locataires"]) for s in donnees["sites"])
|
||||
print(f"carte : {len(donnees['sites'])} site(s), {nb_loc} locataire(s) heberge(s), {nb_vm} machine(s)")
|
||||
for s in donnees["sites"]:
|
||||
print(f" {s['nom']}@{s['commit'] or '?'} — {s['etoile']}, {len(s['zones'])} zones, "
|
||||
f"{len(s['locataires'])} locataire(s), {len(s['reprises'])} reprise(s)")
|
||||
print(f"ecrite : {cible}")
|
||||
print("Elle porte des adresses internes : la remettre en main propre, ou la verser au depot prive du site.")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
219
scripts/tests/test_carte_reseaux.py
Normal file
219
scripts/tests/test_carte_reseaux.py
Normal file
|
|
@ -0,0 +1,219 @@
|
|||
#!/usr/bin/env python3
|
||||
"""La carte celeste des reseaux : une vue des plans, autonome, qui ne fuit rien.
|
||||
|
||||
Ecosystemes FICTIFS (adresses de documentation, RFC 5737) : le moteur est public, les vraies
|
||||
adresses n'y entrent pas. Ces cas gardent :
|
||||
1. un site est un depot qui PORTE sa carte ; un lien `underlay.yml` (montage du moteur) n'en
|
||||
fait pas un troisieme site ;
|
||||
2. les zones du site et celles du locataire viennent des derivations du moteur ;
|
||||
3. un locataire paraît heberge chez son hebergeur actif, en reprise chez l'autre site ;
|
||||
4. `--site` borne la carte : les adresses des autres ecosystemes n'y entrent pas ;
|
||||
5. la page est autonome (polices embarquees, aucune adresse web) et ne porte ni cle
|
||||
publique, ni contenu de voute, ni `</script>` venu d'un plan ;
|
||||
6. la carte ne s'ecrit jamais dans le moteur public, hors de `tmp/`.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
import yaml
|
||||
|
||||
RACINE = Path(__file__).resolve().parents[2]
|
||||
sys.path.insert(0, str(RACINE / "scripts"))
|
||||
|
||||
import carte_reseaux as C # noqa: E402
|
||||
import etoiles # noqa: E402
|
||||
from inventory_rules import vlan_de # noqa: E402
|
||||
|
||||
CLE_SITE = "CLEPUBLIQUEDUPORTEEXEMPLE0000000000000000000="
|
||||
CLE_PAIR = "CLEPUBLIQUEALICE000000000000000000000000000="
|
||||
CLE_BOB = "CLEPUBLIQUEBOB00000000000000000000000000000="
|
||||
SECRET = "SECRET-NE-JAMAIS-LIRE"
|
||||
|
||||
|
||||
def _ecrire(base: Path, chemin: str, contenu) -> None:
|
||||
f = base / chemin
|
||||
f.parent.mkdir(parents=True, exist_ok=True)
|
||||
f.write_text(contenu if isinstance(contenu, str) else yaml.safe_dump(contenu, allow_unicode=True),
|
||||
encoding="utf-8")
|
||||
|
||||
|
||||
def _flotte(d: Path) -> None:
|
||||
"""Deux sites relies, un locataire heberge par l'un et repris par l'autre, un bac a sable."""
|
||||
_ecrire(d, "SITE-Exemple/underlay.yml", {"underlay": {
|
||||
"index": 41, "tenants": {"OPS-Exemple": 19},
|
||||
"reseaux": [
|
||||
{"nom": "management", "nature": "fabric", "sous_reseau": "10.41.0.0/24", "mtu": 1500},
|
||||
{"nom": "site-pilotage", "nature": "site", "vlan": 31, "mtu": 1500,
|
||||
"description": "</script><b>injection</b>"},
|
||||
{"nom": "site-genome", "nature": "site", "vlan": 33, "mtu": 1500},
|
||||
{"nom": "transit-frontiere", "nature": "fabric", "vlan": 40, "sous_reseau": "10.0.4.0/24",
|
||||
"passerelle_sortie": "10.0.4.1", "mtu": 1500},
|
||||
{"nom": "inter-sites", "nature": "fabric", "fabric": "inter-sites", "tunnel": "wireguard",
|
||||
"sous_reseau": "172.30.0.0/30", "mtu": 1412}],
|
||||
"hotes": [
|
||||
{"nom": "porte", "reseau": "management", "ip": "10.41.0.1", "role": "frontiere"},
|
||||
{"nom": "porte", "reseau": "transit-frontiere", "ip": "10.0.4.1", "role": "frontiere"},
|
||||
{"nom": "porte", "reseau": "inter-sites", "ip": "172.30.0.1", "role": "frontiere", "cle_publique": CLE_SITE},
|
||||
{"nom": "autre-porte", "reseau": "inter-sites", "ip": "172.30.0.2", "role": "frontiere_pair",
|
||||
"site": "SITE-Autre"},
|
||||
{"nom": "noeud1", "reseau": "transit-frontiere", "ip": "10.0.4.11", "role": "hyperviseur"}]}})
|
||||
_ecrire(d, "SITE-Exemple/opnsense.yml", {"opnsense_wan_ip": "203.0.113.10",
|
||||
"opnsense_ips_publiques": {"203.0.113.11": "OPS-Exemple"}})
|
||||
_ecrire(d, "SITE-Exemple/underlay.vault.yml", f"vault_secret: {SECRET}\n")
|
||||
_ecrire(d, "SITE-Exemple/proxmox-hebergeur.yml", {"proxmox_noeuds": ["noeud1"], "proxmox_sdn": {
|
||||
"asn": 65041, "controleur": "EVPN0041", "noeuds_de_sortie": ["noeud1"], "sortie_primaire": "noeud1"}})
|
||||
_ecrire(d, "SITE-Exemple/plan/10-intrants.yml", {
|
||||
"domaine_interne": etoiles.domaine_site(41),
|
||||
"dns_public_pairs": [{"site": "SITE-Autre", "etat": "actif"}],
|
||||
"acces_admin_vpn": {"reseau": "10.41.29.0/24", "port": 51821, "mtu": 1412, "adresse_frontiere": "10.41.29.1/24",
|
||||
"pairs": [{"nom": "alice-portable", "cle_publique": CLE_PAIR,
|
||||
"adresse": "10.41.29.2/32", "etat": "present"}]}})
|
||||
_ecrire(d, "SITE-Exemple/plan/serveurs.yml", {"serveurs": {
|
||||
"site-ops-01": {"etat": "actif", "reseau": "site-pilotage", "ip": "10.41.31.11", "noeud": "noeud1", "vmid": 9001},
|
||||
"site-forge-01": {"etat": "actif", "reseau": "site-genome", "ip": "10.41.33.11", "noeud": "noeud1", "vmid": 9003},
|
||||
"site-vieux-01": {"etat": "retire", "reseau": "site-genome", "ip": "10.41.33.99"}}})
|
||||
|
||||
_ecrire(d, "SITE-Autre/underlay.yml", {"underlay": {
|
||||
"index": 43, "tenants": {"OPS-Exemple": 19},
|
||||
"reseaux": [
|
||||
{"nom": "site-pilotage", "nature": "site", "vlan": 31, "mtu": 1500},
|
||||
{"nom": "transit-frontiere", "nature": "fabric", "vlan": 40, "sous_reseau": "10.0.4.0/24",
|
||||
"passerelle_sortie": "10.0.4.1", "mtu": 1500},
|
||||
{"nom": "inter-sites", "nature": "fabric", "fabric": "inter-sites", "tunnel": "wireguard",
|
||||
"sous_reseau": "172.30.0.0/30", "mtu": 1412}],
|
||||
"hotes": [
|
||||
{"nom": "autre-porte", "reseau": "transit-frontiere", "ip": "10.0.4.1", "role": "frontiere"},
|
||||
{"nom": "autre-porte", "reseau": "inter-sites", "ip": "172.30.0.2", "role": "frontiere"},
|
||||
{"nom": "porte", "reseau": "inter-sites", "ip": "172.30.0.1", "role": "frontiere_pair",
|
||||
"site": "SITE-Exemple", "point_arrivee": "203.0.113.10:51820"}]}})
|
||||
_ecrire(d, "SITE-Autre/opnsense.yml", {"opnsense_wan_ip": "198.51.100.6",
|
||||
"opnsense_ips_publiques": {"198.51.100.7": "OPS-Exemple"}})
|
||||
_ecrire(d, "SITE-Autre/plan/serveurs.yml", {"serveurs": {
|
||||
"site-ops-01": {"etat": "actif", "reseau": "site-pilotage", "ip": "10.43.31.11", "vmid": 9001}}})
|
||||
|
||||
cats = {1: {"libelle": "Frontiere"}, 4: {"libelle": "Services-infra"}}
|
||||
_ecrire(d, "OPS-Exemple/plan/nomenclature.yml", {"index": 19, "categories": cats})
|
||||
_ecrire(d, "OPS-Exemple/parente.yml", {"parente": {"depots": {"hebergeur": {"nom": "SITE-Exemple"}}}})
|
||||
_ecrire(d, "OPS-Exemple/fiche-site.yml", {"attribue": {"index": 19, "ip_publique": "203.0.113.11"}})
|
||||
machine = lambda ip, gw: {"ip": ip, "etat": "actif", "clonage": {"SETOPS_DOMAINE": "exemple.internal"},
|
||||
"materialisation": {"proxmox_noeud": "noeud1", "proxmox_passerelle": gw, "proxmox_vmid": 1}}
|
||||
_ecrire(d, "OPS-Exemple/face-reseau.yml", {
|
||||
"index": 19, "nomenclature": {"index": 19, "categories": cats},
|
||||
"machines": {"infra-edge-01": machine("10.19.16.11", "10.19.16.1"),
|
||||
"infra-dns-01": machine("10.19.19.11", "10.19.19.1")},
|
||||
"administration": {"tunnel": ["10.19.29.0/24"], "port_tunnel": 52019,
|
||||
"pairs": {"bob-portable": {"cle_publique": CLE_BOB, "adresse": "10.19.29.2/32", "etat": "present"}}},
|
||||
"dns_public": {"zones": ["exemple.ca"], "primaire": "10.19.19.11", "port": 5300}})
|
||||
|
||||
_ecrire(d, "OPS-Bac/plan/nomenclature.yml", {"index": 21, "federe": False, "categories": cats})
|
||||
(d / "Moteur").mkdir()
|
||||
os.symlink("../SITE-Exemple/underlay.yml", d / "Moteur" / "underlay.yml")
|
||||
|
||||
|
||||
class Carte(unittest.TestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cls._tmp = tempfile.TemporaryDirectory()
|
||||
cls.d = Path(cls._tmp.name)
|
||||
_flotte(cls.d)
|
||||
cls.tout = C.collecter(cls.d)
|
||||
cls.sites = {s["nom"]: s for s in cls.tout["sites"]}
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
cls._tmp.cleanup()
|
||||
|
||||
def test_un_montage_n_est_pas_un_site(self):
|
||||
self.assertEqual(sorted(self.sites), ["SITE-Autre", "SITE-Exemple"])
|
||||
|
||||
def test_zones_du_site_derivees(self):
|
||||
s = self.sites["SITE-Exemple"]
|
||||
self.assertEqual(s["etoile"], etoiles.domaine_site(41))
|
||||
self.assertEqual([(z["sous_reseau"], z["passerelle"]) for z in s["zones"]],
|
||||
[("10.41.31.0/24", "10.41.31.1"), ("10.41.33.0/24", "10.41.33.1")])
|
||||
self.assertEqual([v["nom"] for z in s["zones"] for v in z["vms"]], ["site-ops-01", "site-forge-01"],
|
||||
"une machine retiree ne parait pas")
|
||||
self.assertEqual(s["frontiere"], "porte")
|
||||
self.assertEqual(s["hyperviseurs"], [{"nom": "noeud1", "adresses": {"transit-frontiere": "10.0.4.11"}}])
|
||||
|
||||
def test_locataire_heberge_ici_repris_la_bas(self):
|
||||
t = self.sites["SITE-Exemple"]["locataires"][0]
|
||||
self.assertEqual((t["nom"], t["vrf"], t["supernet"], t["ip_publique"]),
|
||||
("OPS-Exemple", "t19", "10.19.0.0/16", "203.0.113.11"))
|
||||
self.assertEqual([(z["vnet"], z["tag"], z["sous_reseau"], [v["ip"] for v in z["vms"]]) for z in t["zones"]],
|
||||
[("t19fron", vlan_de(19, 1), "10.19.16.0/24", ["10.19.16.11"]),
|
||||
("t19serv", vlan_de(19, 4), "10.19.19.0/24", ["10.19.19.11"])])
|
||||
self.assertEqual(self.sites["SITE-Autre"]["locataires"], [])
|
||||
r = self.sites["SITE-Autre"]["reprises"][0]
|
||||
self.assertEqual((r["nom"], r["ip_publique"], r["zones"]),
|
||||
("OPS-Exemple", "198.51.100.7", ["10.19.16.0/24", "10.19.19.0/24"]))
|
||||
|
||||
def test_lien_entre_les_sites(self):
|
||||
l = self.sites["SITE-Exemple"]["liens"][0]
|
||||
self.assertEqual((l["local"]["ip"], l["pair"]["site"], l["dns_public"]), ("172.30.0.1", "SITE-Autre", True))
|
||||
self.assertEqual(self.sites["SITE-Autre"]["liens"][0]["pair"]["point_arrivee"], "203.0.113.10:51820")
|
||||
|
||||
def test_hors_carte_dit_pourquoi(self):
|
||||
self.assertEqual(self.tout["hors_carte"],
|
||||
[{"nom": "OPS-Bac", "index": 21, "raison": "bac à sable local, non fédéré"}])
|
||||
|
||||
def test_portee_bornee_a_un_site(self):
|
||||
donnees = C.collecter(self.d, site="SITE-Autre")
|
||||
page = C.rendre(donnees)
|
||||
self.assertEqual([s["nom"] for s in donnees["sites"]], ["SITE-Autre"])
|
||||
self.assertIn("10.43.31.11", page)
|
||||
for ailleurs in ("10.41.31.11", "10.19.16.11", "10.19.19.11", "203.0.113.11", "alice-portable", "bob-portable"):
|
||||
self.assertNotIn(ailleurs, page, f"{ailleurs} appartient a un autre ecosysteme")
|
||||
with self.assertRaises(C.CarteRefusee):
|
||||
C.collecter(self.d, site="SITE-Inconnu")
|
||||
|
||||
def test_page_autonome_et_sans_fuite(self):
|
||||
page = C.rendre(self.tout)
|
||||
for g in self.tout["sites"]:
|
||||
for e in [g, *g["locataires"]]:
|
||||
for z in e["zones"]:
|
||||
for v in z["vms"]:
|
||||
self.assertIn(v["ip"], page)
|
||||
self.assertEqual(page.count("@font-face"), len(C.FACES))
|
||||
self.assertIn("data:font/woff2;base64,", page)
|
||||
self.assertEqual(set(re.findall(r"https?://[^\s\"'<>)]+", page)), {"http://www.w3.org/2000/svg"},
|
||||
"aucune ressource exterieure : la page s'ouvre hors ligne")
|
||||
for fuite in (CLE_SITE, CLE_PAIR, CLE_BOB, SECRET):
|
||||
self.assertNotIn(fuite, page)
|
||||
self.assertEqual(page.count("</script>"), 1, "un `</script>` venu d'un plan fermerait le script")
|
||||
|
||||
def test_script_de_la_page_se_lit(self):
|
||||
node = shutil.which("node")
|
||||
if not node:
|
||||
self.skipTest("node absent : syntaxe du script non verifiee")
|
||||
page = C.rendre(self.tout)
|
||||
with tempfile.NamedTemporaryFile("w", suffix=".js", delete=False, encoding="utf-8") as f:
|
||||
f.write(page[page.rindex("<script>") + 8:page.rindex("</script>")])
|
||||
try:
|
||||
r = subprocess.run([node, "--check", f.name], capture_output=True, text=True)
|
||||
finally:
|
||||
os.unlink(f.name)
|
||||
self.assertEqual(r.returncode, 0, r.stderr)
|
||||
|
||||
|
||||
class Sortie(unittest.TestCase):
|
||||
def test_jamais_dans_le_moteur_public(self):
|
||||
with self.assertRaises(C.CarteRefusee):
|
||||
C.verifier_sortie(RACINE / "docs" / "carte.html")
|
||||
with self.assertRaises(C.CarteRefusee):
|
||||
C.verifier_sortie(RACINE / "carte.html")
|
||||
self.assertEqual(C.verifier_sortie(RACINE / "tmp" / "carte.html"), RACINE / "tmp" / "carte.html")
|
||||
dehors = RACINE.parent / "SITE-Quelconque" / "carte.html"
|
||||
self.assertEqual(C.verifier_sortie(dehors), dehors.resolve())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main(verbosity=2)
|
||||
Loading…
Reference in a new issue