new plugins: 'format_fs', 'volume_mount', 'volume_props', 'shutdown' and 'volume_details'

new plugin attribute: "requestAuth"
This commit is contained in:
lars 2006-10-09 16:43:14 +00:00
parent 0e8a5daa73
commit ca13aebdc8
27 changed files with 920 additions and 45 deletions

View file

@ -0,0 +1,93 @@
import CryptoBoxPlugin
class format_fs(CryptoBoxPlugin.CryptoBoxPlugin):
pluginCapabilities = [ "volume" ]
requestAuth = True
## map filesystem types to the appropriate arguments for 'mkfs'
fsTypes = {
"windows": "vfat",
"linux": "ext3" }
containerTypes = [ "luks", "plain" ]
def doAction(self, store=None, fs_type="windows", container_type="luks", crypto_password=None, crypto_password2=None, confirm=None):
if not fs_type in self.fsTypes.keys():
self.cbox.info
return "format_volume"
self.hdf[self.hdf_prefix + "fs_type"] = fs_type
self.hdf[self.hdf_prefix + "container_type"] = container_type
for t in self.fsTypes.keys():
self.hdf[self.hdf_prefix + "fs_types." + t] = t
if store == "step1":
if not confirm:
self.cbox.log.warn("missing confirmation for formatting of filesystem: %s" % self.device)
self.hdf["Data.Warning"] = "Plugins.format_fs.FormatNotConfirmed"
return "volume_format"
if container_type == "luks":
return "volume_format_luks"
elif container_type == "plain":
return self.__format_plain(fs_type)
elif store == "step2":
if container_type == "luks":
return self.__format_luks(fs_type, crypto_password, crypto_password2)
else:
self.cbox.log.info("invalid input value for 'container_type': %s" % container_type)
return "volume_format"
elif store:
self.cbox.log.info("invalid input value for 'store': %s" % store)
return "volume_format"
else:
return "volume_format"
def getStatus(self):
return "no status"
def __format_plain(self, fsType):
try:
container = self.cbox.getContainer(self.device)
container.create(container.Types["plain"])
except CBVolumeIsActive:
self.hdf["Data.Warning"] = "VolumeMayNotBeMounted"
self.cbox.log.info("initialization is not possible as long as the device (%s) is mounted" % self.device)
return None
except CBContainerError, errMsg:
self.hdf["Data.Warning"] = "Plugins.format_fs.FormatFailed"
self.cbox.log.warn("initialization of device '%s' failed" % self.device)
self.cbox.log.warn("reason: %s" % errMsg)
return "volume_format"
else:
self.cbox.log.info("successfully initialized device '%s'" % self.device)
return None
def __format_luks(self, fsType, pw, pw2):
if not pw:
self.hdf["Data.Warning"] = "EmptyCryptoPassword"
self.cbox.log.warn("no crypto password was supplied for initialization of device '%s'" % self.device)
return "volume_format"
if pw != pw2:
self.hdf["Data.Warning"] = "DifferentCryptoPasswords"
self.cbox.log.warn("the crypto password was not repeated correctly for initialization of device '%s'" % self.device)
return "volume_format"
container = self.cbox.getContainer(self.device)
try:
container.create(container.Types["luks"], pw)
except CBVolumeIsActive:
self.hdf["Data.Warning"] = "VolumeMayNotBeMounted"
self.cbox.log.info("initialization is not possible as long as the device (%s) is mounted" % self.device)
return None
except CBContainerError, errMsg:
self.hdf["Data.Warning"] = "Plugins.format_fs.FormatFailed"
self.cbox.log.warn("initialization of device '%s' failed" % self.device)
self.cbox.log.warn("reason: %s" % errMsg)
return "volume_format"
else:
self.hdf["Data.Success"] = "Plugins.format_fs.FormatSuccess"
self.cbox.log.info("successfully initialized device '%s'" % self.device)
return None

View file

@ -0,0 +1,36 @@
Name = Create filesystems
Link = Format
Rank = 60
Title.Format = Initializing filesystem
Button.Format = Initialize filesystem
Text {
Confirm = Yes, I know what I am doing!
FormatWarning = All data of the selected filesystem will get lost!
FSType = Filesystem type
IsEncrypted = Encryption
Yes = Yes
No = No
UnmountBeforeInit = You must deactivate this volume before you may initialize it.
}
SuccessMessage {
FormatSuccess {
Title = Formatting successful
Text = The selected filesystem was successfully formatted.
}
}
WarningMessage {
FormatNotConfirmed {
Title = Confirmation missing
Text = You did not confirm this action by activating the checkbox.
}
FormatFailed {
Title = Formatting failed
Text = Formatting of the selected filesystem failed for unknown reasons - sorry!
}
}

