Beispiel #1
0
    def __init__(self):
        super().__init__()
        # We need this so all the /dev/disk/* stuff is set up.
        udev.trigger(subsystem="block", action="change")

        self._modules = []

        self._disk_init_module = DiskInitializationModule()
        self._add_module(self._disk_init_module)

        self._disk_selection_module = DiskSelectionModule()
        self._add_module(self._disk_selection_module)

        self._bootloader_module = BootloaderModule()
        self._add_module(self._bootloader_module)

        self._auto_part_module = AutoPartitioningModule()
        self._add_module(self._auto_part_module)

        self._manual_part_module = ManualPartitioningModule()
        self._add_module(self._manual_part_module)

        self._dasd_module = None
        self._zfcp_module = None

        if arch.is_s390():
            self._dasd_module = DASDModule()
            self._add_module(self._dasd_module)

            self._zfcp_module = ZFCPModule()
            self._add_module(self._zfcp_module)
Beispiel #2
0
    def __init__(self):
        super().__init__()
        # Initialize Blivet.
        enable_installer_mode()

        # The storage model.
        self._storage = None
        self.storage_changed = Signal()

        # Initialize modules.
        self._modules = []

        self._disk_init_module = DiskInitializationModule()
        self._add_module(self._disk_init_module)

        self._disk_selection_module = DiskSelectionModule()
        self._add_module(self._disk_selection_module)

        self._snapshot_module = SnapshotModule()
        self._add_module(self._snapshot_module)

        self._bootloader_module = BootloaderModule()
        self._add_module(self._bootloader_module)

        self._fcoe_module = FCOEModule()
        self._add_module(self._fcoe_module)

        self._nvdimm_module = NVDIMMModule()
        self._add_module(self._nvdimm_module)

        self._dasd_module = None
        self._zfcp_module = None

        if arch.is_s390():
            self._dasd_module = DASDModule()
            self._add_module(self._dasd_module)

            self._zfcp_module = ZFCPModule()
            self._add_module(self._zfcp_module)

        # Initialize the partitioning modules.
        self._partitioning_modules = {}

        self._auto_part_module = AutoPartitioningModule()
        self._add_partitioning_module(AUTO_PARTITIONING.object_path,
                                      self._auto_part_module)

        self._manual_part_module = ManualPartitioningModule()
        self._add_partitioning_module(MANUAL_PARTITIONING.object_path,
                                      self._manual_part_module)

        self._custom_part_module = CustomPartitioningModule()
        self._add_partitioning_module(CUSTOM_PARTITIONING.object_path,
                                      self._custom_part_module)

        # Connect modules to signals.
        self.storage_changed.connect(self._snapshot_module.on_storage_reset)
Beispiel #3
0
    def __init__(self):
        super().__init__()
        self._modules = []

        self._disk_init_module = DiskInitializationModule()
        self._add_module(self._disk_init_module)

        self._disk_selection_module = DiskSelectionModule()
        self._add_module(self._disk_selection_module)

        self._bootloader_module = BootloaderModule()
        self._add_module(self._bootloader_module)

        self._autopart_module = AutoPartitioningModule()
        self._add_module(self._autopart_module)
Beispiel #4
0
    def __init__(self):
        super().__init__()
        self._modules = []

        self._disk_init_module = DiskInitializationModule()
        self._add_module(self._disk_init_module)

        self._disk_selection_module = DiskSelectionModule()
        self._add_module(self._disk_selection_module)

        self._bootloader_module = BootloaderModule()
        self._add_module(self._bootloader_module)

        self._autopart_module = AutoPartitioningModule()
        self._add_module(self._autopart_module)

        if arch.is_s390():
            self._dasd_module = DASDModule()
            self._add_module(self._dasd_module)
        else:
            self._dasd_module = None
Beispiel #5
0
 def setUp(self):
     """Set up the module."""
     self.bootloader_module = BootloaderModule()
     self.bootloader_interface = BootloaderInterface(self.bootloader_module)
