Example #1
0
    def publish(self, object_path):
        """Publish the object on DBus.

        :type object_path: a DBus path of the object
        """
        DBus.publish_object(self, object_path)
        self._object_path = object_path
Example #2
0
    def publish(self):
        """Publish the module."""
        for kickstart_module in self._modules:
            kickstart_module.publish()

        DBus.publish_object(STORAGE.object_path, StorageInterface(self))
        DBus.register_service(STORAGE.service_name)
Example #3
0
    def publish_handler(self):
        """Publish the handler."""
        self._packages_handler.publish()

        DBus.publish_object(PAYLOAD_DEFAULT.object_path,
                            DNFHandlerInterface(self))
        return PAYLOAD_DEFAULT.object_path
Example #4
0
    def publish(self):
        """Publish the module."""
        TaskContainer.set_namespace(NETWORK.namespace)
        self._firewall_module.publish()

        DBus.publish_object(NETWORK.object_path, NetworkInterface(self))
        DBus.register_service(NETWORK.service_name)
Example #5
0
    def unpublish(self):
        """Unpublish DBus objects and unregister a DBus service.

        Everything is unpublished by default.
        """
        DBus.unregister_all()
        DBus.unpublish_all()
Example #6
0
    def publish(self):
        """Publish the module."""
        for kickstart_module in self._modules:
            kickstart_module.publish()

        DBus.publish_object(STORAGE.object_path, StorageInterface(self))
        DBus.register_service(STORAGE.service_name)
Example #7
0
    def publish(self, module_path):
        """Publish task on DBus.

        Every new created interface instance will get new number used as a last part of the
        DBus object path to avoid conflict.

        :param module_path: DBus object path to the module.
        :type module_path: str
        """
        self._dbus_path = "{}/Tasks/{}".format(module_path, self._task_number)
        DBus.publish_object(self, self._dbus_path)
Example #8
0
    def publish(self):
        """Publish the module."""
        # Publish bar.
        DBus.publish_object(BAR.object_path, BarInterface(self))
        self.publish_task(BAR.namespace, BarTask())
        DBus.register_service(BAR.service_name)

        # Start to watch the timezone module.
        self._timezone_module.cached_properties_changed.connect(
            self._timezone_callback)
        self._timezone_module.connect_once_available()
Example #9
0
    def publish(self):
        """Publish the module."""
        # Publish bar.
        DBus.publish_object(BarInterface(self), MODULE_BAR_PATH)
        self.publish_task(BarTask(), MODULE_BAR_PATH)
        DBus.register_service(MODULE_BAR_NAME)

        # Start to watch the timezone module.
        self._timezone_module.cached_properties_changed.connect(
            self._timezone_callback)
        self._timezone_module.connect_once_available()
Example #10
0
    def _collect_tasks(self):
        self._tasks.clear()

        if not self._modules:
            log.error("Starting installation without available modules.")

        for module_service in self._modules:
            # FIXME: This is just a temporary solution.
            module_object = DBus.get_proxy(module_service, auto_object_path(module_service))

            tasks = module_object.AvailableTasks()
            for task in tasks:
                log.debug("Getting task %s from module %s", task[TASK_NAME], module_service)
                task_proxy = DBus.get_proxy(module_service, task[TASK_PATH])
                self._tasks.add(task_proxy)
Example #11
0
    def add_addon_modules(self):
        """Add the addon modules."""
        dbus = DBus.get_dbus_proxy()
        names = dbus.ListActivatableNames()
        prefix = get_dbus_name(*ADDONS_NAMESPACE)

        for service_name in names:
            if service_name.startswith(prefix):
                # Get the object path.
                namespace = get_namespace_from_name(service_name)
                object_path = get_dbus_path(*namespace)

                # Add the observer.
                observer = DBus.get_observer(service_name, object_path)
                self._module_observers.append(observer)
Example #12
0
    def _collect_installation_tasks(self):
        """Collect installation tasks from modules.

        :return: a list of tasks proxies
        """
        tasks = []

        if not self._module_observers:
            log.error("Starting installation without available modules.")

        for observer in self._module_observers:
            # FIXME: This check is here for testing purposes only.
            # Normally, all given modules should be available once
            # we start the installation.
            if not observer.is_service_available:
                log.error("Module %s is not available!", observer.service_name)
                continue

            service_name = observer.service_name
            task_paths = observer.proxy.InstallWithTasks()

            for object_path in task_paths:
                log.debug("Getting task %s from module %s", object_path,
                          service_name)
                task_proxy = DBus.get_proxy(service_name, object_path)
                tasks.append(task_proxy)

        return tasks
