[PATCH 11/20] Set and refresh BlockDev's global LVM config if needed
vpodzime
installerbot-noreply at redhat.com
Fri Feb 27 15:31:52 UTC 2015
From: Vratislav Podzimek <vpodzime at redhat.com>
BlockDev now runs all the lvm utilities for us so we need to set it the global
config if we want any.
---
blivet/devicelibs/lvm.py | 29 +++++++++++++++--------------
1 file changed, 15 insertions(+), 14 deletions(-)
diff --git a/blivet/devicelibs/lvm.py b/blivet/devicelibs/lvm.py
index 1fd22de..f48743c 100644
--- a/blivet/devicelibs/lvm.py
+++ b/blivet/devicelibs/lvm.py
@@ -21,6 +21,7 @@
#
from collections import namedtuple
+from gi.repository import BlockDev as blockdev
import logging
log = logging.getLogger("blivet")
@@ -54,16 +55,9 @@
config_args_data = { "filterRejects": [], # regular expressions to reject.
"filterAccepts": [] } # regexp to accept
-def _getConfigArgs(args):
+def _set_global_config():
"""lvm command accepts lvm.conf type arguments preceded by --config. """
- # These commands are read-only, so we can run them with read-only locking.
- # (not an exhaustive list, but these are the only ones used here)
- READONLY_COMMANDS = ('lvs', 'pvs', 'vgs')
-
- cmd = args[0]
- config_args = []
-
filter_string = ""
rejects = config_args_data["filterRejects"]
for reject in rejects:
@@ -82,19 +76,26 @@ def _getConfigArgs(args):
# "preferred_names", "filter", "cache_dir", "write_cache_state",
# "types", "sysfs_scan", "md_component_detection". see man lvm.conf.
config_string = " devices { %s } " % (devices_string) # strings can be added
- if cmd in READONLY_COMMANDS:
- config_string += "global {locking_type=4} "
if not flags.lvm_metadata_backup:
config_string += "backup {backup=0 archive=0} "
- if config_string:
- config_args = ["--config", config_string]
- return config_args
+ blockdev.lvm_set_global_config(config_string)
+
+def needs_config_refresh(fn):
+ def fn_with_refresh(*args, **kwargs):
+ ret = fn(*args, **kwargs)
+ _set_global_config()
+ return ret
+
+ return fn_with_refresh
+
+ at needs_config_refresh
def lvm_cc_addFilterRejectRegexp(regexp):
""" Add a regular expression to the --config string."""
log.debug("lvm filter: adding %s to the reject list", regexp)
config_args_data["filterRejects"].append(regexp)
+ at needs_config_refresh
def lvm_cc_removeFilterRejectRegexp(regexp):
""" Remove a regular expression from the --config string."""
log.debug("lvm filter: removing %s from the reject list", regexp)
@@ -104,7 +105,7 @@ def lvm_cc_removeFilterRejectRegexp(regexp):
log.debug("%s wasn't in the reject list", regexp)
return
+ at needs_config_refresh
def lvm_cc_resetFilter():
config_args_data["filterRejects"] = []
config_args_data["filterAccepts"] = []
-# End config_args handling code.
--
To view this commit on github, visit https://github.com/rhinstaller/blivet/commit/067dba196cc8d05813dd7f781e17c70e632d2f2f
More information about the anaconda-patches
mailing list