feat: say whether a host is still in its first boot
CI / test (3.10) (push) Successful in 29s
CI / test (3.11) (push) Successful in 30s
CI / test (3.12) (push) Successful in 29s
CI / test (3.10) (pull_request) Successful in 29s
CI / test (3.11) (pull_request) Successful in 46s
CI / test (3.12) (pull_request) Successful in 42s

first_boot_pending() is true while /firstboot exists on FreeBSD. A FreeBSD
cloud image upgrades its base system on its first boot, starts sshd only
after that and restarts right away, and /etc/rc removes /firstboot just
before that restart. netOrk waits for this before it sets up a new VM
(NetOrk/netork#795).

OpenBSD has no such marker to ask yet, so it returns False there.
This commit is contained in:
Christian Manivong
2026-10-08 12:58:00 +02:00
parent ae09e44345
commit 32a63411d3
5 changed files with 49 additions and 0 deletions
+15
View File
@@ -188,6 +188,21 @@ class BsdDriver(HostStatusMixin, OSDriver):
and the readers below treat empty output as "nothing there"."""
return self.run_command(command, privileged=privileged, timeout=timeout).stdout.strip()
#: A file that exists until the host's first boot is over; "" when there is none to ask.
FIRST_BOOT_MARKER = ""
def first_boot_pending(self) -> bool:
"""Whether the host is still in its first boot.
A FreeBSD cloud image upgrades its base system on the first boot, starts
sshd only after that and restarts right away; ``/etc/rc`` removes
``/firstboot`` just before the restart. netOrk waits for this before it
sets up a new VM (NetOrk/netork#795).
"""
if not self.FIRST_BOOT_MARKER:
return False
return self.run_command(f"test -e {self.FIRST_BOOT_MARKER}").exit_code == 0
def _run_host_status_command(self, command: str) -> str:
"""The transport for ``HostStatusMixin.get_host_status``: read-only, no root.
+2
View File
@@ -31,6 +31,8 @@ class FreeBSDDriver(BsdDriver):
ROUTES_COMMAND = "netstat -rnW"
# sockstat names the process of every socket it can see; root sees them all.
LISTENING_COMMAND = "sockstat -46lq -P tcp,udp"
# /etc/rc removes it at the end of the first boot.
FIRST_BOOT_MARKER = "/firstboot"
def _parse_listening(self, output: str, *, attributed: bool) -> list[dict]:
return parse.sockstat(output)