* added some triggers for refreshing the cache after partitioning
* added more error checking for unavailable devices * fixed a wrong template name
This commit is contained in:
parent
7b0de22e3a
commit
94102a3575
|
@ -70,7 +70,7 @@ class partition(cryptobox.plugins.base.CryptoBoxPlugin):
|
||||||
if not self.blockdevice:
|
if not self.blockdevice:
|
||||||
return self.__action_select_device()
|
return self.__action_select_device()
|
||||||
## exit if the blockdevice is not writeable
|
## exit if the blockdevice is not writeable
|
||||||
if not os.access(self.blockdevice.devnodes[0], os.W_OK):
|
if not os.access(self.blockdevice.get_device(), os.W_OK):
|
||||||
self.hdf["Data.Warning"] = "DeviceNotWriteable"
|
self.hdf["Data.Warning"] = "DeviceNotWriteable"
|
||||||
return self.__action_select_device()
|
return self.__action_select_device()
|
||||||
## no confirm setting?
|
## no confirm setting?
|
||||||
|
@ -191,7 +191,7 @@ class partition(cryptobox.plugins.base.CryptoBoxPlugin):
|
||||||
self.hdf[self.hdf_prefix + "BlockDevices.%d.size" % counter] = \
|
self.hdf[self.hdf_prefix + "BlockDevices.%d.size" % counter] = \
|
||||||
dev.size_human
|
dev.size_human
|
||||||
self.cbox.log.debug("found a suitable block device: %s" % \
|
self.cbox.log.debug("found a suitable block device: %s" % \
|
||||||
dev.devnodes[0])
|
dev.get_device())
|
||||||
counter += 1
|
counter += 1
|
||||||
if self.with_config_partition:
|
if self.with_config_partition:
|
||||||
self.hdf[self.hdf_prefix + "CreateConfigPartition"] = "1"
|
self.hdf[self.hdf_prefix + "CreateConfigPartition"] = "1"
|
||||||
|
@ -273,6 +273,7 @@ class partition(cryptobox.plugins.base.CryptoBoxPlugin):
|
||||||
## return the result
|
## return the result
|
||||||
if not result:
|
if not result:
|
||||||
format_ok = False
|
format_ok = False
|
||||||
|
self.cbox.reread_container_list()
|
||||||
if format_ok:
|
if format_ok:
|
||||||
self.hdf["Data.Success"] = "Plugins.partition.Partitioned"
|
self.hdf["Data.Success"] = "Plugins.partition.Partitioned"
|
||||||
return { "plugin":"system_preferences", "values":[] }
|
return { "plugin":"system_preferences", "values":[] }
|
||||||
|
@ -311,7 +312,7 @@ class partition(cryptobox.plugins.base.CryptoBoxPlugin):
|
||||||
## operation failed
|
## operation failed
|
||||||
self.hdf["Data.Warning"] = "Plugins.partition.FormattingFailed"
|
self.hdf["Data.Warning"] = "Plugins.partition.FormattingFailed"
|
||||||
self.cbox.log.info("easy partitioning failed")
|
self.cbox.log.info("easy partitioning failed")
|
||||||
return "select_partitions"
|
return "set_partitions"
|
||||||
else:
|
else:
|
||||||
## operation was successful
|
## operation was successful
|
||||||
self.hdf["Data.Success"] = "Plugins.partition.EasySetup"
|
self.hdf["Data.Success"] = "Plugins.partition.EasySetup"
|
||||||
|
@ -429,7 +430,7 @@ class partition(cryptobox.plugins.base.CryptoBoxPlugin):
|
||||||
"plugin",
|
"plugin",
|
||||||
os.path.join(self.plugin_dir, "root_action.py"),
|
os.path.join(self.plugin_dir, "root_action.py"),
|
||||||
"partition",
|
"partition",
|
||||||
self.blockdevice.devnodes[0]])
|
self.blockdevice.get_device()])
|
||||||
for line in self.__get_sfdisk_layout(parts, is_filled):
|
for line in self.__get_sfdisk_layout(parts, is_filled):
|
||||||
proc.stdin.write(line + "\n")
|
proc.stdin.write(line + "\n")
|
||||||
#TODO: if running inside of an uml, then sfdisk hangs at "nanosleep({3,0})"
|
#TODO: if running inside of an uml, then sfdisk hangs at "nanosleep({3,0})"
|
||||||
|
@ -453,11 +454,15 @@ class partition(cryptobox.plugins.base.CryptoBoxPlugin):
|
||||||
"plugin",
|
"plugin",
|
||||||
os.path.join(self.plugin_dir, "root_action.py"),
|
os.path.join(self.plugin_dir, "root_action.py"),
|
||||||
"rereadpt",
|
"rereadpt",
|
||||||
self.blockdevice.devnodes[0]])
|
self.blockdevice.get_device()])
|
||||||
(output, error) = rereadpt_proc.communicate()
|
(output, error) = rereadpt_proc.communicate()
|
||||||
rereadpt_status = rereadpt_proc.returncode
|
rereadpt_status = rereadpt_proc.returncode
|
||||||
if rereadpt_status != 0:
|
if rereadpt_status != 0:
|
||||||
self.cbox.log.info("failed to reread the modified partition table: %s" % error)
|
self.cbox.log.info("failed to reread the modified partition table: %s" % error)
|
||||||
|
# refresh the device list
|
||||||
|
self.cbox.reread_container_list()
|
||||||
|
# update the blockdevice - especially the new partitioned children
|
||||||
|
self.blockdevice.reset()
|
||||||
return (fdisk_status == 0)
|
return (fdisk_status == 0)
|
||||||
|
|
||||||
|
|
||||||
|
@ -536,17 +541,23 @@ class partition(cryptobox.plugins.base.CryptoBoxPlugin):
|
||||||
## filter the storage devices
|
## filter the storage devices
|
||||||
for child in blockdev.children:
|
for child in blockdev.children:
|
||||||
childdev = blockdevice_tools.get_blockdevice(child)
|
childdev = blockdevice_tools.get_blockdevice(child)
|
||||||
|
self.cbox.log.debug("Checking child device: %s - %s" % \
|
||||||
|
(blockdev, child))
|
||||||
if childdev and childdev.is_storage():
|
if childdev and childdev.is_storage():
|
||||||
valid_children.append(childdev)
|
valid_children.append(childdev)
|
||||||
sorted = blockdevice_tools.get_sorted_devices(valid_children)
|
valid_children.sort()
|
||||||
if number <= len(sorted):
|
self.cbox.log.debug("Valid children of %s: %s" % \
|
||||||
childdev = sorted[number-1]
|
(blockdev, [child.name for child in valid_children]))
|
||||||
|
if number <= len(valid_children):
|
||||||
|
childdev = valid_children[number-1]
|
||||||
if childdev:
|
if childdev:
|
||||||
return childdev.devnodes[0]
|
return childdev.get_device()
|
||||||
self.cbox.log.warn("Failed to get the partition name (%s, %d)" % \
|
|
||||||
(blockdev, number))
|
|
||||||
## return some guessed value - we should never get here ...
|
## return some guessed value - we should never get here ...
|
||||||
return "%s%d" % (blockdev.devnodes[0], number)
|
guess = "%s%d" % (blockdev.get_device(), number)
|
||||||
|
self.cbox.log.warn("Failed to get the partition name (%s, %d)" % \
|
||||||
|
(blockdev, number) + " - proceeding with guessed name: %s" % \
|
||||||
|
guess)
|
||||||
|
return guess
|
||||||
|
|
||||||
|
|
||||||
def __format_one_partition(self, dev_name, fs_type):
|
def __format_one_partition(self, dev_name, fs_type):
|
||||||
|
@ -559,8 +570,13 @@ class partition(cryptobox.plugins.base.CryptoBoxPlugin):
|
||||||
## call "mkfs"
|
## call "mkfs"
|
||||||
try:
|
try:
|
||||||
format_dev = blockdevice_tools.get_blockdevice(dev_name)
|
format_dev = blockdevice_tools.get_blockdevice(dev_name)
|
||||||
cont = cryptobox.core.container.CryptoBoxContainer(format_dev, self.cbox)
|
if format_dev is None:
|
||||||
cont.create(cryptobox.core.container.CONTAINERTYPES["plain"], fs_type=fs_type)
|
self.cbox.log.warn("Could not find the specified device: %s" % \
|
||||||
|
str(format_dev))
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
cont = cryptobox.core.container.CryptoBoxContainer(format_dev, self.cbox)
|
||||||
|
cont.create(cryptobox.core.container.CONTAINERTYPES["plain"], fs_type=fs_type)
|
||||||
except (CBInvalidType, CBCreateError, CBVolumeIsActive), err_msg:
|
except (CBInvalidType, CBCreateError, CBVolumeIsActive), err_msg:
|
||||||
self.cbox.log.warn(err_msg)
|
self.cbox.log.warn(err_msg)
|
||||||
return False
|
return False
|
||||||
|
|
Loading…
Reference in a new issue