set_hostname: the linux driver cannot rename a host #45

Closed
opened 2026-10-29 20:17:14 +00:00 by christianmanivong · 1 comment
Owner

Priority: P3 — important, not urgent. The hostname is still saved in netOrk; it just never reaches the host.

What happens

Changing a Linux device's hostname on its netOrk detail page saves it, then shows:

Hostname saved, but could not be applied to device: The driver linux does not support set_hostname()

netOrk's POST /devices/{id}/apply-hostname checks implements(driver_cls, "set_hostname") before connecting, and LinuxDriver (pin c00deef, also main) has no such method. OPNsense, Proxmox and OpenWrt implement it.

What it needs

set_hostname(new_hostname) on LinuxDriver, accepting a bare name or an FQDN:

  • hostnamectl set-hostname <short> where systemd is present, falling back to writing /etc/hostname + hostname <short>.
  • /etc/hosts: replace the old name on the 127.0.1.1 line (Debian/Ubuntu convention) with <fqdn> <short> or <short>; leave other lines alone.
  • Validate the name (RFC 1123 labels) before anything is written, since it ends up in a privileged shell.
  • /etc/mailname and cloud-init's preserve_hostname are worth a look: on a cloud-init host, an unset preserve_hostname reverts the name on the next boot.

napalm-proxmox's set_hostname (system_mixin.py) already does the Debian file edits; the shared part could move to a common place rather than being written twice.

Related netOrk ticket: the UI attempts the apply for drivers that lack the method (filed alongside this one).

Priority: P3 — important, not urgent. The hostname is still saved in netOrk; it just never reaches the host. ## What happens Changing a Linux device's hostname on its netOrk detail page saves it, then shows: > Hostname saved, but could not be applied to device: The driver linux does not support set_hostname() netOrk's `POST /devices/{id}/apply-hostname` checks `implements(driver_cls, "set_hostname")` before connecting, and `LinuxDriver` (pin `c00deef`, also `main`) has no such method. OPNsense, Proxmox and OpenWrt implement it. ## What it needs `set_hostname(new_hostname)` on `LinuxDriver`, accepting a bare name or an FQDN: - `hostnamectl set-hostname <short>` where systemd is present, falling back to writing `/etc/hostname` + `hostname <short>`. - `/etc/hosts`: replace the old name on the `127.0.1.1` line (Debian/Ubuntu convention) with `<fqdn> <short>` or `<short>`; leave other lines alone. - Validate the name (RFC 1123 labels) before anything is written, since it ends up in a privileged shell. - `/etc/mailname` and cloud-init's `preserve_hostname` are worth a look: on a cloud-init host, an unset `preserve_hostname` reverts the name on the next boot. `napalm-proxmox`'s `set_hostname` (`system_mixin.py`) already does the Debian file edits; the shared part could move to a common place rather than being written twice. Related netOrk ticket: the UI attempts the apply for drivers that lack the method (filed alongside this one).
Author
Owner

netOrk side: NetOrk/netork#1671

netOrk side: NetOrk/netork#1671
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: NAPALM/napalm-linux#45