Skip to content

Commit

Permalink
To be squashed
Browse files Browse the repository at this point in the history
In response to Brett's suggestion that we explicitly try eject
options rather than making assumptions about systemd.  Keeping
this as a separate commit so we can see the options.
  • Loading branch information
catmsred committed Jan 30, 2024
1 parent 7e5413a commit 32f5a5c
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions cloudinit/distros/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1316,9 +1316,17 @@ def _get_proc_stat_by_index(pid: int, field: int) -> Optional[int]:

@staticmethod
def eject_media(device: str) -> None:
cmd = ["/lib/udev/cdrom_id", "--eject-media", device]
if not uses_systemd():
cmd = None
if subp.which("eject"):
cmd = ["eject", device]
elif subp.which("/lib/udev/cdrom_id"):
cmd = ["/lib/udev/cdrom_id", "--eject-media", device]
else:
raise subp.ProcessExecutionError(
cmd="eject_media_cmd",
description="eject command not found",
reason="neither eject nor /lib/udev/cdrom_id are found",
)
subp.subp(cmd)

def _apply_hostname_transformations_to_url(url: str, transformations: list):
Expand Down

0 comments on commit 32f5a5c

Please sign in to comment.