def process_files(dirname, files):

    node_groups = []
    clusters = []
    plugin_name = get_plugin_name()

    try:
        for fname in files:
            if os.path.splitext(fname)[1] == ".json":
                fpath = os.path.join(dirname, fname)
                with open(fpath, 'r') as fp:
                    try:
                        data = fp.read()
                        template = json.loads(data)
                    except __HOLE__ as e:
                        LOG.warning(_LW("Error processing {path}, "
                                    "{reason}").format(path=fpath, reason=e))
                        raise Handled("error processing files")

                    # If this file doesn't contain basic fields, skip it.
                    # If we are filtering on plugin and version make
                    # sure the file is one that we want
                    if not u.check_basic_fields(template) or (
                            not u.check_plugin_name_and_version(
                                template,
                                plugin_name,
                                CONF.command.plugin_version)):
                        continue

                    # Look through the sections in CONF and register
                    # options for this template if we find a section
                    # related to the template (ie, plugin, version, name)
                    section = add_config_section_for_template(template)
                    LOG.debug("Using config section {section} "
                              "for {path}".format(section=section, path=fpath))

                    # Attempt to resolve substitutions using the config section
                    substitute_config_values(get_configs(section),
                                             template, fpath)

                    file_entry = {'template': template,
                                  'path': fpath}

                    if u.is_node_group(template):
                        # JSON validator
                        try:
                            ng_validator.validate(template)
                        except jsonschema.ValidationError as e:
                            LOG.warning(_LW("Validation for {path} failed, "
                                        "{reason}").format(path=fpath,
                                                           reason=e))
                            raise Handled(
                                "node group template validation failed")
                        node_groups.append(file_entry)
                        LOG.debug("Added {path} to node group "
                                  "template files".format(path=fpath))
                    else:
                        clusters.append(file_entry)
                        LOG.debug("Added {path} to cluster template "
                                  "files".format(path=fpath))

    except Handled as e:
        log_skipping_dir(dirname, str(e))
        node_groups = []
        clusters = []

    except Exception as e:
        log_skipping_dir(dirname,
                         "unhandled exception, {reason}".format(reason=e))
        node_groups = []
        clusters = []

    return node_groups, clusters
dataset/ETHPy150Open openstack/sahara/sahara/db/templates/api.py/process_files