def __init__(self, config, logger, alerts_storage, config_data, filter_storage, context_graph, watcher, event_publisher): self.config = config self.logger = logger self.alerts_storage = alerts_storage self.config_data = config_data self.filter_storage = filter_storage self.context_manager = context_graph self.watcher_manager = watcher self.event_publisher = event_publisher alerts_ = self.config.get(self.ALERTS_CAT, {}) self.extra_fields = cfg_to_array( alerts_.get('extra_fields', DEFAULT_EXTRA_FIELDS)) self.record_last_event_date = cfg_to_bool( alerts_.get('record_last_event_date', DEFAULT_RECORD_LAST_EVENT_DATE)) self.update_longoutput_fields = alerts_.get("update_long_output", False) filter_ = self.config.get(self.FILTER_CAT, {}) self.filter_author = filter_.get('author', DEFAULT_AUTHOR) self.lock_manager = AlertLockRedis( *AlertLockRedis.provide_default_basics())
def __init__(self, config, logger, amqp_pub): self.config = config self.logger = logger self.amqp_pub = amqp_pub server = self.config.get('server', {}) self.debug = server.get('debug', DEFAULT_DEBUG) self.enable_crossdomain_send_events = server.get( 'enable_crossdomain_send_events', DEFAULT_ECSE) self.root_directory = os.path.expanduser( server.get('root_directory', DEFAULT_ROOT_DIR)) auth = self.config.get('auth', {}) self.providers = cfg_to_array(auth.get('providers', '')) if len(self.providers) == 0: self.logger.critical( 'Missing providers. Cannot launch webcore module.') raise RuntimeError('Missing providers') session = self.config.get('session', {}) self.cookie_expires = int(session.get('cookie_expires', DEFAULT_COOKIES_EXPIRE)) self.secret = session.get('secret', DEFAULT_SECRET) self.data_dir = session.get('data_dir', DEFAULT_DATA_DIR) self.webservices = self.config.get('webservices', {}) # TODO: Replace with MongoStorage self.db = get_storage(account=Account(user='******', group='root')) self.stopping = False self.webmodules = {} self.auth_backends = {}
def __init__( self, config, logger, alerts_storage, config_data, filter_storage, context_graph, watcher, event_publisher ): self.config = config self.logger = logger self.alerts_storage = alerts_storage self.config_data = config_data self.filter_storage = filter_storage self.context_manager = context_graph self.watcher_manager = watcher self.event_publisher = event_publisher alerts_ = self.config.get(self.ALERTS_CAT, {}) self.extra_fields = cfg_to_array(alerts_.get('extra_fields', DEFAULT_EXTRA_FIELDS)) self.record_last_event_date = cfg_to_bool(alerts_.get('record_last_event_date', DEFAULT_RECORD_LAST_EVENT_DATE)) self.update_longoutput_fields = alerts_.get("update_long_output", False) filter_ = self.config.get(self.FILTER_CAT, {}) self.filter_author = filter_.get('author', DEFAULT_AUTHOR) self.lock_manager = AlertLockRedis(*AlertLockRedis.provide_default_basics())
def __init__(self, *args, **kwargs): super(engine, self).__init__(*args, **kwargs) self.context_manager = ContextGraph(self.logger) self.influxdb_client = InfluxDBClient.from_configuration(self.logger) cfg = Configuration.load(os.path.join(root_path, self.CONF_PATH), Ini).get(self.CONF_SECTION, {}) self.tags = cfg_to_array(cfg.get('tags', ''))
def __init__(self, *args, **kwargs): super(engine, self).__init__(*args, **kwargs) self.context_manager = ContextGraph(self.logger) self.influxdb_client = InfluxDBClient.from_configuration(self.logger) cfg = Configuration.load( os.path.join(root_path, self.CONF_PATH), Ini ).get(self.CONF_SECTION, {}) self.tags = cfg_to_array(cfg.get('tags', ''))
def test_cfg_to_array(self): fd, conf_file = tempfile.mkstemp() content = """[SECTION] key = un, tableau, separe, par,des,virgules""" with open(conf_file, 'w') as f: f.write(content) self.config = Configuration.load(conf_file, Ini) r = cfg_to_array(self.config['SECTION']['key']) self.assertTrue(isinstance(r, list)) self.assertEqual(len(r), 6) self.assertEqual(r[3], 'par')
def __init__(self, config=None, check_storage=None, *args, **kwargs): super(CheckManager, self).__init__(*args, **kwargs) if config is None: self.config = Configuration.load(CONF_PATH, Ini) else: self.config = config self.config_check = self.config.get(CONF_CATEGORY, {}) self.types = cfg_to_array(self.config_check.get('types', DEFAULT_TYPES)) if check_storage is None: self.check_storage = Middleware.get_middleware_by_uri( self.config_check.get('check_storage_uri', DEFAULT_CHECK_STORAGE_URI) ) else: self.check_storage = check_storage
def __init__(self, config=None, check_storage=None, *args, **kwargs): super(CheckManager, self).__init__(*args, **kwargs) if config is None: self.config = Configuration.load(CONF_PATH, Ini) else: self.config = config self.config_check = self.config.get(CONF_CATEGORY, {}) self.types = cfg_to_array(self.config_check.get( 'types', DEFAULT_TYPES)) if check_storage is None: self.check_storage = Middleware.get_middleware_by_uri( self.config_check.get('check_storage_uri', DEFAULT_CHECK_STORAGE_URI)) else: self.check_storage = check_storage