Example #13
0
    def _collect_installation_tasks(self):
        """Collect installation tasks from modules.

        :return: a list of tasks proxies
        """
        tasks = []

        if not self._module_observers:
            log.error("Starting installation without available modules.")

        for observer in self._module_observers:
            # FIXME: This check is here for testing purposes only.
            # Normally, all given modules should be available once
            # we start the installation.
            if not observer.is_service_available:
                log.error("Module %s is not available!", observer.service_name)
                continue

            service_name = observer.service_name
            task_paths = observer.proxy.InstallWithTasks()

            for object_path in task_paths:
                log.debug("Getting task %s from module %s", object_path, service_name)
                task_proxy = DBus.get_proxy(service_name, object_path)
                tasks.append(task_proxy)

        return tasks
Example #14
0
 def find_addons(self):
     self._addon_module_services = []
     dbus = DBus.get_dbus_proxy()
     names = dbus.ListActivatableNames()
     for name in names:
         if name.startswith(DBUS_ADDON_NAMESPACE):
             self._addon_module_services.append(name)
Example #15
0
def distribute_kickstart_with_boss(kickstart_path):
    boss = DBus.get_proxy(DBUS_BOSS_NAME, DBUS_BOSS_PATH)
    try:
        boss.SplitKickstart(kickstart_path)
    except SplitKickstartError as e:
        log.error("Boss.SplitKickstart(%s) exception: %s", kickstart_path, e)
        return False

    log.info("Boss.SplitKickstart(%s):\n%s", kickstart_path,
             boss.UnprocessedKickstart)

    timeout = 10
    while not boss.AllModulesAvailable and timeout > 0:
        log.info("Waiting %d sec for modules to be started", timeout)
        time.sleep(1)
        timeout = timeout - 1
    if not timeout:
        log.warning("Waiting for modules to be started timed out")
        return False

    errors = boss.DistributeKickstart()
    if errors:
        log.error("Boss.DistributeKickstart() errors: %s", errors)
    unprocessed_kickstart = boss.UnprocessedKickstart
    log.info("Boss.DistributeKickstart() unprocessed part:\n%s",
             unprocessed_kickstart)
    return True
Example #16
0
    def _publish_user_instance(self, user_instance):
        """Publish the user instance on DBus.

        :param user_instance: an instance of UserModule
        """
        # Publish the DBus object.
        publishable = UserInterface(user_instance)
        object_path = UserInterface.get_object_path(USERS.namespace)
        DBus.publish_object(object_path, publishable)

        # Update the module.
        self.users[object_path] = user_instance
        self.users_changed.emit()

        log.debug("Published a user at '%s'.", object_path)
        return object_path
Example #17
0
    def _publish_user_instance(self, user_instance):
        """Publish the user instance on DBus.

        :param user_instance: an instance of UserModule
        """
        # Publish the DBus object.
        publishable = UserInterface(user_instance)
        object_path = UserInterface.get_object_path(USERS.namespace)
        DBus.publish_object(object_path, publishable)

        # Update the module.
        self.users[object_path] = user_instance
        self.users_changed.emit()

        log.debug("Published a user at '%s'.", object_path)
        return object_path
Example #18
0
    def add_addon_modules(self):
        """Add the addon modules."""
        dbus = DBus.get_dbus_proxy()
        names = dbus.ListActivatableNames()

        for name in names:
            if name.startswith(DBUS_ADDON_NAMESPACE):
                self.add_module(name, auto_object_path(name))
Example #19
0
    def _watch(self):
        """Watch the service name on DBus."""
        bus = DBus.get_connection()
        num = bus.watch_name(self.service_name, DBUS_FLAG_NONE,
                             self._service_name_appeared_callback,
                             self._service_name_vanished_callback)

        self._watched_id = num
Example #20
0
    def add_addon_modules(self):
        """Add the addon modules."""
        dbus = DBus.get_dbus_proxy()
        names = dbus.ListActivatableNames()
        prefix = get_dbus_name(*ADDONS_NAMESPACE)

        for service_name in names:
            if service_name.startswith(prefix):
                self.add_module(service_name)
Example #21
0
    def add_module(self, service_name):
        """Add a modules with the given service name."""
        # Get the object path.
        namespace = get_namespace_from_name(service_name)
        object_path = get_dbus_path(*namespace)

        # Add the observer.
        observer = DBus.get_observer(service_name, object_path)
        self._module_observers.append(observer)
