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
51
pythonrewrite/plugins/volume_props/lang/en.hdf
Normal file
51
pythonrewrite/plugins/volume_props/lang/en.hdf
Normal file
|
@ -0,0 +1,51 @@
|
|||
Name = Volume properties
|
||||
Link = Properties
|
||||
Rank = 40
|
||||
|
||||
Title {
|
||||
Properties = Properties
|
||||
ChangeVolumeName = Change the name of this volume
|
||||
ChangePassword = Change the password of this volume
|
||||
}
|
||||
|
||||
|
||||
Button {
|
||||
ContainerNameSet = Change name
|
||||
ChangePassword = Change password
|
||||
}
|
||||
|
||||
|
||||
Text {
|
||||
UmountBeforeProps = You must deactivate a volume, if you want to change its properties.
|
||||
}
|
||||
|
||||
|
||||
SuccessMessage {
|
||||
PasswordChange {
|
||||
Title = Password changed
|
||||
Text = The password of this volume was changed successfully.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
WarningMessage {
|
||||
InvalidVolumeName {
|
||||
Title = Changing of container's name failed
|
||||
Text = The supplied new name of the container was invalid. Please try again!
|
||||
}
|
||||
|
||||
SetVolumeNameFailed {
|
||||
Title = Changing of container's name failed
|
||||
Text = Could not change the name of the container. Take a look at the log files for details.
|
||||
}
|
||||
|
||||
VolumeNameIsInUse {
|
||||
Title = Volume name is in use
|
||||
Text = Another volume with the same name is active.
|
||||
}
|
||||
|
||||
PasswordChange {
|
||||
Title = Could not change password
|
||||
Text = The password of this volume could not be changed - sorry!
|
||||
}
|
||||
}
|
63
pythonrewrite/plugins/volume_props/volume_properties.cs
Normal file
63
pythonrewrite/plugins/volume_props/volume_properties.cs
Normal file
|
@ -0,0 +1,63 @@
|
|||
<?cs # $Id$ ?>
|
||||
|
||||
<?cs include:Settings.TemplateDir + "/show_volume_header.cs" ?>
|
||||
|
||||
<h2><?cs var:html_escape(Lang.Plugins.volume_props.Title.Properties) ?></h2>
|
||||
|
||||
<?cs if:Data.CurrentDisk.active ?>
|
||||
|
||||
<div class="unavailable_action">
|
||||
<?cs var:html_escape(Lang.Plugins.volume_props.Text.UmountBeforeProps) ?>
|
||||
</div>
|
||||
|
||||
<?cs else ?>
|
||||
<table>
|
||||
|
||||
<?cs # name change is only possible if the volume is not mounted ?>
|
||||
<tr><td colspan="3">
|
||||
<h3><?cs var:html_escape(Lang.Plugins.volume_props.Title.ChangeVolumeName) ?></h3>
|
||||
</td></tr>
|
||||
<?cs call:print_form_header("plugins/volume_props") ?><tr>
|
||||
<td align="right"><label for="vol_name"><?cs var:html_escape(Lang.Text.ContainerName) ?>: </label></td>
|
||||
<td><input type="text" name="vol_name" tabindex="10" size="15" id="vol_name" value="<?cs var:html_escape(Data.CurrentDisk.name) ?>" /></td>
|
||||
<td align="right">
|
||||
<input type="hidden" name="device" value="<?cs var:html_escape(Data.CurrentDisk.device) ?>" />
|
||||
<input type="hidden" name="store" value="set_name" />
|
||||
<button type="submit" tabindex="11"><?cs var:html_escape(Lang.Plugins.volume_props.Button.ContainerNameSet) ?></button>
|
||||
</td>
|
||||
</tr></form>
|
||||
<tr><td></td><td></td><td></td></tr>
|
||||
|
||||
|
||||
<?cs # password change is only possible if the volume is not mounted ?>
|
||||
<tr><td colspan="3">
|
||||
<h3><?cs var:html_escape(Lang.Plugins.volume_props.Title.ChangePassword) ?></h3>
|
||||
</td></tr>
|
||||
<?cs call:print_form_header("plugins/volume_props") ?>
|
||||
<tr>
|
||||
<td align="right"><label for="old_pw"><?cs var:html_escape(Lang.Text.EnterCurrentCryptoPassword) ?>: </label></td>
|
||||
<td><input type="password" name="old_pw" tabindex="20" size="15" id="old_pw" /></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right"><label for="new_pw"><?cs var:html_escape(Lang.Text.EnterNewCryptoPassword) ?>: </label></td>
|
||||
<td><input type="password" name="new_pw" tabindex="21" size="15" id="new_pw" /></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right"><label for="new_pw2"><?cs var:html_escape(Lang.Text.EnterSameCryptoPassword) ?>: </label></td>
|
||||
<td><input type="password" name="new_pw2" tabindex="22" size="15" id="new_pw2" /></td>
|
||||
<td align="right">
|
||||
<input type="hidden" name="device" value="<?cs var:html_escape(Data.CurrentDisk.device) ?>" />
|
||||
<input type="hidden" name="store" value="change_pw" />
|
||||
<button type="submit" tabindex="23"><?cs var:html_escape(Lang.Plugins.volume_props.Button.ChangePassword) ?></button></p>
|
||||
</td>
|
||||
</tr>
|
||||
</form>
|
||||
<tr><td></td><td></td><td></td></tr>
|
||||
|
||||
</table>
|
||||
|
||||
<?cs /if ?>
|
||||
|
||||
<?cs include:Settings.TemplateDir + "/show_volume_footer.cs" ?>
|
80
pythonrewrite/plugins/volume_props/volume_props.py
Normal file
80
pythonrewrite/plugins/volume_props/volume_props.py
Normal file
|
@ -0,0 +1,80 @@
|
|||
import CryptoBoxPlugin
|
||||
from CryptoBoxExceptions import *
|
||||
|
||||
|
||||
class volume_props(CryptoBoxPlugin.CryptoBoxPlugin):
|
||||
|
||||
pluginCapabilities = [ "volume" ]
|
||||
requestAuth = False
|
||||
|
||||
|
||||
def doAction(self, store=None, vol_name=None, old_pw=None, new_pw=None, new_pw2=None):
|
||||
self.container = self.cbox.getContainer(self.device)
|
||||
if not self.container:
|
||||
return None
|
||||
self.__prepareHDF()
|
||||
if store == "set_name":
|
||||
return self.__setVolumeName(vol_name)
|
||||
elif store == "change_pw":
|
||||
return self.__changePassword(old_pw, new_pw, new_pw2)
|
||||
elif not store:
|
||||
return "volume_properties"
|
||||
else:
|
||||
self.cbox.log.info("plugin 'volume_props' - unknown action: %s" % store)
|
||||
return "volume_properties"
|
||||
|
||||
|
||||
def getStatus(self):
|
||||
self.container = self.cbox.getContainer(self.device)
|
||||
if not self.container:
|
||||
return "invalid device"
|
||||
return "name=%s" % self.container.getName()
|
||||
|
||||
|
||||
def __prepareHDF(self):
|
||||
self.hdf[self.hdf_prefix + "vol_name"] = self.container.getName()
|
||||
|
||||
|
||||
def __setVolumeName(self, vol_name):
|
||||
if not vol_name:
|
||||
self.hdf["Data.Warning"] = "Plugins.volume_props.InvalidVolumeName"
|
||||
return "volume_properties"
|
||||
if vol_name == self.container.getName():
|
||||
## nothing has to be done
|
||||
return "volume_properties"
|
||||
try:
|
||||
self.container.setName(vol_name)
|
||||
except CBInvalidName:
|
||||
self.hdf["Data.Warning"] = "Plugins.volume_props.InvalidVolumeName"
|
||||
except CBNameActivelyUsed:
|
||||
self.hdf["Data.Warning"] = "Plugins.volume_props.VolumeNameIsInUse"
|
||||
except CBContainerError:
|
||||
self.hdf["Data.Warning"] = "Plugins.volume_props.SetVolumeNameFailed"
|
||||
## reread the volume name
|
||||
self.__prepareHDF()
|
||||
return "volume_properties"
|
||||
|
||||
|
||||
def __changePassword(self, old_pw, new_pw, new_pw2):
|
||||
if not old_pw:
|
||||
self.hdf["Data.Warning"] = "EmptyCryptoPassword"
|
||||
elif not new_pw:
|
||||
self.hdf["Data.Warning"] = "EmptyNewCryptoPassword"
|
||||
elif new_pw != new_pw2:
|
||||
self.hdf["Data.Warning"] = "DifferentCryptoPasswords"
|
||||
elif old_pw == new_pw:
|
||||
## do nothing
|
||||
pass
|
||||
else:
|
||||
try:
|
||||
self.container.changePassword(old_pw, new_pw)
|
||||
except CBInvalidType, errMsg:
|
||||
self.cbox.log.info("plugin 'volume_props' - cannot change passphrase for non-encrypted container (%s): %s" % (self.device, errMsg))
|
||||
except CBVolumeIsActive:
|
||||
self.hdf["Data.Warning"] = "VolumeMayNotBeMounted"
|
||||
except CBChangePasswordError, errMsg:
|
||||
self.cbox.log.warn("plugin 'volume_props' - cannot change password for device (%s): %s" % (self.device, errMsg))
|
||||
self.hdf["Data.Warning"] = "Plugins.volume_props.PasswordChange"
|
||||
else:
|
||||
self.hdf["Data.Success"] = "Plugins.volume_props.PasswordChange"
|
||||
return "volume_properties"
|
Loading…
Add table
Add a link
Reference in a new issue