feat: set_hostname renames the host (#45)
driver / standard (pull_request) Successful in 18s
driver / lint (pull_request) Successful in 14s
driver / types (pull_request) Successful in 1m12s
driver / test (3.12) (pull_request) Successful in 1m11s
driver / test (3.13) (pull_request) Successful in 1m6s
driver / lowest (pull_request) Successful in 29s
driver / build (pull_request) Successful in 32s
driver / security (pull_request) Successful in 1m14s
CI / driver (pull_request) Successful in 1m15s
driver / publish (pull_request) Skipped
driver / standard (pull_request) Successful in 18s
driver / lint (pull_request) Successful in 14s
driver / types (pull_request) Successful in 1m12s
driver / test (3.12) (pull_request) Successful in 1m11s
driver / test (3.13) (pull_request) Successful in 1m6s
driver / lowest (pull_request) Successful in 29s
driver / build (pull_request) Successful in 32s
driver / security (pull_request) Successful in 1m14s
CI / driver (pull_request) Successful in 1m15s
driver / publish (pull_request) Skipped
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.
This commit is contained in:
1 parent
b6677c9fc5
commit
4108eb83dd
5 files changed
+446
-6
No files matched your search
@@ -69,11 +69,9 @@ from napalm_device_types.models import (
|
||||
)
|
||||
from napalm_device_types.ssh_host_keys import HostKeyCheck
|
||||
from netmiko import ConnectHandler
|
||||
from netmiko.exceptions import (
|
||||
NetmikoAuthenticationException,
|
||||
NetmikoTimeoutException,
|
||||
)
|
||||
from netmiko.exceptions import NetmikoAuthenticationException, NetmikoTimeoutException
|
||||
|
||||
from napalm_linux._hostname import HostnameMixin
|
||||
from napalm_linux._shell import PROMPT_RE as _PROMPT_RE
|
||||
from napalm_linux._shell import prepare_shell
|
||||
|
||||
@@ -321,6 +319,7 @@ class LinuxDriver(
|
||||
SystemdServicesMixin,
|
||||
HostStatusMixin,
|
||||
ContainerEngineMixin,
|
||||
HostnameMixin,
|
||||
OSDriver,
|
||||
):
|
||||
"""NAPALM driver for generic Linux systems.
|
||||
@@ -367,7 +366,6 @@ class LinuxDriver(
|
||||
self._secret: str = optional_args.get("secret", password)
|
||||
# Optional sudo password for privilege escalation (e.g. apt-get update)
|
||||
self._sudo_password: str | None = optional_args.get("sudo_password")
|
||||
# Expected apt proxy URL — checked as a device warning on apt systems.
|
||||
|
||||
if optional_args.get("debugging"):
|
||||
logger.setLevel(logging.DEBUG)
|
||||
|
||||
Reference in new issue
Block a user