From ac5646f8e9e59389bdc651c63b5e7dcd2d693bf4 Mon Sep 17 00:00:00 2001 From: Radek Vykydal Date: Wed, 22 May 2019 13:35:01 +0200 Subject: [PATCH] Add flag for protecting cdrom devices during populate Resolves: rhbz#1719648 --- blivet/devices/optical.py | 14 ++++++++++++++ blivet/flags.py | 3 +++ 2 files changed, 17 insertions(+) diff --git a/blivet/devices/optical.py b/blivet/devices/optical.py index b9dba1f2..122825f2 100644 --- a/blivet/devices/optical.py +++ b/blivet/devices/optical.py @@ -24,6 +24,7 @@ from .. import errors from .. import util from ..storage_log import log_method_call +from ..flags import flags import logging log = logging.getLogger("blivet") @@ -81,3 +82,16 @@ def eject(self): util.run_program(["eject", self.name]) except OSError as e: log.warning("error ejecting cdrom %s: %s", self.name, e) + + @property + def protected(self): + protected = super(OpticalDevice, self).protected + + if flags.protect_cdroms: + return True + else: + return protected + + @protected.setter + def protected(self, value): + self._protected = value diff --git a/blivet/flags.py b/blivet/flags.py index 6500be30..a6a78edc 100644 --- a/blivet/flags.py +++ b/blivet/flags.py @@ -77,6 +77,9 @@ def __init__(self): # (so far only for LUKS) self.discard_new = False + # whether cdroms should be protected + self.protect_cdroms = False + self.boot_cmdline = {} self.update_from_boot_cmdline()