From a344fc807b59e45e1174e1a50c5b47e8090b12ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mina=20Gali=C4=87?= Date: Tue, 30 Jan 2024 23:39:17 +0000 Subject: [PATCH] distro: add eject FreeBSD code path OpenBSD, and NetBSD both have an eject(1), so they should be covered in the default code path. FreeBSD and Dragonfly however, do not have eject in base. Here, eject is an (unmaintained) port. In base, we do however, have camcontrol(8) and cdcontrol(1), both of which have an eject subcommand. Let's use camcontrol(8) here. Sponsored by: The FreeBSD Foundation --- cloudinit/distros/freebsd.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cloudinit/distros/freebsd.py b/cloudinit/distros/freebsd.py index 89880578fde..53b4ac4eb3b 100644 --- a/cloudinit/distros/freebsd.py +++ b/cloudinit/distros/freebsd.py @@ -226,3 +226,7 @@ def build_dhclient_cmd( return [path, "-l", lease_file, "-p", pid_file] + ( ["-c", config_file, interface] if config_file else [interface] ) + + @staticmethod + def eject_media(device: str) -> None: + subp.subp(["camcontrol", "eject", device])