Beispiel #6
0
class BootloaderInterfaceTestCase(unittest.TestCase):
    """Test DBus interface of the bootloader module."""
    def setUp(self):
        """Set up the module."""
        self.bootloader_module = BootloaderModule()
        self.bootloader_interface = BootloaderInterface(self.bootloader_module)

    def _check_dbus_property(self, *args, **kwargs):
        check_dbus_property(self, BOOTLOADER, self.bootloader_interface, *args,
                            **kwargs)

    def get_default_type_test(self):
        """Test GetDefaultType."""
        self.assertEqual(self.bootloader_interface.GetDefaultType(), "DEFAULT")

    def bootloader_mode_property_test(self):
        """Test the bootloader mode property."""
        self._check_dbus_property("BootloaderMode", BOOTLOADER_SKIPPED)

    def preferred_location_property_test(self):
        """Test the preferred location property."""
        self._check_dbus_property("PreferredLocation",
                                  BOOTLOADER_LOCATION_PARTITION)

    def drive_property_test(self):
        """Test the drive property."""
        self._check_dbus_property("Drive", "sda")

    def drive_order_property_test(self):
        """Test the drive order property."""
        self._check_dbus_property("DriveOrder", ["sda", "sdb"])

    def keep_mbr_property_test(self):
        """Test the keep MBR property."""
        self._check_dbus_property("KeepMBR", True)

    def keep_boot_order_test(self):
        """Test the keep boot order property."""
        self._check_dbus_property("KeepBootOrder", True)

    def extra_arguments_property_test(self):
        """Test the extra arguments property."""
        self._check_dbus_property("ExtraArguments",
                                  ["hdd=ide-scsi", "ide=nodma"])

    def timeout_property_test(self):
        """Test the timeout property."""
        self._check_dbus_property("Timeout", 25)

    def secure_boot_property_test(self):
        """Test the secure boot property."""
        self._check_dbus_property("ZIPLSecureBoot", "auto")

    def password_property_test(self):
        """Test the password property."""
        self._check_dbus_property(
            "Password",
            "12345",
            setter=self.bootloader_interface.SetEncryptedPassword,
            changed={'IsPasswordSet': True})

    def is_efi_test(self):
        """Test IsEFI."""
        with self.assertRaises(UnavailableStorageError):
            self.bootloader_interface.IsEFI()

        storage = Mock()
        self.bootloader_module.on_storage_changed(storage)

        storage.bootloader = GRUB2()
        self.assertEqual(self.bootloader_interface.IsEFI(), False)

        storage.bootloader = EFIGRUB()
        self.assertEqual(self.bootloader_interface.IsEFI(), True)

    def get_arguments_test(self):
        """Test GetArguments."""
        with self.assertRaises(UnavailableStorageError):
            self.bootloader_interface.GetArguments()

        storage = Mock()
        self.bootloader_module.on_storage_changed(storage)

        storage.bootloader = GRUB2()
        storage.bootloader.boot_args.update(["x=1", "y=2"])
        self.assertEqual(self.bootloader_interface.GetArguments(),
                         ["x=1", "y=2"])

    def detect_windows_test(self):
        """Test DetectWindows."""
        with self.assertRaises(UnavailableStorageError):
            self.bootloader_interface.DetectWindows()

        device = Mock()
        device.format.name = "ntfs"

        storage = Mock()
        storage.devices = [device]

        self.bootloader_module.on_storage_changed(storage)

        storage.bootloader.has_windows.return_value = False
        self.assertEqual(self.bootloader_interface.DetectWindows(), False)

        storage.bootloader.has_windows.return_value = True
        self.assertEqual(self.bootloader_interface.DetectWindows(), True)

    @patch_dbus_publish_object
    def install_bootloader_with_tasks_test(self, publisher):
        """Test InstallBootloaderWithTasks."""
        storage = Mock()
        version = "4.17.7-200.fc28.x86_64"

        self.bootloader_module.on_storage_changed(storage)

        task_classes = [
            CreateRescueImagesTask, ConfigureBootloaderTask,
            InstallBootloaderTask, CreateBLSEntriesTask
        ]

        task_paths = self.bootloader_interface.InstallBootloaderWithTasks(
            PAYLOAD_TYPE_LIVE_IMAGE, [version])

        check_task_creation_list(self, task_paths, publisher, task_classes)

    @patch_dbus_publish_object
    def generate_initramfs_with_tasks_test(self, publisher):
        """Test GenerateInitramfsWithTasks."""
        storage = Mock()
        version = "4.17.7-200.fc28.x86_64"

        self.bootloader_module.on_storage_changed(storage)

        task_classes = [
            RecreateInitrdsTask,
            FixBTRFSBootloaderTask,
            FixZIPLBootloaderTask,
        ]

        task_paths = self.bootloader_interface.GenerateInitramfsWithTasks(
            PAYLOAD_TYPE_LIVE_IMAGE, [version])

        check_task_creation_list(self, task_paths, publisher, task_classes)
