Esempio n. 1
0
    def _getQueryablePlugins(self):
        """
        Check in existing plugins which one support the query manager
        """
        from mmc.agent import PluginManager
        pm = PluginManager()
        ret = {}

        for plugin in pm.getEnabledPluginNames():
            if os.path.exists(os.path.join('plugins/', plugin, 'querymanager', '__init__.py')):
                self.logger.debug("QueryManager is trying to load plugin "+plugin)
                f, p, d = imp.find_module('querymanager', [os.path.join('plugins/', plugin)])
                try:
                    mod = imp.load_module(plugin+'_querymanager', f, p, d)
                    func = getattr(mod, 'activate')
                    if func():
                        ret[plugin] = mod
                        self.logger.info('QueryManager plugin ' + plugin + ' loaded')
                    else:
                        self.logger.info('QueryManager plugin '+ plugin+ ' is disabled by configuration.')

                except Exception,e:
                    self.logger.exception(e)
                    self.logger.error('QueryManager plugin '+ plugin+ " raise an exception.\n"+ plugin+ " not loaded.")
                    continue
Esempio n. 2
0
    def _getQueryablePlugins(self):
        """
        Check in existing plugins which one support the query manager
        """
        from mmc.agent import PluginManager
        pm = PluginManager()
        ret = {}

        for plugin in pm.getEnabledPluginNames():
            if os.path.exists(os.path.join('plugins/', plugin, 'querymanager', '__init__.py')):
                self.logger.debug("QueryManager is trying to load plugin "+plugin)
                f, p, d = imp.find_module('querymanager', [os.path.join('plugins/', plugin)])
                try:
                    mod = imp.load_module(plugin+'_querymanager', f, p, d)
                    func = getattr(mod, 'activate')
                    if func():
                        ret[plugin] = mod
                        self.logger.info('QueryManager plugin ' + plugin + ' loaded')
                    else:
                        self.logger.info('QueryManager plugin '+ plugin+ ' is disabled by configuration.')

                except Exception,e:
                    self.logger.exception(e)
                    self.logger.error('QueryManager plugin '+ plugin+ " raise an exception.\n"+ plugin+ " not loaded.")
                    continue
Esempio n. 3
0
def switchInventoryModule(module_name):
    """
    Activate the new Inventory method and deactivate the other.
    Returns a tuple: True or False and an error message
    describing the reason why it failed.
    """
    pm = PluginManager()
    pm.startPlugin(module_name)
    if module_name == 'inventory':
        pm.stopPlugin('glpi')
    else:
        pm.stopPlugin('inventory')
    return (True, )
def action(xmppobject, action, sessionid, data, message, ret, dataobj):
    logger.debug("=====================================================")
    logger.debug(plugin)
    logger.debug("=====================================================")
    datasend = {
        'action': 'resultenablemmcmodul',
        'sessionid': sessionid,
        'data': PluginManager().getAvailablePlugins()
    }
    xmppobject.send_message(mto=message['from'],
                            mbody=json.dumps(datasend),
                            mtype='chat')
Esempio n. 5
0
def activate_2():
    """
    Check that the MMC pulse2 plugin is enabled
    """
    if not PluginManager().isEnabled('pulse2'):
        ret = False
        logging.getLogger().error(
            "Plugin imaging: plugin is disabled because the pulse2 plugin is not available"
        )
    else:
        ret = True
    return ret
Esempio n. 6
0
def switchInventoryModule(module_name):
    """
    Activate the new Inventory method and deactivate the other.
    Returns a tuple: True or False and an error message
    describing the reason why it failed.
    """
    pm = PluginManager()
    pm.startPlugin(module_name)
    if module_name == 'inventory':
        pm.stopPlugin('glpi')
    else:
        pm.stopPlugin('inventory')
    return (True,)
Esempio n. 7
0
 def list_plugins_services(self):
     """
     Returns list of services ordered by MMC plugins
     """
     list = {}
     plugins = PluginManager().getEnabledPluginNames()
     for plugin in plugins:
         for plugin_services, services in self.config.services.items():
             if plugin == plugin_services and services:
                 list[plugin] = []
                 for service in services:
                     if service not in self.config.blacklist:
                         list[plugin].append(self.get_unit_info(service))
                 list[plugin] = sorted(list[plugin],
                                       key=lambda s: s['id'].lower())
     return list
Esempio n. 8
0
 def areProfilesPossible(self):
     """
     profiles are possible only if the imaging plugin is enable
     """
     # maybe we can add something in the configuration of dyngroup to say if we want or not profiles
     return PluginManager().isEnabled("imaging")