def add_config_section_for_template(template):
    '''Register a config section based on the template values

    Check to see if the configuration files contain a section
    that corresponds to the template.  If an appropriate section
    can be found, register options for the template so that the
    config values can be read and applied to the template via
    substitution (oslo supports registering groups and options
    at any time, before or after the config files are parsed).

    Corresponding section names may be of the following forms:

    <template_name>, example "hdp-2.0.6-master"
    This is useful when a template naming convention is being used,
    so that the template name is already unambiguous

    <plugin_name>_<hadoop_version>_<template_name>, example "hdp_2.0.6_master"
    This can be used if there is a name collision between templates

    <plugin_name>_<hadoop_version>, example "hdp_2.0.6"
    <plugin_name>, example "hdp"
    DEFAULT

    Sections are tried in the order given above.

    Since the first two section naming forms refer to a specific
    template by name, options are added based on template type.

    However, the other section naming forms may map to node group templates
    or cluster templates, so options for both are added.
    '''
    sections = list(CONF.list_all_sections())

    unique_name = "{name}".format(**template)
    fullname = "{plugin_name}_{hadoop_version}_{name}".format(**template)
    plugin_version = "{plugin_name}_{hadoop_version}".format(**template)
    plugin = "{plugin_name}".format(**template)

    section_name = None
    if unique_name in sections:
        section_name = unique_name
    elif fullname in sections:
        section_name = fullname

    if section_name:
        if u.is_node_group(template):
            opts = node_group_template_opts
        else:
            opts = cluster_template_opts
    else:
        if plugin_version in sections:
            section_name = plugin_version
        elif plugin in sections:
            section_name = plugin
        opts = all_template_opts

    add_config_section(section_name, opts)
    return section_name
dataset/ETHPy150Open openstack/sahara/sahara/db/templates/api.py/add_config_section_for_template/original