Beispiel #7
0
    def __init__(self):
        super().__init__()
        # Initialize Blivet.
        enable_installer_mode()

        # The storage model.
        self._current_storage = None
        self._storage_playground = None
        self.storage_changed = Signal()

        # The created partitioning modules.
        self._created_partitioning = []
        self.created_partitioning_changed = Signal()

        # The applied partitioning module.
        self._applied_partitioning = None
        self.applied_partitioning_changed = Signal()
        self.partitioning_reset = Signal()

        # Initialize modules.
        self._modules = []

        self._storage_checker_module = StorageCheckerModule()
        self._add_module(self._storage_checker_module)

        self._device_tree_module = DeviceTreeModule()
        self._add_module(self._device_tree_module)

        self._disk_init_module = DiskInitializationModule()
        self._add_module(self._disk_init_module)

        self._disk_selection_module = DiskSelectionModule()
        self._add_module(self._disk_selection_module)

        self._snapshot_module = SnapshotModule()
        self._add_module(self._snapshot_module)

        self._bootloader_module = BootloaderModule()
        self._add_module(self._bootloader_module)

        self._fcoe_module = FCOEModule()
        self._add_module(self._fcoe_module)

        self._iscsi_module = ISCSIModule()
        self._add_module(self._iscsi_module)

        self._nvdimm_module = NVDIMMModule()
        self._add_module(self._nvdimm_module)

        self._dasd_module = DASDModule()
        self._add_module(self._dasd_module)

        self._zfcp_module = ZFCPModule()
        self._add_module(self._zfcp_module)

        # Connect modules to signals.
        self.storage_changed.connect(
            self._device_tree_module.on_storage_changed)
        self.storage_changed.connect(self._disk_init_module.on_storage_changed)
        self.storage_changed.connect(
            self._disk_selection_module.on_storage_changed)
        self.storage_changed.connect(self._snapshot_module.on_storage_changed)
        self.storage_changed.connect(
            self._bootloader_module.on_storage_changed)
        self.storage_changed.connect(self._dasd_module.on_storage_changed)
        self._disk_init_module.format_unrecognized_enabled_changed.connect(
            self._dasd_module.on_format_unrecognized_enabled_changed)
        self._disk_init_module.format_ldl_enabled_changed.connect(
            self._dasd_module.on_format_ldl_enabled_changed)
        self._disk_selection_module.protected_devices_changed.connect(
            self.on_protected_devices_changed)
