Exemplo n.º 1
0
    def __init__(self, *args, **kwargs):
        StorageCheckHandler.__init__(self)
        NormalSpoke.__init__(self, *args, **kwargs)
        self.applyOnSkip = True
        self._ready = False
        self._back_clicked = False
        self._disks_errors = []
        self._last_clicked_overview = None
        self._cur_clicked_overview = None

        self._storage_module = STORAGE.get_proxy()
        self._device_tree = STORAGE.get_proxy(DEVICE_TREE)
        self._bootloader_module = STORAGE.get_proxy(BOOTLOADER)
        self._disk_init_module = STORAGE.get_proxy(DISK_INITIALIZATION)
        self._disk_select_module = STORAGE.get_proxy(DISK_SELECTION)

        # This list contains all possible disks that can be included in the install.
        # All types of advanced disks should be set up for us ahead of time, so
        # there should be no need to modify this list.
        self._available_disks = []
        self._selected_disks = []
        self._last_selected_disks = []

        # Is the partitioning already configured?
        self._is_preconfigured = bool(self._storage_module.CreatedPartitioning)

        # Find a partitioning to use.
        self._partitioning = find_partitioning()
        self._last_partitioning_method = self._partitioning.PartitioningMethod

        # Create a partitioning request for the automatic partitioning.
        self._partitioning_request = PartitioningRequest()

        if self._last_partitioning_method == PARTITIONING_METHOD_AUTOMATIC:
            self._partitioning_request = PartitioningRequest.from_structure(
                self._partitioning.Request)

        # Get the UI elements.
        self._custom_part_radio_button = self.builder.get_object(
            "customRadioButton")
        self._blivet_gui_radio_button = self.builder.get_object(
            "blivetguiRadioButton")
        self._encrypted_checkbox = self.builder.get_object(
            "encryptionCheckbox")
        self._encryption_revealer = self.builder.get_object(
            "encryption_revealer")
        self._reclaim_checkbox = self.builder.get_object("reclaimCheckbox")
        self._reclaim_revealer = self.builder.get_object(
            "reclaim_checkbox_revealer")
        self._local_disks_box = self.builder.get_object("local_disks_box")
        self._specialized_disks_box = self.builder.get_object(
            "specialized_disks_box")
        self._local_viewport = self.builder.get_object("localViewport")
        self._specialized_viewport = self.builder.get_object(
            "specializedViewport")
        self._main_viewport = self.builder.get_object("storageViewport")
        self._main_box = self.builder.get_object("storageMainBox")

        # Configure the partitioning methods.
        self._configure_partitioning_methods()
Exemplo n.º 2
0
    def test_luks2_format_args(self):
        storage = create_storage()
        request = PartitioningRequest()
        request.encrypted = True
        request.passphrase = "default"
        request.luks_version = "luks2"
        request.pbkdf = "argon2i"
        request.pbkdf_memory = 256
        request.pbkdf_iterations = 1000
        request.pbkdf_time = 100

        args = AutomaticPartitioningTask._get_luks_format_args(
            storage, request)
        pbkdf_args = args.pop("pbkdf_args")

        assert args == {
            "passphrase": "default",
            "cipher": "",
            "luks_version": "luks2",
            "escrow_cert": None,
            "add_backup_passphrase": False,
        }

        assert isinstance(pbkdf_args, LUKS2PBKDFArgs)
        assert pbkdf_args.type == "argon2i"
        assert pbkdf_args.max_memory_kb == 256
        assert pbkdf_args.iterations == 1000
        assert pbkdf_args.time_ms == 100
Exemplo n.º 3
0
    def schedule_partitions_with_task_test(self, publisher):
        """Test SchedulePartitionsWithTask."""
        self.module.on_storage_changed(Mock())

        request = PartitioningRequest()
        request.partitioning_scheme = AUTOPART_TYPE_PLAIN

        task_path = self.interface.SchedulePartitionsWithTask(
            PartitioningRequest.to_structure(request))

        obj = check_task_creation(self, task_path, publisher,
                                  InteractiveAutoPartitioningTask)
        self.assertEqual(obj.implementation._storage, self.module.storage)
        self.assertTrue(compare_data(obj.implementation._request, request))
    def no_luks_format_args_test(self):
        storage = create_storage()
        request = PartitioningRequest()

        args = AutomaticPartitioningTask._get_luks_format_args(
            storage, request)
        self.assertEqual(args, {})
