def _add_flavors_from_configuration():
    """Get flavors from flavor config dir and update to adapters."""
    configs = util.load_configs(setting.ADAPTER_FLAVOR_DIR)
    for config in configs:
        logging.info('add config %s to flavor', config)
        adapter_name = config['ADAPTER_NAME']
        adapter = ADAPTERS[adapter_name]
        adapter_flavors = ADAPTERS_FLAVORS.setdefault(adapter_name, {})
        adapter_roles = ADAPTERS_ROLES[adapter_name]
        for flavor_dict in config['FLAVORS']:
            flavor_name = flavor_dict['flavor']
            flavor_id = '%s:%s' % (adapter_name, flavor_name)
            flavor = {
                'name': flavor_name,
                'id': flavor_id,
                'adapter_id': adapter_name,
                'adapter_name': adapter_name,
                'display_name': flavor_dict.get('display_name', flavor_name),
                'template': flavor_dict.get('template', None)
            }
            flavor_roles = flavor_dict.get('roles', [])
            roles_in_flavor = []
            for flavor_role in flavor_roles:
                if isinstance(flavor_role, basestring):
                    role_name = flavor_role
                    role_in_flavor = {
                        'name': role_name,
                        'flavor_id': flavor_id
                    }
                else:
                    role_in_flavor = flavor_role
                    role_in_flavor['flavor_id'] = flavor_id
                    if 'role' in role_in_flavor:
                        role_in_flavor['name'] = role_in_flavor['role']
                        del role_in_flavor['role']
                    role_name = role_in_flavor['name']
                role = adapter_roles[role_name]
                util.merge_dict(role_in_flavor, role, override=False)
                roles_in_flavor.append(role_in_flavor)
            flavor['roles'] = roles_in_flavor
            adapter_flavors[flavor_name] = flavor
    parents = {}
    for name, adapter in ADAPTERS.items():
        parent = adapter.get('parent', None)
        parents[name] = parent
    for adapter_name, adapter_roles in ADAPTERS_FLAVORS.items():
        util.recursive_merge_dict(adapter_name, ADAPTERS_FLAVORS, parents)
    for adapter_name, adapter_flavors in ADAPTERS_FLAVORS.items():
        adapter = ADAPTERS[adapter_name]
        adapter['flavors'] = adapter_flavors.values()
dataset/ETHPy150Open openstack/compass-core/compass/db/api/adapter.py/_add_flavors_from_configuration/original