def _get_config(static=False, yml_config=None): from assemblyline.odm.models.config import Config if yml_config is None: yml_config = "/etc/assemblyline/config.yml" # Initialize a default config config = Config().as_primitives() # Load modifiers from the yaml config if os.path.exists(yml_config): with open(yml_config) as yml_fh: yml_data = yaml.safe_load(_env_substitute(yml_fh.read())) if yml_data: config = recursive_update(config, yml_data) if not static: # TODO: Load a datastore object and load the config changes from the datastore # config.update(datastore_changes) pass if 'AL_LOG_LEVEL' in os.environ: config['logging']['log_level'] = os.environ['AL_LOG_LEVEL'] return Config(config)
def scheduler(redis): config = Config(DEFAULT_CONFIG) config.services.stages = ['pre', 'core', 'post'] stages = get_service_stage_hash(redis) ds = FakeDatastore() for service in ds.list_all_services(): stages.set(service.name, ServiceStage.Running) return Scheduler(ds, config, redis)
def _get_config(yml_config=None): from assemblyline.odm.models.config import Config if yml_config is None: yml_config = "/etc/assemblyline/config.yml" # Initialize a default config config = Config().as_primitives() # Load modifiers from the yaml config if os.path.exists(yml_config): with open(yml_config) as yml_fh: yml_data = yaml.safe_load(env_substitute(yml_fh.read())) if yml_data: config = recursive_update(config, yml_data) if 'AL_LOG_LEVEL' in os.environ: config['logging']['log_level'] = os.environ['AL_LOG_LEVEL'] return Config(config)
def test_default_config_model(): config = forge.get_config(yml_config="/etc/assemblyline/default.yml") assert config.as_primitives() == Config(DEFAULT_CONFIG).as_primitives()