Пример #1
1
 def geturl(self):
     """
     Get the broker URL
     @return: The broker URL
     @rtype: str
     """
     main = Config()
     cfg = self.cfg()
     return nvl(cfg.messaging.url,
            nvl(main.messaging.url))
Пример #2
0
 def __init__(self, plugins):
     """
     @param plugins: A list of loaded plugins
     @type plugins: list
     """
     self.plugins = plugins
     PAM.SERVICE = nvl(cfg.pam.service, PAM.SERVICE)
Пример #3
0
 def getbroker(self):
     """
     Get the amqp broker for this plugin.  Each plugin can
     connect to a different broker.
     @return: The broker if configured.
     @rtype: L{Broker}
     """
     cfg = self.cfg()
     main = Config()
     broker = Broker(self.geturl())
     broker.cacert = \
         nvl(cfg.messaging.cacert,
         nvl(main.messaging.cacert))
     broker.clientcert = \
         nvl(cfg.messaging.clientcert,
         nvl(main.messaging.clientcert))
     log.info('broker (qpid) configured: %s', broker)
     return broker
Пример #4
0
 def enabled(self):
     """
     Get whether the plugin is enabled.
     @return: True if enabled.
     @rtype: bool
     """
     cfg = self.cfg()
     try:
         return int(nvl(cfg.main.enabled, 0))
     except:
         return 0
Пример #5
0
 def __requires(self):
     """
     Get the list of declared required plugins.
     @return: A list of plugin names.
     @rtype: list
     """
     required = []
     declared = nvl(self.main.requires)
     if declared:
         plugins =  declared.split(',')
         required = [s.strip() for s in plugins]
     return tuple(required)
Пример #6
0
 def getuuid(self):
     """
     Get the plugin's messaging UUID.
     @return: The plugin's messaging UUID.
     @rtype: str
     """
     self.__lock()
     try:
         cfg = self.cfg()
         return nvl(cfg.messaging.uuid)
     finally:
         self.__unlock()
Пример #7
0
def setupLogging():
    """
    Set logging levels based on configuration.
    """
    for p in nvl(cfg.logging, []):
        level = cfg.logging[p]
        if not level:
            continue
        try:
            L = getattr(logging, level.upper())
            logger = logging.getLogger(p)
            logger.setLevel(L)
        except:
            pass
Пример #8
0
def eager():
    return int(nvl(cfg.loader.eager, 0))
Пример #9
-1
 def nthreads(self):
     """
     Get the number of theads in the plugin's pool.
     @return: number of theads.
     @rtype: int
     """
     main = Config()
     cfg = self.cfg()
     value = \
         nvl(cfg.messaging.threads,
         nvl(main.messaging.threads, 1))
     value = int(value)
     assert(value >= 1)
     return value