* changed importance of some log messages
* use "sfdisk -R" instead of "blockdev --rereadpt" in order to avoid an additinal dependency * removed obsolete sort function for block devices
This commit is contained in:
parent
ffb8f841be
commit
f389508ed8
|
@ -440,7 +440,8 @@ class partition(cryptobox.plugins.base.CryptoBoxPlugin):
|
|||
(output, error) = proc.communicate()
|
||||
fdisk_status = proc.returncode
|
||||
if fdisk_status != 0:
|
||||
self.cbox.log.debug("partitioning failed: %s" % error)
|
||||
self.cbox.log.error("partitioning of '%s' failed: %s" % \
|
||||
(self.blockdevice.get_device(), error))
|
||||
##Every time we update a partition table, force the kernel
|
||||
##to reread it and update /proc/partitions. This particularly
|
||||
##applies to internal hard disks.
|
||||
|
@ -459,7 +460,8 @@ class partition(cryptobox.plugins.base.CryptoBoxPlugin):
|
|||
(output, error) = rereadpt_proc.communicate()
|
||||
rereadpt_status = rereadpt_proc.returncode
|
||||
if rereadpt_status != 0:
|
||||
self.cbox.log.info("failed to reread the modified partition table: %s" % error)
|
||||
self.cbox.log.warn("failed to reread the modified partition table "
|
||||
+ "of '%s': %s" % (self.blockdevice.get_device(), error))
|
||||
# refresh the device list
|
||||
self.cbox.reread_container_list()
|
||||
# update the current blockdevice - especially the new partitioned children
|
||||
|
|
|
@ -25,7 +25,6 @@ __revision__ = "$Id$"
|
|||
## necessary: otherwise CryptoBoxRootActions.py will refuse to execute this script
|
||||
PLUGIN_TYPE = "cryptobox"
|
||||
|
||||
BLKDEV_BIN = "/sbin/blockdev"
|
||||
SFDISK_BIN = "/sbin/sfdisk"
|
||||
MKFS_BIN = "/sbin/mkfs"
|
||||
LABEL_BIN = "/sbin/e2label"
|
||||
|
@ -40,6 +39,9 @@ def __partitionDevice(device):
|
|||
## do not use the "-q" flag, as this spoils the exit code of sfdisk (seems to be a bug)
|
||||
proc = subprocess.Popen(
|
||||
shell = False,
|
||||
stdin = subprocess.PIPE,
|
||||
stdout = subprocess.PIPE,
|
||||
stderr = subprocess.PIPE,
|
||||
args = [
|
||||
SFDISK_BIN,
|
||||
"-uM",
|
||||
|
@ -47,16 +49,21 @@ def __partitionDevice(device):
|
|||
proc.wait()
|
||||
return proc.returncode == 0
|
||||
|
||||
|
||||
def __rereadPartitions(device):
|
||||
proc = subprocess.Popen(
|
||||
shell = False,
|
||||
stdin = subprocess.PIPE,
|
||||
stdout = subprocess.PIPE,
|
||||
stderr = subprocess.PIPE,
|
||||
args = [
|
||||
BLKDEV_BIN,
|
||||
"--rereadpt",
|
||||
SFDISK_BIN,
|
||||
"-R",
|
||||
device])
|
||||
proc.wait()
|
||||
return proc.returncode == 0
|
||||
|
||||
|
||||
def __formatPartition(device, type):
|
||||
import time, threading
|
||||
result = True
|
||||
|
|
|
@ -207,7 +207,7 @@ class Blockdevice:
|
|||
if os.path.exists(dev):
|
||||
return dev
|
||||
# none of the device nodes exists
|
||||
self.cbox.log.warn("No valid device node found for %s out of %s" % \
|
||||
LOGGER.warn("No valid device node found for %s out of %s" % \
|
||||
(self.name, str(self.devnodes)))
|
||||
return None
|
||||
|
||||
|
@ -970,25 +970,6 @@ def find_lvm_pv():
|
|||
return result[:]
|
||||
|
||||
|
||||
def get_sorted_devices(names):
|
||||
"""return the names of devices in a sorted order
|
||||
|
||||
e.g.: "hda1", "hda5", "hda6", ..., "hda10", "hda11"
|
||||
"""
|
||||
# TODO: implement this for devicenames like "hda12"
|
||||
def compare_device_names(x, y):
|
||||
if x.name < y.name:
|
||||
return -1
|
||||
elif x.name == y.name:
|
||||
return 0
|
||||
else:
|
||||
return 1
|
||||
|
||||
result = names[:]
|
||||
result.sort(cmp=compare_device_names)
|
||||
return result
|
||||
|
||||
|
||||
def _load_preferences():
|
||||
prefs = cryptobox.core.settings.get_current_settings()
|
||||
if not prefs is None:
|
||||
|
|
Loading…
Reference in New Issue