コード例 #1
0
    def create_live_os_handler(self):
        """Create the live os payload handler and publish it on dbus.

        FIXME: This is only temporary and the solution to manage handlers will change.
        """
        self._payload_handler = LiveOSHandlerModule()
        self._publish_handler()
コード例 #2
0
class PayloadModule(KickstartModule):
    """The Payload module."""
    def __init__(self):
        super().__init__()
        self._payload_handler = None

    def publish(self):
        """Publish the module."""
        DBus.publish_object(PAYLOAD.object_path, PayloadInterface(self))
        DBus.register_service(PAYLOAD.service_name)

    def _publish_handler(self):
        """Publish handler as soon as we know which one to chose"""
        self._payload_handler.publish()

    @property
    def kickstart_specification(self):
        """Return the kickstart specification."""
        return PayloadKickstartSpecification

    def process_kickstart(self, data):
        """Process the kickstart data."""
        log.debug("Processing kickstart data...")

        self._create_correct_handler(data)
        self._publish_handler()

        self._payload_handler.process_kickstart(data)

    def _create_correct_handler(self, data):
        if data.liveimg.seen:
            self._payload_handler = LiveImageHandlerModule()
        else:
            self._payload_handler = DNFHandlerModule()

    def generate_kickstart(self):
        """Return the kickstart string."""
        log.debug("Generating kickstart data...")
        data = self.get_kickstart_handler()

        self._payload_handler.setup_kickstart(data)

        return str(data)

    def create_live_os_handler(self):
        """Create the live os payload handler and publish it on dbus.

        FIXME: This is only temporary and the solution to manage handlers will change.
        """
        self._payload_handler = LiveOSHandlerModule()
        self._publish_handler()
コード例 #3
0
ファイル: factory.py プロジェクト: ScottL97/anaconda
 def _create(cls, object_type):
     if object_type == HandlerType.LIVE_IMAGE:
         return LiveImageHandlerModule()
     elif object_type == HandlerType.LIVE_OS:
         return LiveOSHandlerModule()
     elif object_type == HandlerType.DNF:
         return DNFHandlerModule()
コード例 #4
0
    def setUp(self):
        self.live_os_module = LiveOSHandlerModule()
        self.live_os_interface = LiveOSHandlerInterface(self.live_os_module)

        self.callback = Mock()
        self.live_os_interface.PropertiesChanged.connect(self.callback)
コード例 #5
0
class LiveOSHandlerInterfaceTestCase(unittest.TestCase):
    def setUp(self):
        self.live_os_module = LiveOSHandlerModule()
        self.live_os_interface = LiveOSHandlerInterface(self.live_os_module)

        self.callback = Mock()
        self.live_os_interface.PropertiesChanged.connect(self.callback)

    def _prepare_and_use_source(self):
        source = create_autospec(LiveOSSourceModule())
        source.image_path = "/test/path"
        source.type = SourceType.LIVE_OS_IMAGE
        source.is_ready.return_value = True

        self.live_os_module.set_sources([source])

        return source

    @patch("pyanaconda.modules.payload.live.live_os.get_dir_size")
    def space_required_properties_test(self, get_dir_size_mock):
        """Test Live OS SpaceRequired property."""
        get_dir_size_mock.return_value = 2

        self.assertEqual(self.live_os_interface.SpaceRequired, 2048)

    @patch("pyanaconda.modules.payload.live.live_os.get_kernel_version_list")
    def empty_kernel_version_list_test(self, get_kernel_version_list):
        """Test Live OS empty get kernel version list."""
        self.assertEqual(self.live_os_interface.GetKernelVersionList(), [])

        get_kernel_version_list.return_value = []
        kernel_list_callback = Mock()

        # pylint: disable=no-member
        self.live_os_interface.KernelVersionListChanged.connect(
            kernel_list_callback)
        self.live_os_interface.UpdateKernelVersionList()

        get_kernel_version_list.assert_called_once_with(INSTALL_TREE)

        self.assertEqual(self.live_os_interface.GetKernelVersionList(), [])
        kernel_list_callback.assert_called_once_with([])

    @patch("pyanaconda.modules.payload.live.live_os.get_kernel_version_list")
    def kernel_version_list_test(self, get_kernel_version_list):
        """Test Live OS get kernel version list."""
        kernel_list = [
            "kernel-abc", "magic-kernel.fc3000.x86_64", "sad-kernel"
        ]
        get_kernel_version_list.return_value = kernel_list
        kernel_list_callback = Mock()

        # pylint: disable=no-member
        self.live_os_interface.KernelVersionListChanged.connect(
            kernel_list_callback)
        self.live_os_interface.UpdateKernelVersionList()

        get_kernel_version_list.assert_called_once_with(INSTALL_TREE)

        self.assertListEqual(self.live_os_interface.GetKernelVersionList(),
                             kernel_list)
        kernel_list_callback.assert_called_once_with(kernel_list)

    @patch_dbus_publish_object
    def set_up_installation_sources_task_test(self, publisher):
        """Test Live OS is able to create a set up installation sources task."""
        self._prepare_and_use_source()

        task_path = self.live_os_interface.SetUpSourcesWithTask()

        check_task_creation(self, task_path, publisher, SetUpSourcesTask)

    @patch_dbus_publish_object
    def prepare_system_for_installation_task_test(self, publisher):
        """Test Live OS is able to create a prepare installation task."""
        self._prepare_and_use_source()

        task_path = self.live_os_interface.PreInstallWithTask()

        check_task_creation(self, task_path, publisher,
                            PrepareSystemForInstallationTask)

    @patch_dbus_publish_object
    def prepare_system_for_installation_task_no_source_test(self, publisher):
        """Test Live OS prepare installation task with no source fail."""
        with self.assertRaises(SourceSetupError):
            self.live_os_interface.PreInstallWithTask()

    @patch_dbus_publish_object
    def tear_down_installation_source_task_test(self, publisher):
        """Test Live OS is able to create a tear down installation sources task."""
        self._prepare_and_use_source()

        task_path = self.live_os_interface.TearDownSourcesWithTask()

        check_task_creation(self, task_path, publisher, TearDownSourcesTask)

    @patch_dbus_publish_object
    def install_with_task_test(self, publisher):
        """Test Live OS install with tasks."""
        self._prepare_and_use_source()

        task_path = self.live_os_interface.InstallWithTask()

        check_task_creation(self, task_path, publisher, InstallFromImageTask)

    @patch_dbus_publish_object
    def install_with_task_no_source_test(self, publisher):
        """Test Live OS install with tasks with no source fail."""
        with self.assertRaises(SourceSetupError):
            self.live_os_interface.InstallWithTask()

    @patch_dbus_publish_object
    def post_install_with_tasks_test(self, publisher):
        """Test Live OS post installation configuration task."""
        task_classes = [UpdateBLSConfigurationTask, CopyDriverDisksFilesTask]

        task_paths = self.live_os_interface.PostInstallWithTasks()

        # Check the number of installation tasks.
        task_number = len(task_classes)
        self.assertEqual(task_number, len(task_paths))
        self.assertEqual(task_number, publisher.call_count)

        # Check the tasks.
        for i in range(task_number):
            object_path, obj = publisher.call_args_list[i][0]
            self.assertEqual(object_path, task_paths[i])
            self.assertIsInstance(obj, TaskInterface)
            self.assertIsInstance(obj.implementation, task_classes[i])
コード例 #6
0
 def _create_correct_handler(self, data):
     if data.liveimg.seen:
         self._payload_handler = LiveImageHandlerModule()
     else:
         self._payload_handler = DNFHandlerModule()