Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 4
0
class DiskSelectionInterfaceTestCase(unittest.TestCase):
    """Test DBus interface of the disk selection module."""
    def setUp(self):
        """Set up the module."""
        self.disk_selection_module = DiskSelectionModule()
        self.disk_selection_interface = DiskSelectionInterface(
            self.disk_selection_module)

    def _test_dbus_property(self, *args, **kwargs):
        check_dbus_property(self, DISK_SELECTION,
                            self.disk_selection_interface, *args, **kwargs)

    def selected_disks_property_test(self):
        """Test the selected disks property."""
        self._test_dbus_property("SelectedDisks", ["sda", "sdb"])

    def exclusive_disks_property_test(self):
        """Test the exclusive disks property."""
        self._test_dbus_property("ExclusiveDisks", ["sda", "sdb"])

    def ignored_disks_property_test(self):
        """Test the ignored disks property."""
        self._test_dbus_property("IgnoredDisks", ["sda", "sdb"])

    def protected_disks_property_test(self):
        """Test the protected disks property."""
        self._test_dbus_property("ProtectedDevices", ["sda", "sdb"])

    def disk_images_property_test(self):
        """Test the protected disks property."""
        self._test_dbus_property("DiskImages", {
            "image_1": "/path/1",
            "image_2": "/path/2"
        })

    def get_usable_disks_test(self):
        """Test the GetUsableDisks method."""
        with self.assertRaises(UnavailableStorageError):
            self.disk_selection_interface.GetUsableDisks()

        self.disk_selection_module.on_storage_reset(create_storage())
        self.assertEqual(self.disk_selection_interface.GetUsableDisks(), [])
Esempio n. 5
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)
Esempio n. 6
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
Esempio n. 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)
 def setUp(self):
     """Set up the module."""
     self.disk_selection_module = DiskSelectionModule()
     self.disk_selection_interface = DiskSelectionInterface(
         self.disk_selection_module)
class DiskSelectionInterfaceTestCase(unittest.TestCase):
    """Test DBus interface of the disk selection module."""
    def setUp(self):
        """Set up the module."""
        self.disk_selection_module = DiskSelectionModule()
        self.disk_selection_interface = DiskSelectionInterface(
            self.disk_selection_module)

    def _test_dbus_property(self, *args, **kwargs):
        check_dbus_property(self, DISK_SELECTION,
                            self.disk_selection_interface, *args, **kwargs)

    def selected_disks_property_test(self):
        """Test the selected disks property."""
        self._test_dbus_property("SelectedDisks", ["sda", "sdb"])

    def validate_selected_disks_test(self):
        """Test ValidateSelectedDisks."""
        storage = create_storage()
        self.disk_selection_module.on_storage_changed(storage)

        dev1 = DiskDevice("dev1",
                          exists=False,
                          size=Size("15 GiB"),
                          fmt=get_format("disklabel"))
        dev2 = DiskDevice("dev2",
                          exists=False,
                          parents=[dev1],
                          size=Size("6 GiB"),
                          fmt=get_format("disklabel"))
        dev3 = DiskDevice("dev3",
                          exists=False,
                          parents=[dev2],
                          size=Size("6 GiB"),
                          fmt=get_format("disklabel"))
        storage.devicetree._add_device(dev1)
        storage.devicetree._add_device(dev2)
        storage.devicetree._add_device(dev3)

        report = ValidationReport.from_structure(
            self.disk_selection_interface.ValidateSelectedDisks([]))

        self.assertEqual(report.is_valid(), True)

        report = ValidationReport.from_structure(
            self.disk_selection_interface.ValidateSelectedDisks(["dev1"]))

        self.assertEqual(report.is_valid(), False)
        self.assertEqual(report.error_messages, [
            "You selected disk dev1, which contains devices that also use "
            "unselected disks dev2, dev3. You must select or de-select "
            "these disks as a set."
        ])
        self.assertEqual(report.warning_messages, [])

        report = ValidationReport.from_structure(
            self.disk_selection_interface.ValidateSelectedDisks(
                ["dev1", "dev2"]))

        self.assertEqual(report.is_valid(), False)
        self.assertEqual(report.error_messages, [
            "You selected disk dev1, which contains devices that also "
            "use unselected disk dev3. You must select or de-select "
            "these disks as a set.",
            "You selected disk dev2, which contains devices that also "
            "use unselected disk dev3. You must select or de-select "
            "these disks as a set."
        ])
        self.assertEqual(report.warning_messages, [])

        report = ValidationReport.from_structure(
            self.disk_selection_interface.ValidateSelectedDisks(
                ["dev1", "dev2", "dev3"]))

        self.assertEqual(report.is_valid(), True)

    def exclusive_disks_property_test(self):
        """Test the exclusive disks property."""
        self._test_dbus_property("ExclusiveDisks", ["sda", "sdb"])

    def ignored_disks_property_test(self):
        """Test the ignored disks property."""
        self._test_dbus_property("IgnoredDisks", ["sda", "sdb"])

    def protected_disks_property_test(self):
        """Test the protected disks property."""
        self._test_dbus_property("ProtectedDevices", ["sda", "sdb"])

    def disk_images_property_test(self):
        """Test the protected disks property."""
        self._test_dbus_property("DiskImages", {
            "image_1": "/path/1",
            "image_2": "/path/2"
        })

    def get_usable_disks_test(self):
        """Test the GetUsableDisks method."""
        with self.assertRaises(UnavailableStorageError):
            self.disk_selection_interface.GetUsableDisks()

        self.disk_selection_module.on_storage_changed(create_storage())
        self.assertEqual(self.disk_selection_interface.GetUsableDisks(), [])
Esempio n. 10
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)
Esempio n. 11
0
 def setUp(self):
     """Set up the module."""
     self.disk_selection_module = DiskSelectionModule()
     self.disk_selection_interface = DiskSelectionInterface(self.disk_selection_module)
Esempio n. 12
0
class DiskSelectionInterfaceTestCase(unittest.TestCase):
    """Test DBus interface of the disk selection module."""

    def setUp(self):
        """Set up the module."""
        self.disk_selection_module = DiskSelectionModule()
        self.disk_selection_interface = DiskSelectionInterface(self.disk_selection_module)

    def _test_dbus_property(self, *args, **kwargs):
        check_dbus_property(
            self,
            DISK_SELECTION,
            self.disk_selection_interface,
            *args, **kwargs
        )

    def selected_disks_property_test(self):
        """Test the selected disks property."""
        self._test_dbus_property(
            "SelectedDisks",
            ["sda", "sdb"]
        )

    def exclusive_disks_property_test(self):
        """Test the exclusive disks property."""
        self._test_dbus_property(
            "ExclusiveDisks",
            ["sda", "sdb"]
        )

    def ignored_disks_property_test(self):
        """Test the ignored disks property."""
        self._test_dbus_property(
            "IgnoredDisks",
            ["sda", "sdb"]
        )

    def protected_disks_property_test(self):
        """Test the protected disks property."""
        self._test_dbus_property(
            "ProtectedDevices",
            ["sda", "sdb"]
        )

    def disk_images_property_test(self):
        """Test the protected disks property."""
        self._test_dbus_property(
            "DiskImages",
            {
                "image_1": "/path/1",
                "image_2": "/path/2"
             }
        )

    def get_usable_disks_test(self):
        """Test the GetUsableDisks method."""
        with self.assertRaises(UnavailableStorageError):
            self.disk_selection_interface.GetUsableDisks()

        self.disk_selection_module.on_storage_reset(create_storage())
        self.assertEqual(self.disk_selection_interface.GetUsableDisks(), [])