View file

@ -0,0 +1,37 @@
<?cs # $Id$ ?>
<?cs include:Settings.TemplateDir + "/show_volume_header.cs" ?>
<h2><?cs var:html_escape(Lang.Plugins.format_fs.Title.Format) ?></h2>
<?cs if:Data.CurrentDisk.active ?>
<div class="unavailable_action">
<?cs var:html_escape(Lang.Plugins.format_fs.Text.UnmountBeforeInit) ?>
</div>
<?cs else ?>
<?cs call:print_form_header("plugins/format_fs") ?>
<p><label for="fs_type"><?cs var:html_escape(Lang.Plugins.format_fs.Text.FSType)
?>: </label><select name="fs_type" id="fs_type" size="0" ?>
<?cs each:x = Data.Plugins.format_fs.fs_types ?>
<option <?cs if:x == "windows" ?>selected="selected"<?cs /if ?>><?cs var:html_escape(x) ?></option><?cs /each ?>
</select></p>
<p><label for="container_type"><?cs var:html_escape(Lang.Plugins.format_fs.Text.IsEncrypted)
?>: <select name="container_type" id="container_type">
<option value="luks" <?cs if:Data.Plugins.format_fs.container_type != "plain" ?>selected="selected"<?cs /if ?>><?cs var:html_escape(Lang.Plugins.format_fs.Text.Yes) ?></option> -->
<option value="plain" <?cs if:Data.Plugins.format_fs.container_type == "plain" ?>selected="selected"<?cs /if ?>><?cs var:html_escape(Lang.Plugins.format_fs.Text.No) ?></option>
</select></p>
<p class="note"><?cs var:html_escape(Lang.Plugins.format_fs.Text.FormatWarning) ?></p>
<p><input type="checkbox" name="confirm" value="1" id="confirm"><label for="confirm"><?cs var:html_escape(Lang.Plugins.format_fs.Text.Confirm) ?><p/>
<input type="hidden" name="device" value="<?cs var:Data.CurrentDisk.device ?>" />
<input type="hidden" name="store" value="step1" />
<button type="submit"><?cs var:html_escape(Lang.Plugins.format_fs.Button.Format) ?></button>
</form>
<?cs /if ?>
<?cs include:Settings.TemplateDir + "/show_volume_footer.cs" ?>

View file

@ -0,0 +1,33 @@
<?cs # $Id$ ?>
<?cs include:Settings.TemplateDir + "/show_volume_header.cs" ?>
<h2><?cs var:html_escape(Lang.Plugins.format_fs.Title.Format) ?></h2>
<?cs if:Data.CurrentDisk.active ?>
<div class="unavailable_action">
<?cs var:html_escape(Lang.Plugins.format_fs.Text.UnmountBeforeInit) ?>
</div>
<?cs else ?>
<?cs call:print_form_header("plugins/format_fs") ?>
<p class="note"><?cs var:html_escape(Lang.Plugins.format_fs.Text.FormatWarning) ?></p>
<p><?cs var:html_escape(Lang.Plugins.format_fs.Text.FSType) ?>: <?cs var:html_escape(Data.Plugins.format_fs.fs_type) ?></p>
<p><?cs var:html_escape(Lang.Plugins.format_fs.Text.IsEncrypted) ?>: <?cs if:Data.Plugins.format_fs.container_type == "luks" ?><?cs
var:html_escape(Lang.Plugins.format_fs.Text.Yes) ?><?cs else ?><?cs
var:html_escape(Lang.Plugins.format_fs.Text.No) ?><?cs /if ?></p>
<p><label for="crypto_password"><?cs var:html_escape(Lang.Text.EnterNewCryptoPassword) ?></label> <input type="password" id="crypto_password" name="crypto_password" /></p>
<p><label for="crypto_password2"><?cs var:html_escape(Lang.Text.EnterSameCryptoPassword) ?></label> <input type="password" id="crypto_password2" name="crypto_password2" /></p>
<input type="hidden" name="device" value="<?cs var:Data.CurrentDisk.device ?>" />
<input type="hidden" name="fs_type" value="<?cs var:html_escape(Data.Plugins.format_fs.fs_type) ?>" />
<input type="hidden" name="container_type" value="<?cs var:html_escape(Data.Plugins.format_fs.container_type) ?>" />
<input type="hidden" name="store" value="step2" />
<button type="submit"><?cs var:html_escape(Lang.Plugins.format_fs.Button.Format) ?></button>
</form>
<?cs /if ?>
<?cs include:Settings.TemplateDir + "/show_volume_footer.cs" ?>