Exemplo n.º 5
0
    def test_no_luks_format_args(self):
        storage = create_storage()
        request = PartitioningRequest()

        args = AutomaticPartitioningTask._get_luks_format_args(
            storage, request)
        assert args == {}
Exemplo n.º 6
0
    def Request(self, request: Structure):
        """Set the partitioning request.

        :param request: a request
        """
        self.implementation.set_request(
            PartitioningRequest.from_structure(request))
Exemplo n.º 7
0
    def __init__(self):
        """Initialize the module."""
        super().__init__()
        self.enabled_changed = Signal()
        self._enabled = False

        self.request_changed = Signal()
        self._request = PartitioningRequest()
Exemplo n.º 8
0
    def SchedulePartitionsWithTask(self, request: Structure) -> ObjPath:
        """Schedule the partitioning actions.

        Generate the automatic partitioning configuration
        using the given request.

        :param: a partitioning request
        :return: a DBus path to a task
        """
        return TaskContainer.to_object_path(
            self.implementation.schedule_partitions_with_task(
                PartitioningRequest.from_structure(request)))
Exemplo n.º 9
0
def set_storage_defaults_from_kickstart(storage):
    """Set the storage default values from a kickstart file.

    FIXME: A temporary workaround for UI.
    """
    # Set the default filesystem types.
    auto_part_proxy = STORAGE.get_proxy(AUTO_PARTITIONING)
    request = PartitioningRequest.from_structure(auto_part_proxy.Request)

    if request.file_system_type:
        storage.set_default_fstype(request.file_system_type)

    if "swap" in request.excluded_mount_points:
        storage_checker.set_constraint(STORAGE_SWAP_IS_RECOMMENDED, False)
Exemplo n.º 10
0
    def luks1_format_args_test(self):
        storage = create_storage()
        storage._escrow_certificates["file:///tmp/escrow.crt"] = "CERTIFICATE"

        request = PartitioningRequest()
        request.encrypted = True
        request.passphrase = "passphrase"
        request.luks_version = "luks1"
        request.cipher = "aes-xts-plain64"
        request.escrow_certificate = "file:///tmp/escrow.crt"
        request.backup_passphrase_enabled = True

        args = AutomaticPartitioningTask._get_luks_format_args(storage, request)
        self.assertEqual(args, {
            "passphrase": "passphrase",
            "cipher": "aes-xts-plain64",
            "luks_version": "luks1",
            "pbkdf_args": None,
            "escrow_cert": "CERTIFICATE",
            "add_backup_passphrase": True,
        })
Exemplo n.º 11
0
def configure_storage(storage, data=None, interactive=False):
    """Setup storage state from the kickstart data.

    :param storage: an instance of the Blivet's storage object
    :param data: an instance of kickstart data or None
    :param interactive: use a task for the interactive partitioning
    """
    auto_part_proxy = STORAGE.get_proxy(AUTO_PARTITIONING)

    if interactive:
        task = InteractivePartitioningTask(storage)
    elif auto_part_proxy.Enabled:
        request = PartitioningRequest.from_structure(auto_part_proxy.Request)
        task = AutomaticPartitioningTask(storage, request)
    elif STORAGE.get_proxy(MANUAL_PARTITIONING).Enabled:
        task = ManualPartitioningTask(storage)
    else:
        task = CustomPartitioningTask(storage, data)

    task.run()
Exemplo n.º 12
0
def set_storage_defaults_from_kickstart(storage):
    """Set the storage default values from a kickstart file.

    FIXME: A temporary workaround for UI.
    """
    # Set the default filesystem types.
    auto_part_proxy = STORAGE.get_proxy(AUTO_PARTITIONING)
    request = PartitioningRequest.from_structure(auto_part_proxy.Request)

    if request.file_system_type:
        storage.set_default_fstype(request.file_system_type)

    if "swap" in request.excluded_mount_points:
        storage_checker.set_constraint(STORAGE_SWAP_IS_RECOMMENDED, False)

    # Set up the bootloader.
    boot_loader_proxy = STORAGE.get_proxy(BOOTLOADER)
    default_type = boot_loader_proxy.GetDefaultType()
    default_class = BootLoaderFactory.get_class_by_name(default_type)
    BootLoaderFactory.set_default_class(default_class)
