remember if lvm is not installed

This commit is contained in:
lars 2008-01-14 20:46:42 +00:00
parent f239a27169
commit 4c634d3f9a
1 changed files with 21 additions and 0 deletions

View File

@ -34,6 +34,12 @@ import time
import logging
import cryptobox.core.settings
OPTIONAL_PROGS = { "lvm": True }
"""remember which programs don't exist to avoid calling them in vain
change default values from "True" to "False" to disable the respective program
"""
LOGGER = logging.getLogger("CryptoBox")
DEFAULT_SYSBLOCK_DIR = '/sys/block'
@ -510,6 +516,9 @@ class Blockdevice:
def __get_uuid_lvm_pv(self):
"""determine the unique identifier of physical LVM volumes
"""
if not OPTIONAL_PROGS["lvm"]:
## pvdisplay is not installed - skip it
return None
prefs = _load_preferences()
try:
proc = subprocess.Popen(
@ -524,6 +533,11 @@ class Blockdevice:
LOGGER.warning("Failed to call '%s' via 'super' to determine " \
% prefs["Programs"]["pvdisplay"] + "UUID: %s" % err_msg)
return None
if proc.returncode == 101:
## pvdisplay is not installed
OPTIONAL_PROGS["lvm"] = False
LOGGER.warning("'lvm' is not installed - I will not try it again")
return None
if proc.returncode != 0:
LOGGER.warning("Execution of 'pvdisplay' failed: %s" % error)
return None
@ -837,6 +851,8 @@ def find_blockdevices(top_dir):
def find_lvm_pv():
"""return the blockdevice names of all physical LVM volumes
"""
if not OPTIONAL_PROGS["lvm"]:
return []
cache_link = ["lvm", "pv"]
cached = CACHE.get(cache_link)
if not cached is None:
@ -856,6 +872,11 @@ def find_lvm_pv():
except OSError, err_msg:
LOGGER.info("Failed to call 'pvdisplay' via 'super': %s" % err_msg)
result = []
if proc.returncode == 101:
## pvdisplay is not installed
OPTIONAL_PROGS["lvm"] = False
LOGGER.warning("'lvm' is not installed - I will not try it again")
return []
if proc.returncode != 0:
LOGGER.info("Execution of 'pvdisplay' failed: %s" % error.strip())
result = []