Beispiel #8
0
    def __init__(self):
        super().__init__()
        # Initialize Blivet.
        enable_installer_mode()

        # The storage model.
        self._storage = None
        self.storage_changed = Signal()
        self.storage_reset = Signal()

        # The created partitioning modules.
        self._created_partitioning = []
        self.created_partitioning_changed = Signal()

        # The applied partitioning module.
        self._applied_partitioning = None
        self.applied_partitioning_changed = Signal()

        # Initialize modules.
        self._modules = []

        self._storage_checker_module = StorageCheckerModule()
        self._add_module(self._storage_checker_module)

        self._device_tree_module = DeviceTreeModule()
        self._add_module(self._device_tree_module)

        self._disk_init_module = DiskInitializationModule()
        self._add_module(self._disk_init_module)

        self._disk_selection_module = DiskSelectionModule()
        self._add_module(self._disk_selection_module)

        self._snapshot_module = SnapshotModule()
        self._add_module(self._snapshot_module)

        self._bootloader_module = BootloaderModule()
        self._add_module(self._bootloader_module)

        self._fcoe_module = FCOEModule()
        self._add_module(self._fcoe_module)

        self._iscsi_module = ISCSIModule()
        self._add_module(self._iscsi_module)

        self._nvdimm_module = NVDIMMModule()
        self._add_module(self._nvdimm_module)

        self._dasd_module = None
        self._zfcp_module = None

        if arch.is_s390():
            self._dasd_module = DASDModule()
            self._add_module(self._dasd_module)

            self._zfcp_module = ZFCPModule()
            self._add_module(self._zfcp_module)

        # Initialize the partitioning modules.
        # TODO: Remove the static partitioning modules.
        self._add_module(self.create_partitioning(
            PartitioningMethod.AUTOMATIC))
        self._add_module(self.create_partitioning(PartitioningMethod.MANUAL))
        self._add_module(self.create_partitioning(PartitioningMethod.CUSTOM))
        self._add_module(
            self.create_partitioning(PartitioningMethod.INTERACTIVE))
        self._add_module(self.create_partitioning(PartitioningMethod.BLIVET))
        # Forget the static partitioning modules.
        # TODO: Remove with the static partitioning modules.
        self._created_partitioning = []

        # Connect modules to signals.
        self.storage_changed.connect(self._device_tree_module.on_storage_reset)
        self.storage_changed.connect(self._disk_init_module.on_storage_reset)
        self.storage_changed.connect(
            self._disk_selection_module.on_storage_reset)
        self.storage_changed.connect(self._snapshot_module.on_storage_reset)
        self.storage_changed.connect(self._bootloader_module.on_storage_reset)
        self._disk_selection_module.protected_devices_changed.connect(
            self.on_protected_devices_changed)
 def setUp(self):
     """Set up the module."""
     self.bootloader_module = BootloaderModule()
     self.bootloader_interface = BootloaderInterface(self.bootloader_module)
