neil / rpms / python-blivet

Forked from rpms/python-blivet a year ago
Clone

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

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