new plugins: 'format_fs', 'volume_mount', 'volume_props', 'shutdown' and 'volume_details'
new plugin attribute: "requestAuth"
This commit is contained in:
parent
0e8a5daa73
commit
ca13aebdc8
27 changed files with 920 additions and 45 deletions
|
@ -5,7 +5,8 @@ Rank = 80
|
|||
Title.Partition = Disk partitions
|
||||
|
||||
Button {
|
||||
SelectDevice = Repartition disk
|
||||
SelectDevice = Manual partitioning
|
||||
EasySetup = Automatic setup
|
||||
AddPartition = Add
|
||||
DelPartition = Remove
|
||||
SavePartitions = Write new partition table
|
||||
|
@ -24,8 +25,9 @@ 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 careful!
|
||||
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
|
||||
}
|
||||
|
||||
SuccessMessage {
|
||||
|
@ -33,6 +35,12 @@ SuccessMessage {
|
|||
Title = Partitioning complete
|
||||
Text = The disk was partitioned successfully.
|
||||
}
|
||||
|
||||
EasySetup {
|
||||
Title = Initialization completed
|
||||
Text = Automatic initialization was finished successfully.
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
WarningMessage {
|
||||
|
|
|
@ -6,6 +6,9 @@ import CryptoBoxPlugin
|
|||
|
||||
class partition(CryptoBoxPlugin.CryptoBoxPlugin):
|
||||
|
||||
pluginCapabilities = [ "system" ]
|
||||
requestAuth = True
|
||||
|
||||
PartTypes = {
|
||||
"windows" : ["0xC", "vfat"],
|
||||
"linux" : ["L", "ext3"]}
|
||||
|
@ -22,21 +25,29 @@ class partition(CryptoBoxPlugin.CryptoBoxPlugin):
|
|||
## retrieve some values from 'args' - defaults are empty
|
||||
self.withConfigPartition = self.__isWithConfigPartition(args)
|
||||
self.device = self.__getSelectedDevice(args)
|
||||
self.cbox.log.debug("partition plugin: selected device=%s" % str(self.device))
|
||||
self.deviceSize = self.__getAvailableDeviceSize(self.device)
|
||||
try:
|
||||
step = args["step"]
|
||||
del args["step"]
|
||||
except KeyError:
|
||||
step = "select_device"
|
||||
try:
|
||||
## this way of selecting the easy setup is necessary: see select_device.py for details
|
||||
if args["easy"]: step = "easy"
|
||||
except KeyError:
|
||||
pass
|
||||
## no (or invalid) device was supplied
|
||||
if not self.device:
|
||||
step == "select_device"
|
||||
if step == "add_partition":
|
||||
return self.__actionAddPartition(args)
|
||||
if step == "del_partition":
|
||||
elif step == "del_partition":
|
||||
return self.__actionDelPartition(args)
|
||||
elif step == "finish":
|
||||
return self.__actionFinish(args)
|
||||
elif step == "easy":
|
||||
return self.__actionEasySetup(args)
|
||||
else: # for "select_device" and for invalid targets
|
||||
return self.__actionSelectDevice(args)
|
||||
|
||||
|
@ -105,7 +116,7 @@ class partition(CryptoBoxPlugin.CryptoBoxPlugin):
|
|||
parts = self.__getPartitionsFromArgs(args)
|
||||
self.__setPartitionData(parts)
|
||||
return "set_partitions"
|
||||
|
||||
|
||||
|
||||
def __actionDelPartition(self, args):
|
||||
try:
|
||||
|
@ -132,11 +143,6 @@ class partition(CryptoBoxPlugin.CryptoBoxPlugin):
|
|||
self.hdf["Data.Warning"] = "Plugins.partition.PartitioningFailed"
|
||||
return self.__actionAddPartition(args)
|
||||
else:
|
||||
# TODO: will we use the "yield"-style? If yes, then remove these messages (success and warning)
|
||||
#if self.__formatPartitions(parts):
|
||||
# self.hdf["Data.Success"] = "Plugins.partition.Partitioned"
|
||||
#else:
|
||||
# self.hdf["Data.Warning"] = "Plugins.partition.FormattingFailed"
|
||||
"""
|
||||
tricky problem: if the device was partitioned, then a created config partition is still part of the containerlist, as the label is not checked again - very ugly!!! So we will call reReadContainerList after formatting the last partition - see below
|
||||
"""
|
||||
|
@ -156,7 +162,10 @@ class partition(CryptoBoxPlugin.CryptoBoxPlugin):
|
|||
## important: reRead the containerList
|
||||
self.cbox.reReadContainerList()
|
||||
## return the result
|
||||
yield result
|
||||
if result:
|
||||
yield "OK"
|
||||
else:
|
||||
yield "<b>Error</b>"
|
||||
return {
|
||||
"template": "show_format_progress",
|
||||
"generator": result_generator}
|
||||
|
@ -164,6 +173,28 @@ class partition(CryptoBoxPlugin.CryptoBoxPlugin):
|
|||
return self.__actionAddPartition(args)
|
||||
|
||||
|
||||
def __actionEasySetup(self, args):
|
||||
import types
|
||||
## we do not have to take special care for a possible config partition
|
||||
parts = [ { "size": self.deviceSize, "type": "windows" } ]
|
||||
## doe
|
||||
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
|
||||
## 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
|
||||
else:
|
||||
## operation was successful
|
||||
self.hdf["Data.Success"] = "Plugins.partition.EasySetup"
|
||||
self.cbox.log.info("easy partitioning succeeded")
|
||||
return None
|
||||
|
||||
|
||||
def __setPartitionData(self, parts):
|
||||
availSize = self.deviceSize
|
||||
i = 0
|
||||
|
@ -242,6 +273,7 @@ class partition(CryptoBoxPlugin.CryptoBoxPlugin):
|
|||
## check if the device is completely filled (to avoid some empty last blocks)
|
||||
avail_size = self.deviceSize
|
||||
for d in parts: avail_size -= d["size"]
|
||||
self.cbox.log.debug("remaining size: %d" % avail_size)
|
||||
isFilled = avail_size == 0
|
||||
proc = subprocess.Popen(
|
||||
shell = False,
|
||||
|
@ -252,7 +284,7 @@ class partition(CryptoBoxPlugin.CryptoBoxPlugin):
|
|||
self.cbox.prefs["Programs"]["super"],
|
||||
self.cbox.prefs["Programs"]["CryptoBoxRootActions"],
|
||||
"plugin",
|
||||
os.path.join(os.path.dirname(__file__), "root_action.py"),
|
||||
os.path.join(self.pluginDir, "root_action.py"),
|
||||
"partition",
|
||||
self.device])
|
||||
for line in self.__getSFDiskLayout(parts, isFilled):
|
||||
|
@ -263,13 +295,19 @@ class partition(CryptoBoxPlugin.CryptoBoxPlugin):
|
|||
|
||||
|
||||
def __getSFDiskLayout(self, paramParts, isFilled):
|
||||
"""this generator returns the input lines for sfdisk"""
|
||||
parts = paramParts[:]
|
||||
## first a (possible) configuration partition - so it will be reusable
|
||||
if self.withConfigPartition:
|
||||
## fill the main table (including a config partition)
|
||||
yield ",%d,%s" % (self.ConfigPartition["size"], self.ConfigPartition["type"])
|
||||
## one primary partition
|
||||
yield ",%d,%s,*" % (parts[0]["size"], self.PartTypes[parts[0]["type"]][0])
|
||||
if isFilled and (len(parts) == 1):
|
||||
## fill the rest of the device
|
||||
yield ",,%s,*" % self.PartTypes[parts[0]["type"]][0]
|
||||
else:
|
||||
## only use the specified size
|
||||
yield ",%d,%s,*" % (parts[0]["size"], self.PartTypes[parts[0]["type"]][0])
|
||||
del parts[0]
|
||||
## no extended partition, if there is only one disk
|
||||
if not parts: return
|
||||
|
@ -303,10 +341,7 @@ class partition(CryptoBoxPlugin.CryptoBoxPlugin):
|
|||
partType = self.PartTypes[parts[0]["type"]][1]
|
||||
self.cbox.log.info("formatting partition (%s) as '%s'" % (dev_name, partType))
|
||||
yield dev_name
|
||||
if self.__formatOnePartition(dev_name, partType):
|
||||
yield "OK"
|
||||
else:
|
||||
yield "<b>Failed!</b>"
|
||||
yield self.__formatOnePartition(dev_name, partType)
|
||||
del parts[0]
|
||||
## other data partitions
|
||||
part_num = 5
|
||||
|
@ -315,10 +350,7 @@ class partition(CryptoBoxPlugin.CryptoBoxPlugin):
|
|||
partType = self.PartTypes[parts[0]["type"]][1]
|
||||
self.cbox.log.info("formatting partition (%s) as '%s'" % (dev_name, partType))
|
||||
yield dev_name
|
||||
if self.__formatOnePartition(dev_name, partType):
|
||||
yield "OK"
|
||||
else:
|
||||
yield "<b>Failed!</b>"
|
||||
yield self.__formatOnePartition(dev_name, partType)
|
||||
part_num += 1
|
||||
del parts[0]
|
||||
return
|
||||
|
@ -331,7 +363,7 @@ class partition(CryptoBoxPlugin.CryptoBoxPlugin):
|
|||
self.cbox.prefs["Programs"]["super"],
|
||||
self.cbox.prefs["Programs"]["CryptoBoxRootActions"],
|
||||
"plugin",
|
||||
os.path.join(os.path.dirname(__file__), "root_action.py"),
|
||||
os.path.join(self.pluginDir, "root_action.py"),
|
||||
"format",
|
||||
dev_name,
|
||||
type])
|
||||
|
@ -352,7 +384,7 @@ class partition(CryptoBoxPlugin.CryptoBoxPlugin):
|
|||
self.cbox.prefs["Programs"]["super"],
|
||||
self.cbox.prefs["Programs"]["CryptoBoxRootActions"],
|
||||
"plugin",
|
||||
os.path.join(os.path.dirname(__file__), "root_action.py"),
|
||||
os.path.join(self.pluginDir, "root_action.py"),
|
||||
"label",
|
||||
dev_name,
|
||||
label])
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
<?cs /each ?>
|
||||
</select></p>
|
||||
|
||||
<p><label for="create_config_partition">Create configuration partition?</label><input type="checkbox" name="create_config_partition" value="1" tabindex="2" id="create_config_partition" /></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" />
|
||||
|
@ -28,7 +28,13 @@
|
|||
|
||||
<input type="hidden" name="step" value="add_partition" />
|
||||
|
||||
<button type="submit" tabindex="3"><?cs var:html_escape(Lang.Plugins.partition.Button.SelectDevice) ?></button>
|
||||
<div align="center"><table><tr>
|
||||
<!-- we have to avoid an ugly IE bug, that ignores the "value" attribute
|
||||
of "button" elements: if a variable called 'easy' is set, then this
|
||||
button was choosen - uuuuuugly! -->
|
||||
<td><button type="submit" name="easy" value="1" tabindex="3"><?cs var:html_escape(Lang.Plugins.partition.Button.EasySetup) ?></button></td>
|
||||
<td><button type="submit" name="normal" value="1" tabindex="4"><?cs var:html_escape(Lang.Plugins.partition.Button.SelectDevice) ?></button></td>
|
||||
</tr></table></div>
|
||||
|
||||
</form>
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue