Exemple #1
0
    def activate(self, conffile=None):
        self.logger = logging.getLogger()

        if self.is_activated:
            self.logger.info("Glpi don't need activation")
            return None

        self.config = GlpiConfig("glpi", conffile)

        # we choose the good backend for the database
        if Glpi07().try_activation(self.config):
            self.database = Glpi07()
        elif Glpi08().try_activation(self.config):
            self.database = Glpi08()
        elif Glpi084().try_activation(self.config):
            self.database = Glpi084()
        elif Glpi0855().try_activation(self.config):
            self.database = Glpi0855()
        elif Glpi090().try_activation(self.config):
            self.database = Glpi090()
        elif Glpi91().try_activation(self.config):
            self.database = Glpi91()
        elif Glpi92().try_activation(self.config):
            self.database = Glpi92()
        elif Glpi93().try_activation(self.config):
            self.database = Glpi93()
        elif Glpi94().try_activation(self.config):
            self.database = Glpi94()
        else:
            self.logger.warn(
                "Can't load the right database backend for your version of GLPI"
            )
            return False

        # activate the backend
        ret = self.database.activate(self.config)
        self.is_activated = self.database.is_activated
        # Register the panel to the DashboardManager
        try:
            logging.getLogger().debug('Try to load glpi panels')
            from mmc.plugins.dashboard.manager import DashboardManager
            from mmc.plugins.dashboard.panel import Panel
            DM = DashboardManager()
            DM.register_panel(Panel("inventory"))
            if self.database.fusionantivirus is not None:
                DM.register_panel(Panel("antivirus"))
            # Registring OS Repartition panel
            DM.register_panel(Panel("os_repartition"))
        except ImportError:
            logging.getLogger().debug('Failed to load glpi panels')

        return ret
Exemple #2
0
def activate():
    config = updateConfig("update")
    if config.disabled:
        logger.warning("Plugin UpdateMgr: disabled by configuration.")
        return False
    if not updateDatabase().activate(config):
        logger.error("UpdateMgr database not activated")
        return False

    DashboardManager().register_panel(Panel('product_updates'))
    DashboardManager().register_panel(Panel('clients_updates'))

    # Add create update commands in the task manager
    if config.enable_update_commands:
        TaskManager().addTask("update.create_update_commands",
                              (create_update_commands, ),
                              cron_expression=config.update_commands_cron)
    if config.enable_update_description:
        TaskManager().addTask(
            "add_update_description", (add_update_description, ),
            cron_expression=config.add_update_description_cron)
    return True
Exemple #3
0
def activate():
    logger = logging.getLogger()
    logger.debug("Pkgs is activating")
    config = PkgsConfig("pkgs")
    if config.disabled:
        logger.warning("Plugin pkgs: disabled by configuration.")
        return False

    DashboardManager().register_panel(Panel('appstream'))

    TaskManager().addTask("pkgs.updateAppstreamPackages",
                          (updateAppstreamPackages, ),
                          cron_expression='23 10 * * *')
    return True