Example #22
0
    def proxy(self):
        """"Returns a proxy of the remote object."""
        if not self._is_service_available:
            raise DBusObserverError("Service {} is not available.".format(
                self._service_name))

        if not self._proxy:
            self._proxy = DBus.get_proxy(self._service_name, self._object_path)

        return self._proxy
Example #23
0
    def get_proxy(self, object_path):
        """"Returns a proxy of the remote object."""
        if not self._is_service_available:
            raise DBusObserverError("Service {} is not available.".format(
                self._service_name))

        if object_path in self._proxies:
            return self._proxies.get(object_path)

        proxy = DBus.get_proxy(self._service_name, object_path)
        self._proxies[object_path] = proxy
        return proxy
Example #24
0
 def publish(self):
     """Publish the boss."""
     DBus.publish_object(BOSS.object_path,
                         AnacondaBossInterface(self))
     DBus.publish_object(BOSS_INSTALLATION.object_path,
                         InstallationInterface(self._install_manager))
     DBus.register_service(BOSS.service_name)
Example #25
0
    def connect(self):
        """Connect to the service immediately.

        :raise DBusObserverError: if service is not available
        """
        bus_proxy = DBus.get_dbus_proxy()

        if not bus_proxy.NameHasOwner(self.service_name):
            raise DBusObserverError("Service {} is not available.".format(
                self._service_name))

        self._enable_service()
        self._watch()
Example #26
0
 def stop_modules(self):
     """Tells all running modules to quit."""
     log.debug("sending Quit to all modules and addons")
     for service in self.running_module_services:
         # FIXME: This is just a temporary solution.
         module = DBus.get_proxy(service, auto_object_path(service))
         # TODO: async ?
         # possible reasons:
         # - module hanging in Quit, deadlocking shutdown
         try:
             module.Quit()
         except Exception:  # pylint: disable=broad-except
             log.exception("Quit failed for module: %s", service)
Example #27
0
def run_boss(kickstart_modules=None, addons_enabled=True):
    """Start Boss service on DBus.

    :param kickstart_modules: a list of service identifiers
    :param addons_enabled: should we start the addons?
    """
    if kickstart_modules is None:
        kickstart_modules = ALL_KICKSTART_MODULES

    bus_proxy = DBus.get_dbus_proxy()
    bus_proxy.StartServiceByName(BOSS.service_name, DBUS_FLAG_NONE)

    boss_proxy = BOSS.get_proxy()
    boss_proxy.StartModules([m.service_name for m in kickstart_modules], addons_enabled)
Example #28
0
 def check_modules_started(self):
     if self.modules_starting_finished:
         log.debug("modules starting finished, running: %s failed: %s",
                   self._started_module_services,
                   self._failed_module_services)
         for service in self._started_module_services:
             # FIXME: This is just a temporary solution.
             module = DBus.get_proxy(service, auto_object_path(service))
             module.EchoString(
                 "Boss told me - some modules were started: %s and some might have failed: %s."
                 % (self._started_module_services,
                    self._failed_module_services))
         return True
     else:
         return False
Example #29
0
    def start_modules(self):
        """Start anaconda modules (including addons)."""
        log.debug("Start modules.")
        dbus = DBus.get_dbus_proxy()

        for observer in self.module_observers:
            log.debug("Starting %s", observer)
            dbus.StartServiceByName(observer.service_name,
                                    DBUS_FLAG_NONE,
                                    callback=self._start_modules_callback,
                                    callback_args=(observer,))

            # Watch the module.
            observer.service_available.connect(self._process_module_is_available)
            observer.service_unavailable.connect(self._process_module_is_unavailable)
            observer.connect_once_available()
Example #30
0
    def start_modules(self):
        """Starts anaconda modules (including addons)."""
        log.debug("starting modules")
        self.check_no_modules_are_running()

        dbus = DBus.get_dbus_proxy()
        for service in self.expected_module_services:
            log.debug("Starting %s", service)
            try:
                dbus.StartServiceByName(service,
                                        0,
                                        callback=self._finish_start_service_cb,
                                        callback_args=(service, ))
            except Exception:  # pylint: disable=broad-except
                self._failed_module_services.append(service)
                log.exception("module startup failed")

        log.debug("started all modules")
Example #31
0
    def _collect_tasks(self):
        self._tasks.clear()

        if not self._module_observers:
            log.error("Starting installation without available modules.")

        for observer in self._module_observers:
            # FIXME: This check is here for testing purposes only.
            # Normally, all given modules should be available once
            # we start the installation.
            if not observer.is_service_available:
                log.error("Module %s is not available!", observer.service_name)
                continue

            tasks = observer.proxy.AvailableTasks
            for task in tasks:
                log.debug("Getting task %s from module %s", task[TASK_NAME], observer.service_name)
                task_proxy = DBus.get_proxy(observer.service_name, task[TASK_PATH])
                self._tasks.add(task_proxy)
