def _load_value_configurations(self): valid_datasources_conf = {} erroneous_datasources_conf = [] files = file_utils.list_files( self.conf.entity_graph.datasources_values_dir, '.yaml') for file_name in files: try: full_path = self.conf.entity_graph.datasources_values_dir \ + '/' + file_name operational_values, priority_values = \ self._retrieve_values_and_priorities_from_file(full_path) valid_datasources_conf[os.path.splitext(file_name)[0]] = { self.OPERATIONAL_VALUES: operational_values, self.PRIORITY_VALUES: priority_values } except Exception: datasource = os.path.splitext(file_name)[0] erroneous_datasources_conf.append(datasource) LOG.exception('Erroneous data source is %s', datasource) self._check_value_confs_exists( [key for key in valid_datasources_conf.keys()], erroneous_datasources_conf) return valid_datasources_conf
def _load_state_configurations(self): valid_datasources_conf = {} erroneous_datasources_conf = [] files = file_utils.list_files( self.conf.entity_graph.datasources_values_dir, '.yaml') for file_name in files: try: full_path = self.conf.entity_graph.datasources_values_dir \ + '/' + file_name operational_values, priority_values = \ self._retrieve_states_and_priorities_from_file(full_path) valid_datasources_conf[os.path.splitext(file_name)[0]] = { self.OPERATIONAL_VALUES: operational_values, self.PRIORITY_VALUES: priority_values } except Exception as e: LOG.exception("Exception: %s", e) datasource = os.path.splitext(file_name)[0] LOG.error('erroneous data sources is %s', erroneous_datasources_conf.append(datasource)) self._check_state_confs_exists( [key for key in valid_datasources_conf.keys()], erroneous_datasources_conf) return valid_datasources_conf
def _get_all_entities(self): static_entities = [] files = file_utils.list_files(self.cfg.static_physical.directory, '.yaml') for file_ in files: full_path = self.cfg.static_physical.directory \ + '/' + file_ static_entities += self._get_entities_from_file(file_, full_path) return static_entities
def _load_templates_files(self, conf): templates_dir = conf.evaluator.templates_dir files = \ file_utils.list_files(templates_dir, '.yaml', with_pathname=True) template_defs = [] for f in files: template_defs.append(self._load_template_file(f)) for template_def in template_defs: self.add_template(template_def)
def _get_all_entities(self): static_entities = [] files = file_utils.list_files( self.cfg.static_physical.directory, '.yaml') for file_ in files: full_path = self.cfg.static_physical.directory \ + '/' + file_ static_entities += self._get_entities_from_file(file_, full_path) return static_entities
def _get_changes_entities(self): entities_updates = [] files = file_utils.list_files( self.cfg.static_physical.directory, '.yaml') for file_ in files: full_path = self.cfg.static_physical.directory +\ '/' + file_ config = file_utils.load_yaml_file(full_path) if StaticDriver._is_valid_config(config): LOG.warning("Skipped config of new static datasource: {}" .format(file_)) return [] if config: if file_ in self.cache: if str(config) != str(self.cache[file_]): # TODO(alexey_weyl): need also to remove deleted # files from cache old_config = copy.deepcopy(config) self._update_on_existing_entities( self.cache[file_][self.ENTITIES_SECTION], config[self.ENTITIES_SECTION], entities_updates) self._update_on_new_entities( config[self.ENTITIES_SECTION], self.cache[file_][self.ENTITIES_SECTION], entities_updates) self.cache[file_] = old_config else: self.cache[file_] = config entities_updates += \ self._get_entities_from_file(file_, full_path) # iterate over deleted files deleted_files = set(self.cache.keys()) - set(files) for file_ in deleted_files: self._update_on_existing_entities( self.cache[file_][self.ENTITIES_SECTION], {}, entities_updates) del self.cache[file_] return entities_updates
def _get_changes_entities(self): entities_updates = [] files = file_utils.list_files( self.cfg.static_physical.directory, '.yaml') for file_ in files: full_path = self.cfg.static_physical.directory +\ '/' + file_ config = file_utils.load_yaml_file(full_path) if StaticDriver.is_valid_config(config): LOG.warning("Skipped config of new static datasource: {}" .format(file_)) return [] if config: if file_ in self.cache: if str(config) != str(self.cache[file_]): # TODO(alexey_weyl): need also to remove deleted # files from cache old_config = copy.deepcopy(config) self._update_on_existing_entities( self.cache[file_][self.ENTITIES_SECTION], config[self.ENTITIES_SECTION], entities_updates) self._update_on_new_entities( config[self.ENTITIES_SECTION], self.cache[file_][self.ENTITIES_SECTION], entities_updates) self.cache[file_] = old_config else: self.cache[file_] = config entities_updates += \ self._get_entities_from_file(file_, full_path) # iterate over deleted files deleted_files = set(self.cache.keys()) - set(files) for file_ in deleted_files: self._update_on_existing_entities( self.cache[file_][self.ENTITIES_SECTION], {}, entities_updates) del self.cache[file_] return entities_updates
def _get_all_entities(self): files = file_utils.list_files(CONF.static.directory, '.yaml', True) return list( reduce(chain, [self._get_entities_from_file(path) for path in files], []))
def _get_all_entities(self): files = file_utils.list_files(self.cfg.static.directory, ".yaml", True) return reduce(chain, [self._get_entities_from_file(path) for path in files], [])