Merge pull request #630 from mwhudson/guided-luks
add guided luks options
This commit is contained in:
commit
6c5c2022fd
|
@ -342,8 +342,9 @@ class FilesystemController(SubiquityController):
|
||||||
self.ui.set_body(v)
|
self.ui.set_body(v)
|
||||||
if self.answers['guided']:
|
if self.answers['guided']:
|
||||||
index = self.answers['guided-index']
|
index = self.answers['guided-index']
|
||||||
disk = self.model.all_disks()[index]
|
v.form.guided.value = True
|
||||||
v.choose_disk(None, disk)
|
v.form.guided_choice.disk.widget.index = index
|
||||||
|
v.form._emit('done')
|
||||||
|
|
||||||
def reset(self):
|
def reset(self):
|
||||||
log.info("Resetting Filesystem model")
|
log.info("Resetting Filesystem model")
|
||||||
|
@ -658,7 +659,7 @@ class FilesystemController(SubiquityController):
|
||||||
}
|
}
|
||||||
self.partition_disk_handler(disk, None, result)
|
self.partition_disk_handler(disk, None, result)
|
||||||
|
|
||||||
def guided_lvm(self, disk):
|
def guided_lvm(self, disk, lvm_options):
|
||||||
self.reformat(disk)
|
self.reformat(disk)
|
||||||
if DeviceAction.MAKE_BOOT in disk.supported_actions:
|
if DeviceAction.MAKE_BOOT in disk.supported_actions:
|
||||||
self.make_boot_disk(disk)
|
self.make_boot_disk(disk)
|
||||||
|
@ -674,6 +675,8 @@ class FilesystemController(SubiquityController):
|
||||||
fstype=None,
|
fstype=None,
|
||||||
))
|
))
|
||||||
spec = dict(name="ubuntu-vg", devices=set([part]))
|
spec = dict(name="ubuntu-vg", devices=set([part]))
|
||||||
|
if lvm_options['encrypt']:
|
||||||
|
spec['password'] = lvm_options['luks_options']['password']
|
||||||
# create volume group on partition
|
# create volume group on partition
|
||||||
vg = self.create_volgroup(spec)
|
vg = self.create_volgroup(spec)
|
||||||
self.create_logical_volume(
|
self.create_logical_volume(
|
||||||
|
|
|
@ -432,7 +432,7 @@ class DeviceList(WidgetWrap):
|
||||||
|
|
||||||
|
|
||||||
class FilesystemView(BaseView):
|
class FilesystemView(BaseView):
|
||||||
title = _("Filesystem setup")
|
title = _("Storage configuration")
|
||||||
|
|
||||||
def __init__(self, model, controller):
|
def __init__(self, model, controller):
|
||||||
self.model = model
|
self.model = model
|
||||||
|
|
|
@ -25,6 +25,7 @@ from subiquitycore.ui.form import (
|
||||||
Form,
|
Form,
|
||||||
NO_CAPTION,
|
NO_CAPTION,
|
||||||
NO_HELP,
|
NO_HELP,
|
||||||
|
PasswordField,
|
||||||
RadioButtonField,
|
RadioButtonField,
|
||||||
SubForm,
|
SubForm,
|
||||||
SubFormField,
|
SubFormField,
|
||||||
|
@ -39,22 +40,47 @@ from subiquitycore.ui.utils import (
|
||||||
)
|
)
|
||||||
from subiquitycore.view import BaseView
|
from subiquitycore.view import BaseView
|
||||||
|
|
||||||
|
|
||||||
from .helpers import summarize_device
|
from .helpers import summarize_device
|
||||||
|
|
||||||
|
|
||||||
log = logging.getLogger("subiquity.ui.views.filesystem.guided")
|
log = logging.getLogger("subiquity.ui.views.filesystem.guided")
|
||||||
|
|
||||||
text = _("""The installer can guide you through partitioning an entire disk
|
subtitle = _("Configure a guided storage layout, or create a custom one:")
|
||||||
either directly or using LVM, or, if you prefer, you can do it manually.
|
|
||||||
|
|
||||||
If you choose to partition an entire disk you will still have a chance to
|
|
||||||
review and modify the results.""")
|
class LUKSOptionsForm(SubForm):
|
||||||
|
|
||||||
|
password = PasswordField(_("Passphrase:"))
|
||||||
|
confirm_password = PasswordField(_("Confirm passphrase:"))
|
||||||
|
|
||||||
|
def validate_password(self):
|
||||||
|
if len(self.password.value) < 1:
|
||||||
|
return _("Password must be set")
|
||||||
|
|
||||||
|
def validate_confirm_password(self):
|
||||||
|
if self.password.value != self.confirm_password.value:
|
||||||
|
return _("Passwords do not match")
|
||||||
|
|
||||||
|
|
||||||
|
class LVMOptionsForm(SubForm):
|
||||||
|
|
||||||
|
def __init__(self, parent):
|
||||||
|
super().__init__(parent)
|
||||||
|
connect_signal(self.encrypt.widget, 'change', self._toggle)
|
||||||
|
self.luks_options.enabled = self.encrypt.value
|
||||||
|
|
||||||
|
def _toggle(self, sender, val):
|
||||||
|
self.luks_options.enabled = val
|
||||||
|
|
||||||
|
encrypt = BooleanField(_("Encrypt the LVM group with LUKS"), help=NO_HELP)
|
||||||
|
luks_options = SubFormField(LUKSOptionsForm, "", help=NO_HELP)
|
||||||
|
|
||||||
|
|
||||||
class GuidedChoiceForm(SubForm):
|
class GuidedChoiceForm(SubForm):
|
||||||
|
|
||||||
disk = ChoiceField(caption=NO_CAPTION, help=NO_HELP, choices=["x"])
|
disk = ChoiceField(caption=NO_CAPTION, help=NO_HELP, choices=["x"])
|
||||||
use_lvm = BooleanField(_("Set up this disk as an LVM group"), help=NO_HELP)
|
use_lvm = BooleanField(_("Set up this disk as an LVM group"), help=NO_HELP)
|
||||||
|
lvm_options = SubFormField(LVMOptionsForm, "", help=NO_HELP)
|
||||||
|
|
||||||
def __init__(self, parent):
|
def __init__(self, parent):
|
||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
|
@ -70,6 +96,11 @@ class GuidedChoiceForm(SubForm):
|
||||||
t0.bind(t)
|
t0.bind(t)
|
||||||
self.disk.widget.options = options
|
self.disk.widget.options = options
|
||||||
self.disk.widget.index = 0
|
self.disk.widget.index = 0
|
||||||
|
connect_signal(self.use_lvm.widget, 'change', self._toggle)
|
||||||
|
self.lvm_options.enabled = self.use_lvm.value
|
||||||
|
|
||||||
|
def _toggle(self, sender, val):
|
||||||
|
self.lvm_options.enabled = val
|
||||||
|
|
||||||
|
|
||||||
class GuidedForm(Form):
|
class GuidedForm(Form):
|
||||||
|
@ -98,10 +129,15 @@ replacing any partitions and data already there.
|
||||||
|
|
||||||
If the platform requires it, a bootloader partition is created on the disk.
|
If the platform requires it, a bootloader partition is created on the disk.
|
||||||
|
|
||||||
If you choose to use LVM, two partitions are then created, one for /boot and
|
If you choose to use LVM, two additional partitions are then created,
|
||||||
one covering the rest of the disk. A LVM volume group is created containing
|
one for /boot and one covering the rest of the disk. An LVM volume
|
||||||
the large partition. A 4 gigabyte logical volume is created for the root
|
group is created containing the large partition. A 4 gigabyte logical
|
||||||
filesystem. It can easily be enlarged with standard LVM command line tools.
|
volume is created for the root filesystem. It can easily be enlarged
|
||||||
|
with standard LVM command line tools.
|
||||||
|
|
||||||
|
You can also choose to encrypt LVM volume group. This will require
|
||||||
|
setting a password, that one will need to type on every boot before
|
||||||
|
the system boots.
|
||||||
|
|
||||||
If you do not choose to use LVM, a single partition is created covering the
|
If you do not choose to use LVM, a single partition is created covering the
|
||||||
rest of the disk which is then formatted as ext4 and mounted at /.
|
rest of the disk which is then formatted as ext4 and mounted at /.
|
||||||
|
@ -117,7 +153,7 @@ at /.
|
||||||
|
|
||||||
class GuidedDiskSelectionView (BaseView):
|
class GuidedDiskSelectionView (BaseView):
|
||||||
|
|
||||||
title = _("Filesystem setup")
|
title = _("Guided storage configuration")
|
||||||
|
|
||||||
def __init__(self, controller):
|
def __init__(self, controller):
|
||||||
self.controller = controller
|
self.controller = controller
|
||||||
|
@ -126,8 +162,8 @@ class GuidedDiskSelectionView (BaseView):
|
||||||
connect_signal(self.form, 'submit', self.done)
|
connect_signal(self.form, 'submit', self.done)
|
||||||
connect_signal(self.form, 'cancel', self.cancel)
|
connect_signal(self.form, 'cancel', self.cancel)
|
||||||
|
|
||||||
super().__init__(self.form.as_screen(
|
super().__init__(
|
||||||
focus_buttons=False, excerpt=rewrap(_(text))))
|
self.form.as_screen(focus_buttons=False, excerpt=_(subtitle)))
|
||||||
|
|
||||||
def local_help(self):
|
def local_help(self):
|
||||||
return (_("Help on guided storage configuration"), rewrap(_(HELP)))
|
return (_("Help on guided storage configuration"), rewrap(_(HELP)))
|
||||||
|
@ -137,7 +173,8 @@ class GuidedDiskSelectionView (BaseView):
|
||||||
if results['guided']:
|
if results['guided']:
|
||||||
disk = results['guided_choice']['disk']
|
disk = results['guided_choice']['disk']
|
||||||
if results['guided_choice']['use_lvm']:
|
if results['guided_choice']['use_lvm']:
|
||||||
self.controller.guided_lvm(disk)
|
self.controller.guided_lvm(
|
||||||
|
disk, results['guided_choice']['lvm_options'])
|
||||||
else:
|
else:
|
||||||
self.controller.guided_direct(disk)
|
self.controller.guided_direct(disk)
|
||||||
self.controller.manual()
|
self.controller.manual()
|
||||||
|
|
Loading…
Reference in New Issue