def _add_roles_from_configuration():
    """Get roles from roles config dir and update to adapters."""
    configs = util.load_configs(setting.ADAPTER_ROLE_DIR)
    for config in configs:
        logging.info(
            'add config %s to role', config
        )
        adapter_name = config['ADAPTER_NAME']
        adapter = ADAPTERS[adapter_name]
        adapter_roles = ADAPTERS_ROLES.setdefault(adapter_name, {})
        for role_dict in config['ROLES']:
            role_name = role_dict['role']
            display_name = role_dict.get('display_name', role_name)
            adapter_roles[role_name] = {
                'name': role_name,
                'id': '%s:%s' % (adapter_name, role_name),
                'adapter_id': adapter_name,
                'adapter_name': adapter_name,
                'display_name': display_name,
                'description': role_dict.get('description', display_name),
                'optional': role_dict.get('optional', False)
            }
    parents = {}
    for name, adapter in ADAPTERS.items():
        parent = adapter.get('parent', None)
        parents[name] = parent
    for adapter_name, adapter_roles in ADAPTERS_ROLES.items():
        util.recursive_merge_dict(adapter_name, ADAPTERS_ROLES, parents)
    for adapter_name, adapter_roles in ADAPTERS_ROLES.items():
        adapter = ADAPTERS[adapter_name]
        adapter['roles'] = adapter_roles.values()
dataset/ETHPy150Open openstack/compass-core/compass/db/api/adapter.py/_add_roles_from_configuration/original