[FIX] qemu ssh: one name per Host, the chained one
A nested VM was written as « Host erplibre-ubuntu-2404 test-vm_02+erplibre-ubuntu-2404 » — two patterns on one Host line. Valid ssh syntax, but the short name only repeats the tail of the chain and buys nothing, so it is gone. Nested hosts now carry the chained name alone. Existing configs repair themselves: replacing a block drops any whose name list intersects the new one, so the old two-name line is removed as a whole and rewritten with the single chained name — no stale short entry left behind. Verified on a config holding exactly the reported line, alongside an unrelated host that must survive. The naming rule is simpler too: a chain cannot collide with another machine, so there is no case left where a short name has to be preferred or avoided. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
4205c0c0e3
commit
32d25b5344
1 changed files with 9 additions and 19 deletions
|
|
@ -1664,9 +1664,7 @@ class TODO:
|
|||
self._write_ssh_config_entry(
|
||||
name, "erplibre", ip, identity_file=identity
|
||||
)
|
||||
entries.append(
|
||||
{"names": [name], "ip": ip, "parent": None, "chain": name}
|
||||
)
|
||||
entries.append({"names": [name], "ip": ip, "parent": None})
|
||||
taken.add(name)
|
||||
chain_of[name] = name
|
||||
frontier.append(name)
|
||||
|
|
@ -1703,33 +1701,25 @@ class TODO:
|
|||
if not ip:
|
||||
print(f" ⏭ {parent} › {child}: {t('no IP')}")
|
||||
continue
|
||||
# Le nom CHAÎNÉ dit où vit la VM ; le nom court est plus
|
||||
# agréable à taper. UN SEUL bloc porte les deux — ssh
|
||||
# accepte plusieurs noms sur la ligne Host — et le court
|
||||
# n'est retenu que s'il est libre, pour ne jamais masquer
|
||||
# une autre machine.
|
||||
# UN SEUL nom, le nom CHAÎNÉ : il dit où vit la VM et ne
|
||||
# peut heurter aucune autre machine. Y ajouter le nom
|
||||
# court ne ferait que répéter la fin de la chaîne.
|
||||
chain = f"{chain_of[parent]}+{child}"
|
||||
if chain in taken:
|
||||
continue # déjà vu (cycle)
|
||||
names = [chain] if child in taken else [child, chain]
|
||||
self._write_ssh_config_entry(
|
||||
names,
|
||||
chain,
|
||||
"erplibre",
|
||||
ip,
|
||||
proxy_jump=parent,
|
||||
identity_file=identity,
|
||||
)
|
||||
entries.append(
|
||||
{
|
||||
"names": names,
|
||||
"ip": ip,
|
||||
"parent": parent,
|
||||
"chain": chain,
|
||||
}
|
||||
{"names": [chain], "ip": ip, "parent": parent}
|
||||
)
|
||||
taken.update(names)
|
||||
chain_of[names[0]] = chain
|
||||
next_frontier.append(names[0])
|
||||
taken.add(chain)
|
||||
chain_of[chain] = chain
|
||||
next_frontier.append(chain)
|
||||
frontier = next_frontier
|
||||
|
||||
print(f"\n── {t('SSH hosts written')} ──")
|
||||
|
|
|
|||
Loading…
Reference in a new issue