Exemplo n.º 13
0
    def __init__(self, data, storage, payload, partitioning):
        super().__init__(data, storage, payload)
        self.title = N_("Partition Scheme Options")
        self._container = None
        self._part_schemes = OrderedDict()
        self._partitioning = partitioning
        self._request = PartitioningRequest.from_structure(
            self._partitioning.Request)

        supported_choices = get_supported_autopart_choices()

        if supported_choices:
            # Fallback value (eg when default is not supported)
            self._selected_scheme_value = supported_choices[0][1]

        selected_choice = self._request.partitioning_scheme

        for item in supported_choices:
            self._part_schemes[item[0]] = item[1]
            if item[1] == selected_choice:
                self._selected_scheme_value = item[1]
Exemplo n.º 14
0
    def process_kickstart(self, data):
        """Process the kickstart data."""
        self.set_enabled(data.autopart.autopart)
        request = PartitioningRequest()

        if data.autopart.type is not None:
            request.partitioning_scheme = data.autopart.type

        if data.autopart.fstype:
            request.file_system_type = data.autopart.fstype

        if data.autopart.noboot:
            request.excluded_mount_points.append("/boot")

        if data.autopart.nohome:
            request.excluded_mount_points.append("/home")

        if data.autopart.noswap:
            request.excluded_mount_points.append("swap")

        if data.autopart.encrypted:
            request.encrypted = True
            request.passphrase = data.autopart.passphrase
            request.cipher = data.autopart.cipher
            request.luks_version = data.autopart.luks_version

            request.pbkdf = data.autopart.pbkdf
            request.pbkdf_memory = data.autopart.pbkdf_memory
            request.pbkdf_time = data.autopart.pbkdf_time
            request.pbkdf_iterations = data.autopart.pbkdf_iterations

            request.escrow_certificate = data.autopart.escrowcert
            request.backup_passphrase_enabled = data.autopart.backuppassphrase

        self.set_request(request)
Exemplo n.º 15
0
 def apply(self):
     """ Apply our selections. """
     self._partitioning.SetRequest(
         PartitioningRequest.to_structure(self._request))
Exemplo n.º 16
0
 def apply(self):
     """ Apply our selections. """
     self._request.partitioning_scheme = self._selected_scheme_value
     self._auto_part_proxy.SetRequest(PartitioningRequest.to_structure(self._request))
Exemplo n.º 17
0
    def _skip_to_automatic_partitioning(self):
        """Skip to the automatic partitioning.

        The user has requested to create the partitioning automatically.
        Ask for missing information and set up the automatic partitioning,
        so it can be later applied in the execute method.
        """
        # Set up the encryption.
        self._partitioning_request.encrypted = self._encrypted_checkbox.get_active(
        )

        # Ask for a passphrase.
        if self._partitioning_request.encrypted:
            dialog = PassphraseDialog(self.data,
                                      self._partitioning_request.passphrase)

            rc = self.run_lightbox_dialog(dialog)
            if rc != 1:
                self._back_clicked = False
                return

            self._partitioning_request.passphrase = dialog.passphrase

        # Set up the disk selection and initialization.
        self.apply()

        # Use the automatic partitioning and reset it.
        self._partitioning = create_partitioning(PARTITIONING_METHOD_AUTOMATIC)

        self._partitioning.Request = \
            PartitioningRequest.to_structure(self._partitioning_request)

        # Reclaim space.
        disks = filter_disks_by_names(self._available_disks,
                                      self._selected_disks)
        rc = self._check_space_and_run_dialog(self._partitioning, disks)

        if rc == RESPONSE_RECLAIM:
            dialog = ResizeDialog(self.data, self.payload, self._partitioning,
                                  disks)
            dialog.refresh()
            rc = self.run_lightbox_dialog(dialog)

        # Plan the next action.
        if rc == RESPONSE_OK:
            # nothing special needed
            self._skip_to_spoke(None)
            return

        if rc == RESPONSE_CANCEL:
            # A cancel button was clicked on one of the dialogs.  Stay on this
            # spoke.  Generally, this is because the user wants to add more disks.
            self._back_clicked = False
            return

        if rc == RESPONSE_MODIFY_SW:
            # The "Fedora software selection" link was clicked on one of the
            # dialogs.  Send the user to the software spoke.
            self._skip_to_spoke("SoftwareSelectionSpoke")
            return

        if rc == RESPONSE_QUIT:
            # Not enough space, and the user can't do anything about it so
            # they chose to quit.
            raise SystemExit("user-selected exit")

        # I don't know how we'd get here, but might as well have a
        # catch-all.  Just stay on this spoke.
        self._back_clicked = False
        return
Exemplo n.º 18
0
 def Request(self) -> Structure:
     """The partitioning request."""
     return PartitioningRequest.to_structure(self.implementation.request)