Example #32
0
 def publish(self):
     """Publish the module."""
     DBus.publish_object(BOOTLOADER.object_path, BootloaderInterface(self))
Example #33
0
 def publish(self):
     """Publish the module."""
     DBus.publish_object(LOCALIZATION.object_path, LocalizationInterface(self))
     DBus.register_service(LOCALIZATION.service_name)
Example #34
0
 def publish(self):
     """Publish the module."""
     DBus.publish_object(DEVICE_TREE.object_path, DeviceTreeInterface(self))
Example #35
0
 def stop(self):
     """Stop the module's loop."""
     DBus.disconnect()
     Timer().timeout_sec(1, self.loop.quit)
Example #36
0
    def publish(self):
        """Publish the module."""
        self._packages_handler.publish()

        DBus.publish_object(PAYLOAD_DEFAULT.object_path, DNFHandlerInterface(self))
Example #37
0
    def publish(self):
        """Publish the module."""
        self._firewall_module.publish()

        DBus.publish_object(NETWORK.object_path, NetworkInterface(self))
        DBus.register_service(NETWORK.service_name)
Example #38
0
 def publish(self):
     """Publish the module."""
     DBus.publish_object(TIMEZONE.object_path, TimezoneInterface(self))
     DBus.register_service(TIMEZONE.service_name)
Example #39
0
 def publish(self):
     """Publish the module."""
     DBus.publish_object(SECURITY.object_path, SecurityInterface(self))
     DBus.register_service(SECURITY.service_name)
Example #40
0
 def publish(self):
     """Publish the module."""
     DBus.publish_object(AUTO_PARTITIONING.object_path, AutoPartitioningInterface(self))
Example #41
0
 def publish(self):
     """Publish the module."""
     DBus.publish_object(SNAPSHOT.object_path, SnapshotInterface(self))
Example #42
0
 def publish(self):
     """Publish the module."""
     DBus.publish_object(PAYLOAD.object_path, PayloadInterface(self))
     DBus.register_service(PAYLOAD.service_name)
Example #43
0
 def publish(self):
     """Publish the module."""
     DBus.publish_object(USERS.object_path, UsersInterface(self))
     DBus.register_service(USERS.service_name)
Example #44
0
 def publish(self):
     """Publish the module."""
     DBus.publish_object(BAZ.object_path, BazInterface(self))
     DBus.register_service(BAZ.service_name)
Example #45
0
 def publish(self):
     """Publish the module."""
     DBus.publish_object(DISK_INITIALIZATION.object_path,
                         DiskInitializationInterface(self))
Example #46
0
 def publish(self):
     """Publish the module."""
     DBus.publish_object(DASD.object_path, DASDInterface(self))
Example #47
0
 def publish(self):
     """Publish the module."""
     DBus.publish_object(NVDIMM.object_path, NVDIMMInterface(self))
Example #48
0
 def publish(self):
     """Publish the module."""
     DBus.publish_object(ZFCP.object_path, ZFCPInterface(self))
Example #49
0
 def stop(self):
     """Stop the module's loop."""
     DBus.disconnect()
     Timer().timeout_sec(1, self.loop.quit)
Example #50
0
 def publish(self):
     """Publish the module."""
     DBus.publish_object(FCOE.object_path, FCOEInterface(self))
Example #51
0
    def publish(self):
        """Publish the boss."""
        DBus.publish_object(BOSS.object_path,
                            AnacondaBossInterface(self))

        DBus.register_service(BOSS.service_name)
Example #52
0
 def publish(self):
     """Publish the module."""
     DBus.publish_object(DISK_SELECTION.object_path, DiskSelectionInterface(self))
Example #53
0
 def publish(self):
     """Publish the module."""
     DBus.publish_object(DNF_PACKAGES.object_path, PackagesHandlerInterface(self))
Example #54
0
 def publish(self):
     """Publish the module."""
     DBus.publish_object(
         MANUAL_PARTITIONING.object_path,
         ManualPartitioningInterface(self)
     )
Example #55
0
 def publish(self):
     """Publish the module."""
     DBus.publish_object(NETWORK.object_path, NetworkInterface(self))
     DBus.register_service(NETWORK.service_name)
Example #56
0
 def publish(self):
     """Publish the module."""
     DBus.publish_object(FIREWALL.object_path, FirewallInterface(self))