class BootloaderInterfaceTestCase(unittest.TestCase):
    """Test DBus interface of the bootloader module."""

    def setUp(self):
        """Set up the module."""
        self.bootloader_module = BootloaderModule()
        self.bootloader_interface = BootloaderInterface(self.bootloader_module)

    def _test_dbus_property(self, *args, **kwargs):
        check_dbus_property(
            self,
            BOOTLOADER,
            self.bootloader_interface,
            *args, **kwargs
        )

    def bootloader_mode_property_test(self):
        """Test the bootloader mode property."""
        self._test_dbus_property(
            "BootloaderMode",
            BOOTLOADER_SKIPPED
        )

    def bootloader_type_property_test(self):
        """Test the bootloader type property."""
        self._test_dbus_property(
            "BootloaderType",
            BOOTLOADER_TYPE_EXTLINUX
        )

    def preferred_location_property_test(self):
        """Test the preferred location property."""
        self._test_dbus_property(
            "PreferredLocation",
            BOOTLOADER_LOCATION_PARTITION
        )

    def drive_property_test(self):
        """Test the drive property."""
        self._test_dbus_property(
            "Drive",
            "sda"
        )

    def drive_order_property_test(self):
        """Test the drive order property."""
        self._test_dbus_property(
            "DriveOrder",
            ["sda", "sdb"]
        )

    def keep_mbr_property_test(self):
        """Test the keep MBR property."""
        self._test_dbus_property(
            "KeepMBR",
            True
        )

    def keep_boot_order_test(self):
        """Test the keep boot order property."""
        self._test_dbus_property(
            "KeepBootOrder",
            True
        )

    def extra_arguments_property_test(self):
        """Test the extra arguments property."""
        self._test_dbus_property(
            "ExtraArguments",
            ["hdd=ide-scsi", "ide=nodma"]
        )

    def timeout_property_test(self):
        """Test the timeout property."""
        self._test_dbus_property(
            "Timeout",
            25
        )

    def password_property_test(self):
        """Test the password property."""
        self._test_dbus_property(
            "Password",
            "12345",
            setter=self.bootloader_interface.SetEncryptedPassword,
            changed={'IsPasswordSet': True}
        )

    def is_efi_test(self):
        """Test IsEFI."""
        with self.assertRaises(UnavailableStorageError):
            self.bootloader_interface.IsEFI()

        storage = Mock()
        self.bootloader_module.on_storage_reset(storage)

        storage.bootloader = GRUB2()
        self.assertEqual(self.bootloader_interface.IsEFI(), False)

        storage.bootloader = EFIGRUB()
        self.assertEqual(self.bootloader_interface.IsEFI(), True)

    def get_arguments_test(self):
        """Test GetArguments."""
        with self.assertRaises(UnavailableStorageError):
            self.bootloader_interface.GetArguments()

        storage = Mock()
        self.bootloader_module.on_storage_reset(storage)

        storage.bootloader = GRUB2()
        storage.bootloader.boot_args.update(["x=1", "y=2"])
        self.assertEqual(self.bootloader_interface.GetArguments(), ["x=1", "y=2"])

    def detect_windows_test(self):
        """Test DetectWindows."""
        with self.assertRaises(UnavailableStorageError):
            self.bootloader_interface.DetectWindows()

        device = Mock()
        device.format.name = "ntfs"

        storage = Mock()
        storage.devices = [device]

        self.bootloader_module.on_storage_reset(storage)

        storage.bootloader.has_windows.return_value = False
        self.assertEqual(self.bootloader_interface.DetectWindows(), False)

        storage.bootloader.has_windows.return_value = True
        self.assertEqual(self.bootloader_interface.DetectWindows(), True)

    @patch('pyanaconda.dbus.DBus.publish_object')
    def configure_with_task_test(self, publisher):
        """Test ConfigureWithTask."""
        storage = Mock()
        sysroot = "/mnt/sysroot"
        version = "4.17.7-200.fc28.x86_64"

        self.bootloader_module.on_storage_reset(storage)
        task_path = self.bootloader_interface.ConfigureWithTask(sysroot, [version])

        publisher.assert_called_once()
        object_path, obj = publisher.call_args[0]

        self.assertEqual(task_path, object_path)
        self.assertIsInstance(obj, TaskInterface)

        self.assertIsInstance(obj.implementation, ConfigureBootloaderTask)
        self.assertEqual(obj.implementation._storage, storage)
        self.assertEqual(obj.implementation._sysroot, sysroot)
        self.assertEqual(obj.implementation._versions, [version])

    @patch('pyanaconda.dbus.DBus.publish_object')
    def install_with_task_test(self, publisher):
        """Test InstallWithTask."""
        storage = Mock()
        sysroot = "/mnt/sysroot"

        self.bootloader_module.on_storage_reset(storage)
        task_path = self.bootloader_interface.InstallWithTask(sysroot)

        publisher.assert_called_once()
        object_path, obj = publisher.call_args[0]

        self.assertEqual(task_path, object_path)
        self.assertIsInstance(obj, TaskInterface)

        self.assertIsInstance(obj.implementation, InstallBootloaderTask)
        self.assertEqual(obj.implementation._storage, storage)
        self.assertEqual(obj.implementation._sysroot, sysroot)
