Example #1
0
 def __setup_console_logger(self, *args):
     # If daemon is set force console logger to quiet
     if getattr(self.options, 'daemon', False) is False:
         # Since we're not going to be a daemon, setup the console logger
         log.setup_console_logger(self.config['log_level'],
                                  log_format=self.config['log_fmt_console'],
                                  date_format=self.config['log_datefmt'])
Example #2
0
    def _init_logger(self):
        '''
        sets up the logger used throughout saltt-eventsd
        '''
        # make sure we have the required settings for our logging
        if ('logfile' in self.gen_opts) and \
           ('loglevel' in self.gen_opts):

            setup_logfile_logger(
                self.gen_opts['logfile'],
                self.gen_opts['loglevel'],
            )

            # Only log to foreground if not running as a daemon
            if not self.gen_opts['daemonize']:
                setup_console_logger(
                    log_level=self.gen_opts['loglevel'],
                )
        else:
            # if no log settings found, use defaults

            # Only log to foreground if not running as a daemon
            if not self.gen_opts['daemonize']:
                setup_console_logger(
                    log_level="warn"
                )

            setup_logfile_logger(
                '/var/log/salt/eventsd',
                'warn',
            )
Example #3
0
 def __setup_console_logger(self, *args):
     # If daemon is set force console logger to quiet
     if hasattr(self.options, "daemon"):
         if self.options.daemon:
             self.config["log_level"] = "quiet"
     log.setup_console_logger(
         self.config["log_level"], log_format=self.config["log_fmt_console"], date_format=self.config["log_datefmt"]
     )
Example #4
0
 def __setup_console_logger(self, *args):
     # If daemon is set force console logger to quiet
     if hasattr(self.options, 'daemon'):
         if self.options.daemon:
             self.config['log_level'] = 'quiet'
     log.setup_console_logger(self.config['log_level'],
                              log_format=self.config['log_fmt_console'],
                              date_format=self.config['log_datefmt'])
Example #5
0
 def __setup_console_logger(self, *args):
     # If daemon is set force console logger to quiet
     if getattr(self.options, 'daemon', False) is False:
         # Since we're not going to be a daemon, setup the console logger
         log.setup_console_logger(
             self.config['log_level'],
             log_format=self.config['log_fmt_console'],
             date_format=self.config['log_datefmt']
         )
Example #6
0
 def __setup_console_logger(self, *args):
     # If daemon is set force console logger to quiet
     if hasattr(self.options, 'daemon'):
         if self.options.daemon:
             self.config['log_level'] = 'quiet'
     log.setup_console_logger(
         self.config['log_level'],
         log_format=self.config['log_fmt_console'],
         date_format=self.config['log_datefmt']
     )
Example #7
0
    # Attempt to import msgpack
    import msgpack
    # There is a serialization issue on ARM and potentially other platforms
    # for some msgpack bindings, check for it
    if msgpack.loads(msgpack.dumps([1, 2, 3]), use_list=True) is None:
        raise ImportError
    available = True
except ImportError:
    # Fall back to msgpack_pure
    try:
        import msgpack_pure as msgpack  # pylint: disable=import-error
    except ImportError:
        # TODO: Come up with a sane way to get a configured logfile
        #       and write to the logfile when this error is hit also
        LOG_FORMAT = '[%(levelname)-8s] %(message)s'
        setup_console_logger(log_format=LOG_FORMAT)
        log.fatal('Unable to import msgpack or msgpack_pure python modules')
        # Don't exit if msgpack is not available, this is to make local mode
        # work without msgpack
        #sys.exit(salt.defaults.exitcodes.EX_GENERIC)
        available = False


if not available:

    def _fail():
        raise RuntimeError('msgpack is not available')

    def _serialize(obj, **options):
        _fail()
Example #8
0
    # Attempt to import msgpack
    import msgpack
    # There is a serialization issue on ARM and potentially other platforms
    # for some msgpack bindings, check for it
    if msgpack.loads(msgpack.dumps([1, 2, 3]), use_list=True) is None:
        raise ImportError
    available = True
except ImportError:
    # Fall back to msgpack_pure
    try:
        import msgpack_pure as msgpack  # pylint: disable=import-error
    except ImportError:
        # TODO: Come up with a sane way to get a configured logfile
        #       and write to the logfile when this error is hit also
        LOG_FORMAT = '[%(levelname)-8s] %(message)s'
        setup_console_logger(log_format=LOG_FORMAT)
        log.fatal('Unable to import msgpack or msgpack_pure python modules')
        # Don't exit if msgpack is not available, this is to make local mode
        # work without msgpack
        #sys.exit(salt.defaults.exitcodes.EX_GENERIC)
        available = False


if not available:

    def _fail():
        raise RuntimeError('msgpack is not available')

    def _serialize(obj, **options):
        _fail()
    def accept(self, minion, key):
        return self.auth_service.accept(minion, key)


#    def auto_sign()...
#    def auto_reject()...
#    def pre()...
#    etc.

#
# Sample interaction with the KeyService
#
if __name__ == '__main__':

    setup_console_logger(log_level='debug')

    log.info('Sample interaction with FileKeyService...')

    ks = KeyserviceMixin()
    log.info('Listing minions...')

    for state, minions in sorted(ks.minions().iteritems()):
        log.info('\t{0}: {1}'.format(state, minions))

    log.info('\n\n')
    log.info('Sample interaction with RedisKeyService...')

    # Define options to work with redis
    opts = {
        'redis_server': 'localhost',