URLs changed to new plugin addressing scheme

svn:keywords set
fixed: shutdown - delay reboot/poweroff by some seconds to finish the web page before
added: format_fs - show link to umount in case of active device
added: new plugin "language_selection"
fixed: recently introduced syntax error in 'network'
added: "volume_props" mentions encryption support via "format_fs" (including link)
updated: plugin-interface.txt
fixed: broken test case for date plugin (caused by twill, I guess)
added: "partition" plugin - better handling of config partition
This commit is contained in:
lars 2006-11-06 06:17:22 +00:00
parent 7905fe7051
commit 80337411ae
49 changed files with 259 additions and 116 deletions

View file

@ -1,5 +1,5 @@
Name = Disk partitioning
Link = Disk partitioning
Link = Partition a disk
Title.Partition = Disk partitions
@ -24,9 +24,15 @@ Text {
PartType = Type
Size = Size (MB)
SelectDevice = Choose a disk for partitioning
WarningMessage = If you continue, you will destroy all data on the choosen disk. Please be VERY careful!
ProgressInfo = Progress of formatting:
CreateConfigPartition = create config partition
CreateConfigPartition = Automatically creating a configuration partition.
RemovalContainers = These disks will be destroyed, if you continue
}
AdviceMessage {
DeviceDataIsLost {
Text = If you continue, you will destroy all data on the choosen disk. Please be VERY careful!
}
}
SuccessMessage {
@ -61,6 +67,8 @@ WarningMessage {
DiskIsBusy {
Title = This disk is busy
Text = Please deactivate all containers of this disk before partitioning.
Link.Text = Show all disks
Link.Rel = disks
}
PartitionTooBig {

View file

@ -24,8 +24,8 @@ class partition(CryptoBoxPlugin.CryptoBoxPlugin):
## load default hdf values
self.__prepareDataset()
## retrieve some values from 'args' - defaults are empty
self.withConfigPartition = self.__isWithConfigPartition(args)
self.device = self.__getSelectedDevice(args)
self.withConfigPartition = self.__isWithConfigPartition()
self.cbox.log.debug("partition plugin: selected device=%s" % str(self.device))
self.deviceSize = self.__getAvailableDeviceSize(self.device)
try:
@ -86,7 +86,7 @@ class partition(CryptoBoxPlugin.CryptoBoxPlugin):
def __isDeviceBusy(self, device):
"""check if the device (or one of its partitions) is mounted"""
# TODO: the config partition is ignored, as it is not part of the container list - that is not good
# the config partition is ignored, as it will get unmounted if necessary
import re
for c in self.cbox.getContainerList():
if re.match(device + "\d*$", c.getDevice()):
@ -142,6 +142,8 @@ class partition(CryptoBoxPlugin.CryptoBoxPlugin):
parts = self.__getPartitionsFromArgs(args)
if parts:
self.__setPartitionData(parts)
if CryptoBoxTools.isPartOfBlockDevice(self.device, self.cbox.prefs.getActivePartition()):
self.cbox.prefs.umountPartition()
if not self.__runFDisk(parts):
self.hdf["Data.Warning"] = "Plugins.partition.PartitioningFailed"
return self.__actionAddPartition(args)
@ -162,8 +164,12 @@ class partition(CryptoBoxPlugin.CryptoBoxPlugin):
result = formatPart_gen.next()
## after the first partiton, we can reRead the containerList (as the possible config partition was already created)
if self.withConfigPartition and (counter == 1):
## important: reRead the containerList
self.cbox.reReadContainerList()
## important: reRead the containerList - but somehow it breaks the flow (hanging process)
#self.cbox.reReadContainerList()
## write config data
self.cbox.prefs.mountPartition()
self.cbox.prefs.write()
self.cbox.log.info("settings stored on config partition")
## return the result
if result:
yield "OK"
@ -180,22 +186,30 @@ class partition(CryptoBoxPlugin.CryptoBoxPlugin):
import types
## we do not have to take special care for a possible config partition
parts = [ { "size": self.deviceSize, "type": "windows" } ]
## doe
## umount partition if necessary
if CryptoBoxTools.isPartOfBlockDevice(self.device, self.cbox.prefs.getActivePartition()):
self.cbox.prefs.umountPartition()
## partition it
if not self.__runFDisk(parts):
self.hdf["Data.Warning"] = "Plugins.partition.PartitioningFailed"
return None
result = [e for e in self.__formatPartitions(parts) if type(e) == types.BooleanType] # it is a generator, returning device names and bolean values
## "formatPartitions" is a generator, returning device names and bolean values
result = [e for e in self.__formatPartitions(parts) if type(e) == types.BooleanType]
if self.withConfigPartition:
self.cbox.prefs.mountPartition()
self.cbox.prefs.write()
## check if there is a "False" return value
if False in result:
## operation failed
self.hdf["Data.Warning"] = "Plugins.partition.FormattingFailed"
self.cbox.log.info("easy partitioning failed")
return None
return "select_partitions"
else:
## operation was successful
self.hdf["Data.Success"] = "Plugins.partition.EasySetup"
self.cbox.log.info("easy partitioning succeeded")
return None
## do not show the disk overview immediately - it does not get updated that fast
return { "plugin":"system_preferences", "values":[] }
def __setPartitionData(self, parts):
@ -212,6 +226,12 @@ class partition(CryptoBoxPlugin.CryptoBoxPlugin):
self.hdf[self.hdf_prefix + "CreateConfigPartition"] = "1"
for t in self.PartTypes.keys():
self.hdf[self.hdf_prefix + "Types.%s" % t] = t
## store the currently existing partitions of the choosen block device
current_containers = [ e for e in self.cbox.getContainerList() if CryptoBoxTools.isPartOfBlockDevice(self.device, e.getDevice()) ]
## additionally store the uuids (to be removed after partitioning)
for (index, t) in enumerate(current_containers):
self.hdf[self.hdf_prefix + "ExistingContainers.%d.name" % index] = t.getName()
self.hdf[self.hdf_prefix + "ExistingContainers.%d.size" % index] = CryptoBoxTools.getBlockDeviceSizeHumanly(t.getDevice())
def __getPartitionsFromArgs(self, args):
@ -251,15 +271,15 @@ class partition(CryptoBoxPlugin.CryptoBoxPlugin):
return deviceSize
def __isWithConfigPartition(self, args):
try:
if args["create_config_partition"]:
createConfig = True
else:
createConfig = False
except KeyError:
createConfig = False
return createConfig
def __isWithConfigPartition(self):
"""check if we have to create a configuration partition"""
if self.cbox.prefs.requiresPartition():
active = self.cbox.prefs.getActivePartition()
## we need a partition, if there is no active one
if not active: return True
## check if the active one is part of the current device
return CryptoBoxTools.isPartOfBlockDevice(self.device, active)
return False
def __runFDisk(self, parts):
@ -350,6 +370,9 @@ class partition(CryptoBoxPlugin.CryptoBoxPlugin):
def __formatOnePartition(self, dev_name, type):
## first: retrieve UUID - it can be removed from the database afterwards
prev_uuid = [self.cbox.getUUIDForName(e.getName()) for e in self.cbox.getContainerList() if e.getDevice() == dev_name ]
## call "mkfs"
proc = subprocess.Popen(
shell = False,
args = [
@ -365,6 +388,9 @@ class partition(CryptoBoxPlugin.CryptoBoxPlugin):
self.cbox.log.warn("failed to create filesystem on %s: %s" % (dev_name, error))
return False
else:
## remove unused uuid
if prev_uuid:
self.cbox.removeUUID(prev_uuid[0])
return True

View file

@ -42,6 +42,9 @@ def __formatPartition(device, type):
## TODO: very ugly way of communication: it assumes, that failures are fast - success is slow
if proc.returncode == 0:
time.sleep(1)
return True
else:
return False
thread = threading.Thread()
thread.setDaemon(True)
thread.run = formatting

View file

@ -8,9 +8,9 @@
<?cs if:subcount(Data.Plugins.partition.BlockDevices) > 0 ?>
<?cs call:print_form_header("select_device", "plugins/partition") ?>
<?cs call:print_form_header("select_device", "partition") ?>
<?cs call:hint(Lang.Plugins.partition.Text.WarningMessage) ?>
<?cs call:hint("Plugins.partition.DeviceDataIsLost") ?>
<p><label for="block_device"><?cs var:html_escape(Lang.Plugins.partition.Text.SelectDevice) ?>: </label><br/>
<select name="block_device" id="block_device" tabindex="1" size="0">
@ -20,8 +20,8 @@
<?cs /each ?>
</select></p>
<p><input type="checkbox" name="create_config_partition" value="1" tabindex="2" id="create_config_partition" /><label for="create_config_partition"><?cs var:html_escape(Lang.Plugins.partition.Text.CreateConfigPartition) ?></label></p>
<!--
<p><input type="checkbox" name="create_config_partition" value="1" tabindex="2" id="create_config_partition" /><label for="create_config_partition"><?cs var:html_escape(Lang.Plugins.partition.Text.CreateConfigPartition) ?></label></p>
<?cs if:Data.Plugins.partition.CreateConfigPartition ?>
<input type="hidden" name="create_config_partition" value="1" />
<?cs /if ?>

View file

@ -24,7 +24,7 @@
<td><?cs var:Data.Plugins.partition.Parts[x].Size ?></td>
<td><?cs var:Data.Plugins.partition.Parts[x].Type ?></td>
<td>
<?cs call:print_form_header("part_del_" + x, "plugins/partition") ?>
<?cs call:print_form_header("part_del_" + x, "partition") ?>
<?cs include:Settings.PluginDir + "/partition/current_partition_info.cs" ?>
<input type="hidden" name="step" value="del_partition" />
<input type="hidden" name="del_num" value="<?cs var:x ?>" />
@ -37,7 +37,7 @@
<?cs # new partition input if space is available ?>
<?cs if:Data.Plugins.partition.availSize > 0 ?>
<tr>
<?cs call:print_form_header("part_add", "plugins/partition") ?>
<?cs call:print_form_header("part_add", "partition") ?>
<?cs include:Settings.PluginDir + "/partition/current_partition_info.cs" ?>
<input type="hidden" name="step" value="add_partition" />
<?cs set: x = subcount(Data.Plugins.partition.Parts) ?>
@ -55,10 +55,21 @@
</div>
<?cs if:subcount(Data.Plugins.partition.Parts) > 0 ?>
<?cs call:hint(Lang.Plugins.partition.Text.WarningMessage) ?>
<?cs if:Data.Plugins.partition.CreateConfigPartition ?><p><?cs var:html_escape(Lang.Plugins.partition.Text.CreateConfigPartition) ?></p><?cs /if ?>
<?cs call:print_form_header("part_finish", "plugins/partition") ?>
<?cs if:subcount(Data.Plugins.partition.ExistingContainers) ?>
<p align="left"><?cs var:html_escape(Lang.Plugins.partition.Text.RemovalContainers) ?>:
<ul>
<?cs each:item = Data.Plugins.partition.ExistingContainers ?>
<li><?cs var:html_escape(item.name) ?> (<?cs var:html_escape(item.size) ?>)</li>
<?cs /each ?>
</ul></p>
<?cs /if ?>
<?cs if:subcount(Data.Plugins.partition.Parts) > 0 ?>
<?cs call:hint("Plugins.partition.DeviceDataIsLost") ?>
<?cs call:print_form_header("part_finish", "partition") ?>
<?cs include:Settings.PluginDir + "/partition/current_partition_info.cs" ?>
<input type="hidden" name="step" value="finish" />
<button type="submit"><?cs var:html_escape(Lang.Plugins.partition.Button.SavePartitions) ?></button>

View file

@ -3,7 +3,7 @@ import WebInterfaceTestClass
class unittests(WebInterfaceTestClass.WebInterfaceTestClass):
def test_read_form(self):
url = self.URL + "plugins/partition?weblang=en"
url = self.URL + "partition?weblang=en"
self.register_auth(url)
self.cmd.go(url)
self.cmd.find('VERY careful')