Blame SOURCES/0017-Add-flag-for-protecting-cdrom-devices-during-populate.patch

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