def configure_runtime_test(self, proxy_getter): """Configure the runtime system with three tasks.""" observers = [] observer = Mock() observer.is_service_available = True observer.service_name = "A" observer.proxy.ConfigureWithTasks.return_value = ["/A/1"] observers.append(observer) observer = Mock() observer.is_service_available = True observer.service_name = "B" observer.proxy.ConfigureWithTasks.return_value = ["/B/1", "/B/2"] observers.append(observer) task_proxy = Mock() task_proxy.Steps = 1 proxy_getter.return_value = task_proxy install_manager = InstallManager() install_manager.on_module_observers_changed(observers) proxies = install_manager.collect_configure_runtime_tasks() self.assertEqual(proxies, [task_proxy, task_proxy, task_proxy]) proxy_getter.assert_has_calls( [call("A", "/A/1"), call("B", "/B/1"), call("B", "/B/2")])
def install_with_no_modules_test(self): """Install with no modules.""" install_manager = InstallManager() install_manager.module_observers = [] main_task = install_manager.install_system_with_task() self.assertIsInstance(main_task, SystemInstallationTask) self.assertEqual(main_task._subtasks, [])
def install_three_tasks_test(self, proxy_getter): """Install with three tasks.""" observers = [] observer = Mock() observer.is_service_available = True observer.service_name = "A" observer.proxy.InstallWithTasks.return_value = ["/A/1"] observers.append(observer) observer = Mock() observer.is_service_available = True observer.service_name = "B" observer.proxy.InstallWithTasks.return_value = ["/B/1", "/B/2"] observers.append(observer) task_proxy = Mock() task_proxy.Steps = 1 proxy_getter.return_value = task_proxy install_manager = InstallManager() install_manager.module_observers = observers main_task = install_manager.install_system_with_task() proxy_getter.assert_has_calls([ call("A", "/A/1"), call("B", "/B/1"), call("B", "/B/2") ]) self.assertIsInstance(main_task, SystemInstallationTask) self.assertEqual(main_task._subtasks, [task_proxy, task_proxy, task_proxy])
def test_install_three_tasks(self, proxy_getter): """Install with three tasks.""" observers = [] observer = Mock() observer.is_service_available = True observer.service_name = "A" observer.proxy.InstallWithTasks.return_value = ["/A/1"] observers.append(observer) observer = Mock() observer.is_service_available = True observer.service_name = "B" observer.proxy.InstallWithTasks.return_value = ["/B/1", "/B/2"] observers.append(observer) task_proxy = Mock() task_proxy.Steps = 1 proxy_getter.return_value = task_proxy install_manager = InstallManager() install_manager.on_module_observers_changed(observers) proxies = install_manager.collect_install_system_tasks() assert proxies == [task_proxy, task_proxy, task_proxy] proxy_getter.assert_has_calls( [call("A", "/A/1"), call("B", "/B/1"), call("B", "/B/2")])
def install_with_no_modules_test(self): """Install with no modules.""" install_manager = InstallManager() install_manager.module_observers = [] main_task = install_manager.install_system_with_task() self.assertIsInstance(main_task, SystemInstallationTask) self.assertEqual(main_task._subtasks, [])
def install_three_tasks_test(self, proxy_getter): """Install with three tasks.""" observers = [] observer = Mock() observer.is_service_available = True observer.service_name = "A" observer.proxy.InstallWithTasks.return_value = ["/A/1"] observers.append(observer) observer = Mock() observer.is_service_available = True observer.service_name = "B" observer.proxy.InstallWithTasks.return_value = ["/B/1", "/B/2"] observers.append(observer) task_proxy = Mock() task_proxy.Steps = 1 proxy_getter.return_value = task_proxy install_manager = InstallManager() install_manager.module_observers = observers main_task = install_manager.install_system_with_task() proxy_getter.assert_has_calls( [call("A", "/A/1"), call("B", "/B/1"), call("B", "/B/2")]) self.assertIsInstance(main_task, SystemInstallationTask) self.assertEqual(main_task._subtasks, [task_proxy, task_proxy, task_proxy])
def install_with_no_modules_test(self): """Install with no modules.""" install_manager = InstallManager() install_manager.on_module_observers_changed([]) main_task = install_manager.install_system_with_task() self.assertIsInstance(main_task, DBusMetaTask) self.assertEqual(main_task.name, "Install the system") self.assertEqual(main_task._subtasks, [])
def install_with_no_tasks_test(self): """Install with no tasks.""" observer = Mock() observer.is_service_available = True observer.service_name = "A" observer.proxy.InstallWithTasks.return_value = [] install_manager = InstallManager() install_manager.on_module_observers_changed([observer]) proxies = install_manager.collect_install_system_tasks() self.assertEqual(proxies, [])
def __init__(self): super().__init__() self._module_manager = ModuleManager() self._kickstart_manager = KickstartManager() self._install_manager = InstallManager() self._module_manager.module_observers_changed.connect( self._kickstart_manager.on_module_observers_changed) self._module_manager.module_observers_changed.connect( self._install_manager.on_module_observers_changed)
def install_with_no_tasks_test(self): """Install with no tasks.""" observer = Mock() observer.is_service_available = True observer.service_name = "A" observer.proxy.InstallWithTasks.return_value = [] install_manager = InstallManager() install_manager.module_observers = [observer] main_task = install_manager.install_system_with_task() self.assertIsInstance(main_task, SystemInstallationTask) self.assertEqual(main_task._subtasks, [])
def install_with_no_tasks_test(self): """Install with no tasks.""" observer = Mock() observer.is_service_available = True observer.service_name = "A" observer.proxy.InstallWithTasks.return_value = [] install_manager = InstallManager() install_manager.module_observers = [observer] main_task = install_manager.install_system_with_task() self.assertIsInstance(main_task, SystemInstallationTask) self.assertEqual(main_task._subtasks, [])
def install_with_no_tasks_test(self): """Install with no tasks.""" observer = Mock() observer.is_service_available = True observer.service_name = "A" observer.proxy.InstallWithTasks.return_value = [] install_manager = InstallManager() install_manager.on_module_observers_changed([observer]) main_task = install_manager.install_system_with_task() self.assertIsInstance(main_task, DBusMetaTask) self.assertEqual(main_task.name, "Install the system") self.assertEqual(main_task._subtasks, [])
def __init__(self, module_manager=None, install_manager=None, kickstart_manager=None): super().__init__() self._module_manager = module_manager or ModuleManager() self._install_manager = install_manager or InstallManager() self._kickstart_manager = kickstart_manager or KickstartManager() self._setup_install_manager() self._setup_kickstart_manager()
def install_one_task_test(self, proxy_getter): """Install with one task.""" observer = Mock() observer.is_service_available = True observer.service_name = "A" observer.proxy.InstallWithTasks.return_value = ["/A/1"] task_proxy = Mock() task_proxy.Steps = 1 proxy_getter.return_value = task_proxy install_manager = InstallManager() install_manager.on_module_observers_changed([observer]) proxies = install_manager.collect_install_system_tasks() self.assertEqual(proxies, [task_proxy]) proxy_getter.assert_called_once_with("A", "/A/1")
def install_one_task_test(self, proxy_getter): """Install with one task.""" observer = Mock() observer.is_service_available = True observer.service_name = "A" observer.proxy.InstallWithTasks.return_value = ["/A/1"] task_proxy = Mock() task_proxy.Steps = 1 proxy_getter.return_value = task_proxy install_manager = InstallManager() install_manager.module_observers = [observer] main_task = install_manager.install_system_with_task() proxy_getter.assert_called_once_with("A", "/A/1") self.assertIsInstance(main_task, SystemInstallationTask) self.assertEqual(main_task._subtasks, [task_proxy])
def install_one_task_test(self, proxy_getter): """Install with one task.""" observer = Mock() observer.is_service_available = True observer.service_name = "A" observer.proxy.InstallWithTasks.return_value = ["/A/1"] task_proxy = Mock() task_proxy.Steps = 1 proxy_getter.return_value = task_proxy install_manager = InstallManager() install_manager.module_observers = [observer] main_task = install_manager.install_system_with_task() proxy_getter.assert_called_once_with("A", "/A/1") self.assertIsInstance(main_task, SystemInstallationTask) self.assertEqual(main_task._subtasks, [task_proxy])
def test_install_with_no_modules(self): """Install with no modules.""" install_manager = InstallManager() install_manager.on_module_observers_changed([]) proxies = install_manager.collect_install_system_tasks() assert proxies == []
class Boss(Service): """The Boss service.""" def __init__(self): super().__init__() self._module_manager = ModuleManager() self._kickstart_manager = KickstartManager() self._install_manager = InstallManager() self._module_manager.module_observers_changed.connect( self._kickstart_manager.on_module_observers_changed) self._module_manager.module_observers_changed.connect( self._install_manager.on_module_observers_changed) def publish(self): """Publish the boss.""" TaskContainer.set_namespace(BOSS.namespace) DBus.publish_object(BOSS.object_path, BossInterface(self)) DBus.register_service(BOSS.service_name) def get_modules(self): """Get service names of running modules. Get a list of all running DBus modules (including addons) that were discovered and started by the boss. :return: a list of service names """ return self._module_manager.get_service_names() def start_modules_with_task(self): """Start the modules with the task.""" return self._module_manager.start_modules_with_task() def stop(self): """Stop all modules and then stop the boss.""" self._module_manager.stop_modules() super().stop() def read_kickstart_file(self, path): """Read the specified kickstart file. :param path: a path to a file :returns: a kickstart report """ log.info("Reading a kickstart file at %s.", path) return self._kickstart_manager.read_kickstart_file(path) def generate_kickstart(self): """Return a kickstart representation of modules. :return: a kickstart string """ log.info("Generating kickstart data...") return self._kickstart_manager.generate_kickstart() def collect_requirements(self): """Collect requirements of the modules. :return: a list of requirements """ return self._install_manager.collect_requirements() def configure_runtime_with_task(self): """Configure the runtime environment. FIXME: This method temporarily uses only addons. :return: a task """ return self._install_manager.configure_runtime_with_task() def install_system_with_task(self): """Install the system. FIXME: This method temporarily uses only addons. :return: a task """ return self._install_manager.install_system_with_task() def set_locale(self, locale): """Set locale of boss and all modules. :param str locale: locale to set """ log.info("Setting locale of all modules to %s.", locale) super().set_locale(locale) self._module_manager.set_modules_locale(locale)
def install_with_no_modules_test(self): """Install with no modules.""" install_manager = InstallManager() install_manager.on_module_observers_changed([]) proxies = install_manager.collect_install_system_tasks() self.assertEqual(proxies, [])
class Boss(Service): """The Boss service.""" def __init__(self): super().__init__() self._module_manager = ModuleManager() self._kickstart_manager = KickstartManager() self._install_manager = InstallManager() self._ui_module = UIModule() self._module_manager.module_observers_changed.connect( self._kickstart_manager.on_module_observers_changed) self._module_manager.module_observers_changed.connect( self._install_manager.on_module_observers_changed) def publish(self): """Publish the boss.""" TaskContainer.set_namespace(BOSS.namespace) # Publish submodules. self._ui_module.publish() DBus.publish_object(BOSS.object_path, BossInterface(self)) DBus.register_service(BOSS.service_name) def get_modules(self): """Get service names of running modules. Get a list of all running DBus modules (including addons) that were discovered and started by the boss. :return: a list of service names """ return self._module_manager.get_service_names() def start_modules_with_task(self): """Start the modules with the task.""" return self._module_manager.start_modules_with_task() def stop(self): """Stop all modules and then stop the boss.""" self._module_manager.stop_modules() super().stop() def read_kickstart_file(self, path): """Read the specified kickstart file. :param path: a path to a file :returns: a kickstart report """ log.info("Reading a kickstart file at %s.", path) return self._kickstart_manager.read_kickstart_file(path) def generate_kickstart(self): """Return a kickstart representation of modules. :return: a kickstart string """ log.info("Generating kickstart data...") return self._kickstart_manager.generate_kickstart() def collect_requirements(self): """Collect requirements of the modules. :return: a list of requirements """ return self._install_manager.collect_requirements() def collect_configure_runtime_tasks(self): """Collect tasks for configuration of the runtime environment. FIXME: This method temporarily uses only addons. :return: a list of task proxies """ return self._install_manager.collect_configure_runtime_tasks() def collect_configure_bootloader_tasks(self, kernel_versions): """Collect tasks for configuration of the bootloader. FIXME: This method temporarily uses only addons. FIXME: This is a temporary workaround. The method might change. :param kernel_versions: a list of kernel versions :return: a list of task proxies """ return self._install_manager.collect_configure_bootloader_tasks( kernel_versions) def collect_install_system_tasks(self): """Collect tasks for installation of the system. FIXME: This method temporarily uses only addons. :return: a list of task proxies """ return self._install_manager.collect_install_system_tasks() def set_locale(self, locale): """Set locale of boss and all modules. :param str locale: locale to set """ log.info("Setting locale of all modules to %s.", locale) super().set_locale(locale) self._module_manager.set_modules_locale(locale) def finish_installation_with_tasks(self): """Finish installation with tasks. :return: a list of installation tasks """ return [ SetContextsTask(conf.target.system_root), CopyLogsTask(conf.target.system_root) ]
class Boss(Service): """The Boss service.""" def __init__(self): super().__init__() self._module_manager = ModuleManager() self._kickstart_manager = KickstartManager() self._install_manager = InstallManager() self._module_manager.module_observers_changed.connect( self._kickstart_manager.on_module_observers_changed) self._module_manager.module_observers_changed.connect( self._install_manager.on_module_observers_changed) def publish(self): """Publish the boss.""" TaskContainer.set_namespace(BOSS.namespace) DBus.publish_object(BOSS.object_path, BossInterface(self)) DBus.register_service(BOSS.service_name) def start_modules_with_task(self): """Start the modules with the task.""" return self._module_manager.start_modules_with_task() def stop(self): """Stop all modules and then stop the boss.""" self._module_manager.stop_modules() super().stop() def read_kickstart_file(self, path): """Read the specified kickstart file. :param path: a path to a file :returns: a kickstart report """ log.info("Reading a kickstart file at %s.", path) return self._kickstart_manager.read_kickstart_file(path) def generate_kickstart(self): """Return a kickstart representation of modules. :return: a kickstart string """ log.info("Generating kickstart data...") return self._kickstart_manager.generate_kickstart() def install_system_with_task(self): """Install the system. :return: the main installation task """ return self._install_manager.install_system_with_task() def set_locale(self, locale): """Set locale of boss and all modules. :param str locale: locale to set """ log.info("Setting locale of all modules to %s.", locale) super().set_locale(locale) self._module_manager.set_modules_locale(locale)