set_hostname() for Linux hosts, so netOrk's apply-hostname works for them (netOrk side: NetOrk/netork#1671).
Short name via hostnamectl, or /etc/hostname + hostname(1) without systemd
/etc/hosts: lines naming the old name rewritten, else the 127.0.1.1 line; otherwise untouched (nothing appended)
cloud-init hosts: /etc/cloud/cloud.cfg.d/99-preserve-hostname.cfg with preserve_hostname: true
RFC 1123 validation before anything runs; files staged unprivileged and installed by root
In its own module (_hostname.py, HostnameMixin) because linux.py may not grow under the quality ratchet; baseline 2288 → 2286.
Not in scope: /etc/mailname/Postfix, and sharing code with napalm-proxmox's own set_hostname (that belongs to the napalm-unix split, NetOrk/netork#1105).
Tests: 253 passed (32 new), ruff, mypy, napalm-standard ratchet and check green locally.
Closes #45
`set_hostname()` for Linux hosts, so netOrk's apply-hostname works for them (netOrk side: NetOrk/netork#1671).
- Short name via `hostnamectl`, or `/etc/hostname` + `hostname(1)` without systemd
- `/etc/hosts`: lines naming the old name rewritten, else the `127.0.1.1` line; otherwise untouched (nothing appended)
- cloud-init hosts: `/etc/cloud/cloud.cfg.d/99-preserve-hostname.cfg` with `preserve_hostname: true`
- RFC 1123 validation before anything runs; files staged unprivileged and installed by root
In its own module (`_hostname.py`, `HostnameMixin`) because `linux.py` may not grow under the quality ratchet; baseline 2288 → 2286.
Not in scope: `/etc/mailname`/Postfix, and sharing code with napalm-proxmox's own `set_hostname` (that belongs to the napalm-unix split, NetOrk/netork#1105).
Tests: 253 passed (32 new), ruff, mypy, `napalm-standard ratchet` and `check` green locally.
netOrk could save a Linux host's new name but not apply it: the driver had
no set_hostname(), so apply-hostname answered "The driver linux does not
support set_hostname()".
HostnameMixin.set_hostname() takes a bare name or an FQDN. The short name
goes to hostnamectl, or to /etc/hostname and hostname(1) without systemd.
/etc/hosts follows: every line naming the old name, else the 127.0.1.1
line; a file with neither is left alone. A cloud-init host gets
preserve_hostname: true, or its next boot restores the image's name.
Names that are not RFC 1123 hostnames are refused before anything runs.
Files are staged unprivileged and installed by root
(_install_file_as_root), never written from privileged stdin.
It lives in its own module because linux.py may not grow (quality
ratchet); the two lines it adds there are offset by a stale comment and
an import that fits on one line, so the baseline drops to 2286.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Closes #45
set_hostname()for Linux hosts, so netOrk's apply-hostname works for them (netOrk side: NetOrk/netork#1671).hostnamectl, or/etc/hostname+hostname(1)without systemd/etc/hosts: lines naming the old name rewritten, else the127.0.1.1line; otherwise untouched (nothing appended)/etc/cloud/cloud.cfg.d/99-preserve-hostname.cfgwithpreserve_hostname: trueIn its own module (
_hostname.py,HostnameMixin) becauselinux.pymay not grow under the quality ratchet; baseline 2288 → 2286.Not in scope:
/etc/mailname/Postfix, and sharing code with napalm-proxmox's ownset_hostname(that belongs to the napalm-unix split, NetOrk/netork#1105).Tests: 253 passed (32 new), ruff, mypy,
napalm-standard ratchetandcheckgreen locally.