Beispiel #11
0
class BootloaderInterfaceTestCase(unittest.TestCase):
    """Test DBus interface of the bootloader module."""
    def setUp(self):
        """Set up the module."""
        self.bootloader_module = BootloaderModule()
        self.bootloader_interface = BootloaderInterface(self.bootloader_module)

    def _test_dbus_property(self, *args, **kwargs):
        check_dbus_property(self, BOOTLOADER, self.bootloader_interface, *args,
                            **kwargs)

    def bootloader_mode_property_test(self):
        """Test the bootloader mode property."""
        self._test_dbus_property("BootloaderMode", BOOTLOADER_SKIPPED)

    def bootloader_type_property_test(self):
        """Test the bootloader type property."""
        self._test_dbus_property("BootloaderType", BOOTLOADER_TYPE_EXTLINUX)

    def preferred_location_property_test(self):
        """Test the preferred location property."""
        self._test_dbus_property("PreferredLocation",
                                 BOOTLOADER_LOCATION_PARTITION)

    def drive_property_test(self):
        """Test the drive property."""
        self._test_dbus_property("Drive", "sda")

    def drive_order_property_test(self):
        """Test the drive order property."""
        self._test_dbus_property("DriveOrder", ["sda", "sdb"])

    def keep_mbr_property_test(self):
        """Test the keep MBR property."""
        self._test_dbus_property("KeepMBR", True)

    def keep_boot_order_test(self):
        """Test the keep boot order property."""
        self._test_dbus_property("KeepBootOrder", True)

    def extra_arguments_property_test(self):
        """Test the extra arguments property."""
        self._test_dbus_property("ExtraArguments",
                                 ["hdd=ide-scsi", "ide=nodma"])

    def timeout_property_test(self):
        """Test the timeout property."""
        self._test_dbus_property("Timeout", 25)

    def password_property_test(self):
        """Test the password property."""
        self._test_dbus_property(
            "Password",
            "12345",
            setter=self.bootloader_interface.SetEncryptedPassword,
            changed={'IsPasswordSet': True})

    def is_efi_test(self):
        """Test IsEFI."""
        with self.assertRaises(UnavailableStorageError):
            self.bootloader_interface.IsEFI()

        storage = Mock()
        self.bootloader_module.on_storage_reset(storage)

        storage.bootloader = GRUB2()
        self.assertEqual(self.bootloader_interface.IsEFI(), False)

        storage.bootloader = EFIGRUB()
        self.assertEqual(self.bootloader_interface.IsEFI(), True)

    def get_arguments_test(self):
        """Test GetArguments."""
        with self.assertRaises(UnavailableStorageError):
            self.bootloader_interface.GetArguments()

        storage = Mock()
        self.bootloader_module.on_storage_reset(storage)

        storage.bootloader = GRUB2()
        storage.bootloader.boot_args.update(["x=1", "y=2"])
        self.assertEqual(self.bootloader_interface.GetArguments(),
                         ["x=1", "y=2"])

    def detect_windows_test(self):
        """Test DetectWindows."""
        with self.assertRaises(UnavailableStorageError):
            self.bootloader_interface.DetectWindows()

        device = Mock()
        device.format.name = "ntfs"

        storage = Mock()
        storage.devices = [device]

        self.bootloader_module.on_storage_reset(storage)

        storage.bootloader.has_windows.return_value = False
        self.assertEqual(self.bootloader_interface.DetectWindows(), False)

        storage.bootloader.has_windows.return_value = True
        self.assertEqual(self.bootloader_interface.DetectWindows(), True)

    @patch_dbus_publish_object
    def configure_with_task_test(self, publisher):
        """Test ConfigureWithTask."""
        storage = Mock()
        version = "4.17.7-200.fc28.x86_64"

        self.bootloader_module.on_storage_reset(storage)
        task_path = self.bootloader_interface.ConfigureWithTask([version])

        obj = check_task_creation(self, task_path, publisher,
                                  ConfigureBootloaderTask)

        self.assertEqual(obj.implementation._storage, storage)
        self.assertEqual(obj.implementation._versions, [version])

    @patch_dbus_publish_object
    def install_with_task_test(self, publisher):
        """Test InstallWithTask."""
        storage = Mock()

        self.bootloader_module.on_storage_reset(storage)
        task_path = self.bootloader_interface.InstallWithTask()

        obj = check_task_creation(self, task_path, publisher,
                                  InstallBootloaderTask)

        self.assertEqual(obj.implementation._storage, storage)

    @patch_dbus_publish_object
    def fix_btrfs_with_task_test(self, publisher):
        """Test FixBTRFSWithTask."""
        storage = Mock()
        version = "4.17.7-200.fc28.x86_64"

        self.bootloader_module.on_storage_reset(storage)
        task_path = self.bootloader_interface.FixBTRFSWithTask([version])

        obj = check_task_creation(self, task_path, publisher,
                                  FixBTRFSBootloaderTask)
        self.assertEqual(obj.implementation._storage, storage)
        self.assertEqual(obj.implementation._versions, [version])

    @patch_dbus_publish_object
    def fix_zipl_with_task_test(self, publisher):
        """Test FixZIPLWithTask."""
        storage = Mock()

        self.bootloader_module.on_storage_reset(storage)
        task_path = self.bootloader_interface.FixZIPLWithTask()

        obj = check_task_creation(self, task_path, publisher,
                                  FixZIPLBootloaderTask)
        self.assertEqual(obj.implementation._mode,
                         self.bootloader_module.bootloader_mode)