improved detection of 'active' plugin for marking in the main menu
plugin plugin_manager: prevent browser from caching repeatitive actions plugin plugin_manager: add support for properties/volume visibility plugins: moved message handling to central header file (templates/header.cs) splitted 'volume_props' into 'volume_rename' and 'volume_chpasswd' volume_props: turned into a container for small property changes renamed 'format_fs' to 'volume_format_fs' moved inclusion of 'show_volume_[header|footer].cs' to central header filemaster
parent
fc67727692
commit
405f6b90fa
@ -1,37 +0,0 @@
|
||||
<?cs # $Id$ ?>
|
||||
|
||||
<?cs include:Settings.TemplateDir + "/show_volume_header.cs" ?>
|
||||
|
||||
<h2><?cs var:html_escape(Lang.Plugins.format_fs.Title.Format) ?></h2>
|
||||
|
||||
<?cs call:handle_messages() ?>
|
||||
|
||||
<?cs if:Data.CurrentDisk.active ?>
|
||||
<?cs call:hint("Plugins.format_fs.UnmountBeforeInit") ?>
|
||||
<?cs else ?>
|
||||
|
||||
<?cs call:hint("Plugins.format_fs.FormatWarning") ?>
|
||||
|
||||
<?cs call:print_form_header("set_type", "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)
|
||||
?>: </label><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><input type="checkbox" name="confirm" value="1" id="confirm" /><label for="confirm"><?cs var:html_escape(Lang.Plugins.format_fs.Text.Confirm) ?></label></p>
|
||||
|
||||
<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></p>
|
||||
</form>
|
||||
|
||||
<?cs /if ?>
|
||||
|
||||
<?cs include:Settings.TemplateDir + "/show_volume_footer.cs" ?>
|
@ -1,32 +0,0 @@
|
||||
<?cs # $Id$ ?>
|
||||
|
||||
<?cs include:Settings.TemplateDir + "/show_volume_header.cs" ?>
|
||||
|
||||
<h2><?cs var:html_escape(Lang.Plugins.format_fs.Title.Format) ?></h2>
|
||||
|
||||
<?cs call:handle_messages() ?>
|
||||
|
||||
<?cs if:Data.CurrentDisk.active ?>
|
||||
<?cs call:hint("Plugins.format_fs.UnmountBeforeInit") ?>
|
||||
<?cs else ?>
|
||||
|
||||
<?cs call:hint("Plugins.format_fs.FormatWarning") ?>
|
||||
|
||||
<?cs call:print_form_header("set_luks", "format_fs") ?>
|
||||
<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.EnterNewPassword) ?>: </label> <input type="password" id="crypto_password" name="crypto_password" /></p>
|
||||
<p><label for="crypto_password2"><?cs var:html_escape(Lang.Text.EnterSamePassword) ?>: </label> <input type="password" id="crypto_password2" name="crypto_password2" /></p>
|
||||
<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></p>
|
||||
</form>
|
||||
|
||||
<?cs /if ?>
|
||||
|
||||
<?cs include:Settings.TemplateDir + "/show_volume_footer.cs" ?>
|
@ -0,0 +1,36 @@
|
||||
Name = Change volume password
|
||||
Link = Password
|
||||
|
||||
Title {
|
||||
ChangePassword = Change the password of this volume
|
||||
}
|
||||
|
||||
|
||||
Button {
|
||||
ChangePassword = Change password
|
||||
FormatContainer = Format volume
|
||||
}
|
||||
|
||||
|
||||
AdviceMessage {
|
||||
FormatForEncryptionSupport {
|
||||
Text = This volume is not encrypted. If you want to turn on encryption, then you have to format the volume. Beware: this will destroy all data of this container.
|
||||
Link.Text = Format this volume
|
||||
Link.Rel = volume_format_fs
|
||||
}
|
||||
|
||||
|
||||
SuccessMessage {
|
||||
PasswordChange {
|
||||
Title = Password changed
|
||||
Text = The password of this volume was changed successfully.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
WarningMessage {
|
||||
PasswordChange {
|
||||
Title = Could not change password
|
||||
Text = The password of this volume could not be changed - sorry!
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
import WebInterfaceTestClass
|
||||
|
||||
class unittests(WebInterfaceTestClass.WebInterfaceTestClass):
|
||||
|
||||
def test_read_form(self):
|
||||
url = self.URL + "volume_chpasswd?weblang=en&device=%2Fdev%2Floop1"
|
||||
self.register_auth(url)
|
||||
self.cmd.go(url)
|
||||
self.cmd.find('hange')
|
||||
self.cmd.find('password')
|
||||
|
@ -0,0 +1,33 @@
|
||||
<?cs # $Id$ ?>
|
||||
|
||||
<h3><?cs var:html_escape(Lang.Plugins.volume_chpasswd.Title.ChangePassword) ?></h3>
|
||||
|
||||
<?cs # show password change form only for encrypted volumes ?>
|
||||
<?cs if:Data.CurrentDisk.encryption ?>
|
||||
<?cs call:print_form_header("set_password", "volume_chpasswd") ?>
|
||||
<table>
|
||||
<tr>
|
||||
<td align="right"><label for="old_pw"><?cs var:html_escape(Lang.Text.EnterCurrentPassword) ?>: </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.EnterNewPassword) ?>: </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.EnterSamePassword) ?>: </label></td>
|
||||
<td><input type="password" name="new_pw2" tabindex="22" size="15" id="new_pw2" /></td>
|
||||
<td>
|
||||
<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_chpasswd.Button.ChangePassword) ?></button>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
<?cs else ?>
|
||||
<?cs call:hint("Plugins.volume_chpasswd.FormatForEncryptionSupport") ?>
|
||||
<?cs /if ?>
|
||||
|
@ -0,0 +1,53 @@
|
||||
import CryptoBoxPlugin
|
||||
from CryptoBoxExceptions import *
|
||||
|
||||
|
||||
class volume_chpasswd(CryptoBoxPlugin.CryptoBoxPlugin):
|
||||
|
||||
pluginCapabilities = [ "volume" ]
|
||||
pluginVisibility = [ "properties" ]
|
||||
requestAuth = False
|
||||
rank = 70
|
||||
|
||||
|
||||
def doAction(self, store=None, old_pw=None, new_pw=None, new_pw2=None):
|
||||
self.container = self.cbox.getContainer(self.device)
|
||||
if not self.container:
|
||||
return None
|
||||
elif store == "change_pw":
|
||||
return self.__changePassword(old_pw, new_pw, new_pw2)
|
||||
elif not store:
|
||||
return "volume_chpasswd"
|
||||
else:
|
||||
self.cbox.log.info("plugin 'volume_chpasswd' - unknown action: %s" % store)
|
||||
return "volume_chpasswd"
|
||||
|
||||
|
||||
def getStatus(self):
|
||||
return "TODO"
|
||||
|
||||
|
||||
def __changePassword(self, old_pw, new_pw, new_pw2):
|
||||
if not old_pw:
|
||||
self.hdf["Data.Warning"] = "EmptyPassword"
|
||||
elif not new_pw:
|
||||
self.hdf["Data.Warning"] = "EmptyNewPassword"
|
||||
elif new_pw != new_pw2:
|
||||
self.hdf["Data.Warning"] = "DifferentPasswords"
|
||||
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_chpasswd' - 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_chpasswd' - cannot change password for device (%s): %s" % (self.device, errMsg))
|
||||
self.hdf["Data.Warning"] = "Plugins.volume_chpasswd.PasswordChange"
|
||||
else:
|
||||
self.hdf["Data.Success"] = "Plugins.volume_chpasswd.PasswordChange"
|
||||
return "volume_chpasswd"
|
||||
|
Before Width: | Height: | Size: 4.8 KiB After Width: | Height: | Size: 4.8 KiB |
Before Width: | Height: | Size: 6.2 KiB After Width: | Height: | Size: 6.2 KiB |
@ -0,0 +1,32 @@
|
||||
<?cs # $Id$ ?>
|
||||
|
||||
<h3><?cs var:html_escape(Lang.Plugins.volume_format_fs.Title.Format) ?></h3>
|
||||
|
||||
<?cs if:Data.CurrentDisk.active ?>
|
||||
<?cs call:hint("Plugins.volume_format_fs.UnmountBeforeInit") ?>
|
||||
<?cs else ?>
|
||||
|
||||
<?cs call:hint("Plugins.volume_format_fs.FormatWarning") ?>
|
||||
|
||||
<?cs call:print_form_header("set_type", "volume_format_fs") ?>
|
||||
<p><label for="fs_type"><?cs var:html_escape(Lang.Plugins.volume_format_fs.Text.FSType)
|
||||
?>: </label><select name="fs_type" id="fs_type" size="0">
|
||||
<?cs each:x = Data.Plugins.volume_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.volume_format_fs.Text.IsEncrypted)
|
||||
?>: </label><select name="container_type" id="container_type">
|
||||
<option value="luks" <?cs if:Data.Plugins.volume_format_fs.container_type != "plain" ?>selected="selected"<?cs /if ?>><?cs var:html_escape(Lang.Plugins.volume_format_fs.Text.Yes) ?></option>
|
||||
<option value="plain" <?cs if:Data.Plugins.volume_format_fs.container_type == "plain" ?>selected="selected"<?cs /if ?>><?cs var:html_escape(Lang.Plugins.volume_format_fs.Text.No) ?></option>
|
||||
</select></p>
|
||||
|
||||
<p><input type="checkbox" name="confirm" value="1" id="confirm" /><label for="confirm"><?cs var:html_escape(Lang.Plugins.volume_format_fs.Text.Confirm) ?></label></p>
|
||||
|
||||
<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.volume_format_fs.Button.Format) ?></button></p>
|
||||
</form>
|
||||
|
||||
<?cs /if ?>
|
||||
|
@ -0,0 +1,96 @@
|
||||
import CryptoBoxPlugin
|
||||
from CryptoBoxExceptions import *
|
||||
|
||||
class volume_format_fs(CryptoBoxPlugin.CryptoBoxPlugin):
|
||||
|
||||
pluginCapabilities = [ "volume" ]
|
||||
pluginVisibility = [ "volume" ]
|
||||
requestAuth = True
|
||||
rank = 60
|
||||
|
||||
## 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.volume_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.volume_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"] = "EmptyPassword"
|
||||
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"] = "DifferentPasswords"
|
||||
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.volume_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.volume_format_fs.FormatSuccess"
|
||||
self.cbox.log.info("successfully initialized device '%s'" % self.device)
|
||||
return None
|
||||
|
@ -0,0 +1,27 @@
|
||||
<?cs # $Id$ ?>
|
||||
|
||||
<h3><?cs var:html_escape(Lang.Plugins.volume_format_fs.Title.Format) ?></h3>
|
||||
|
||||
<?cs if:Data.CurrentDisk.active ?>
|
||||
<?cs call:hint("Plugins.volume_format_fs.UnmountBeforeInit") ?>
|
||||
<?cs else ?>
|
||||
|
||||
<?cs call:hint("Plugins.volume_format_fs.FormatWarning") ?>
|
||||
|
||||
<?cs call:print_form_header("set_luks", "volume_format_fs") ?>
|
||||
<p><?cs var:html_escape(Lang.Plugins.volume_format_fs.Text.FSType) ?>: <?cs var:html_escape(Data.Plugins.volume_format_fs.fs_type) ?></p>
|
||||
<p><?cs var:html_escape(Lang.Plugins.volume_format_fs.Text.IsEncrypted) ?>: <?cs if:Data.Plugins.volume_format_fs.container_type == "luks" ?><?cs
|
||||
var:html_escape(Lang.Plugins.volume_format_fs.Text.Yes) ?><?cs else ?><?cs
|
||||
var:html_escape(Lang.Plugins.volume_format_fs.Text.No) ?><?cs /if ?></p>
|
||||
|
||||
<p><label for="crypto_password"><?cs var:html_escape(Lang.Text.EnterNewPassword) ?>: </label> <input type="password" id="crypto_password" name="crypto_password" /></p>
|
||||
<p><label for="crypto_password2"><?cs var:html_escape(Lang.Text.EnterSamePassword) ?>: </label> <input type="password" id="crypto_password2" name="crypto_password2" /></p>
|
||||
<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.volume_format_fs.fs_type) ?>" />
|
||||
<input type="hidden" name="container_type" value="<?cs var:html_escape(Data.Plugins.volume_format_fs.container_type) ?>" />
|
||||
<input type="hidden" name="store" value="step2" />
|
||||
<button type="submit"><?cs var:html_escape(Lang.Plugins.volume_format_fs.Button.Format) ?></button></p>
|
||||
</form>
|
||||
|
||||
<?cs /if ?>
|
||||
|
@ -0,0 +1,38 @@
|
||||
Name = Rename volume
|
||||
Link = Rename
|
||||
|
||||
Title {
|
||||
ChangeVolumeName = Change the name of this volume
|
||||
}
|
||||
|
||||
|
||||
Button {
|
||||
ContainerNameSet = Change name
|
||||
}
|
||||
|
||||
|
||||
SuccessMessage {
|
||||
VolumeNameChanged {
|
||||
Title = Name changed
|
||||
Text = The name 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.
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,11 @@
|
||||
import WebInterfaceTestClass
|
||||
|
||||
class unittests(WebInterfaceTestClass.WebInterfaceTestClass):
|
||||
|
||||
def test_read_form(self):
|
||||
url = self.URL + "volume_rename?weblang=en&device=%2Fdev%2Floop1"
|
||||
self.register_auth(url)
|
||||
self.cmd.go(url)
|
||||
self.cmd.find('name')
|
||||
self.cmd.find('hange')
|
||||
|
@ -0,0 +1,14 @@
|
||||
<?cs # $Id$ ?>
|
||||
|
||||
<h3><?cs var:html_escape(Lang.Plugins.volume_rename.Title.ChangeVolumeName) ?></h3>
|
||||
|
||||
<p>
|
||||
<?cs call:print_form_header("set_name", "volume_rename") ?>
|
||||
<label for="vol_name"><?cs var:html_escape(Lang.Text.ContainerName) ?>: </label>
|
||||
<input type="text" name="vol_name" tabindex="10" size="15" id="vol_name" value="<?cs var:html_escape(Data.CurrentDisk.name) ?>" />
|
||||
<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_rename.Button.ContainerNameSet) ?></button>
|
||||
</form>
|
||||
</p>
|
||||
|
@ -0,0 +1,54 @@
|
||||
import CryptoBoxPlugin
|
||||
from CryptoBoxExceptions import *
|
||||
|
||||
|
||||
class volume_rename(CryptoBoxPlugin.CryptoBoxPlugin):
|
||||
|
||||
pluginCapabilities = [ "volume" ]
|
||||
pluginVisibility = [ "properties" ]
|
||||
requestAuth = False
|
||||
rank = 60
|
||||
|
||||
|
||||
def doAction(self, store=None, vol_name=None):
|
||||
self.container = self.cbox.getContainer(self.device)
|
||||
if not self.container:
|
||||
return None
|
||||
self.__prepareHDF()
|
||||
if store and vol_name:
|
||||
return self.__setVolumeName(vol_name)
|
||||
else:
|
||||
return "volume_rename"
|
||||
|
||||
|
||||
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_rename.InvalidVolumeName"
|
||||
return "volume_rename"
|
||||
if vol_name == self.container.getName():
|
||||
## nothing has to be done
|
||||
return "volume_rename"
|
||||
try:
|
||||
self.container.setName(vol_name)
|
||||
self.hdf["Data.Success"] = "Plugins.volume_rename.VolumeNameChanged"
|
||||
except CBInvalidName:
|
||||
self.hdf["Data.Warning"] = "Plugins.volume_rename.InvalidVolumeName"
|
||||
except CBNameActivelyUsed:
|
||||
self.hdf["Data.Warning"] = "Plugins.volume_rename.VolumeNameIsInUse"
|
||||
except CBContainerError:
|
||||
self.hdf["Data.Warning"] = "Plugins.volume_rename.SetVolumeNameFailed"
|
||||
## reread the volume name
|
||||
self.__prepareHDF()
|
||||
return "volume_rename"
|
||||
|
Loading…
Reference in New Issue