"Fossies" - the Fresh Open Source Software Archive

Member "keystone-19.0.0/keystone/conf/__init__.py" (14 Apr 2021, 6788 Bytes) of package /linux/misc/openstack/keystone-19.0.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. For more information about "__init__.py" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 18.0.0_vs_19.0.0.

    1 # Licensed under the Apache License, Version 2.0 (the "License"); you may
    2 # not use this file except in compliance with the License. You may obtain
    3 # a copy of the License at
    4 #
    5 #      http://www.apache.org/licenses/LICENSE-2.0
    6 #
    7 # Unless required by applicable law or agreed to in writing, software
    8 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
    9 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
   10 # License for the specific language governing permissions and limitations
   11 # under the License.
   12 
   13 import logging
   14 
   15 from oslo_cache import core as cache
   16 from oslo_config import cfg
   17 from oslo_log import log
   18 from oslo_log import versionutils
   19 import oslo_messaging
   20 from oslo_middleware import cors
   21 from oslo_policy import opts as policy_opts
   22 from osprofiler import opts as profiler
   23 
   24 from keystone.conf import application_credential
   25 from keystone.conf import assignment
   26 from keystone.conf import auth
   27 from keystone.conf import catalog
   28 from keystone.conf import credential
   29 from keystone.conf import default
   30 from keystone.conf import domain_config
   31 from keystone.conf import endpoint_filter
   32 from keystone.conf import endpoint_policy
   33 from keystone.conf import eventlet_server
   34 from keystone.conf import federation
   35 from keystone.conf import fernet_receipts
   36 from keystone.conf import fernet_tokens
   37 from keystone.conf import identity
   38 from keystone.conf import identity_mapping
   39 from keystone.conf import jwt_tokens
   40 from keystone.conf import ldap
   41 from keystone.conf import memcache
   42 from keystone.conf import oauth1
   43 from keystone.conf import policy
   44 from keystone.conf import receipt
   45 from keystone.conf import resource
   46 from keystone.conf import revoke
   47 from keystone.conf import role
   48 from keystone.conf import saml
   49 from keystone.conf import security_compliance
   50 from keystone.conf import shadow_users
   51 from keystone.conf import token
   52 from keystone.conf import tokenless_auth
   53 from keystone.conf import totp
   54 from keystone.conf import trust
   55 from keystone.conf import unified_limit
   56 from keystone.conf import wsgi
   57 
   58 CONF = cfg.CONF
   59 
   60 
   61 conf_modules = [
   62     application_credential,
   63     assignment,
   64     auth,
   65     catalog,
   66     credential,
   67     default,
   68     domain_config,
   69     endpoint_filter,
   70     endpoint_policy,
   71     eventlet_server,
   72     federation,
   73     fernet_receipts,
   74     fernet_tokens,
   75     identity,
   76     identity_mapping,
   77     jwt_tokens,
   78     ldap,
   79     memcache,
   80     oauth1,
   81     policy,
   82     receipt,
   83     resource,
   84     revoke,
   85     role,
   86     saml,
   87     security_compliance,
   88     shadow_users,
   89     token,
   90     tokenless_auth,
   91     totp,
   92     trust,
   93     unified_limit,
   94     wsgi
   95 ]
   96 
   97 
   98 oslo_messaging.set_transport_defaults(control_exchange='keystone')
   99 _DEPRECATED_REASON = ('This option is only used by eventlet mode which has '
  100                       'been removed from Keystone in Newton release.')
  101 
  102 
  103 def set_default_for_default_log_levels():
  104     """Set the default for the default_log_levels option for keystone.
  105 
  106     Keystone uses some packages that other OpenStack services don't use that do
  107     logging. This will set the default_log_levels default level for those
  108     packages.
  109 
  110     This function needs to be called before CONF().
  111 
  112     """
  113     extra_log_level_defaults = [
  114         'dogpile=INFO',
  115         'routes=INFO',
  116     ]
  117 
  118     log.register_options(CONF)
  119     log.set_defaults(default_log_levels=log.get_default_log_levels() +
  120                      extra_log_level_defaults)
  121 
  122 
  123 def setup_logging():
  124     """Set up logging for the keystone package."""
  125     log.setup(CONF, 'keystone')
  126     logging.captureWarnings(True)
  127 
  128 
  129 def configure(conf=None):
  130     if conf is None:
  131         conf = CONF
  132 
  133     conf.register_cli_opt(
  134         cfg.BoolOpt('standard-threads', default=False,
  135                     help='Do not monkey-patch threading system modules.',
  136                     deprecated_for_removal=True,
  137                     deprecated_reason=_DEPRECATED_REASON,
  138                     deprecated_since=versionutils.deprecated.STEIN))
  139     conf.register_cli_opt(
  140         cfg.StrOpt('pydev-debug-host',
  141                    help='Host to connect to for remote debugger.',
  142                    deprecated_for_removal=True,
  143                    deprecated_reason=_DEPRECATED_REASON,
  144                    deprecated_since=versionutils.deprecated.STEIN))
  145     conf.register_cli_opt(
  146         cfg.PortOpt('pydev-debug-port',
  147                     help='Port to connect to for remote debugger.',
  148                     deprecated_for_removal=True,
  149                     deprecated_reason=_DEPRECATED_REASON,
  150                     deprecated_since=versionutils.deprecated.STEIN))
  151 
  152     for module in conf_modules:
  153         module.register_opts(conf)
  154 
  155     # register any non-default auth methods here (used by extensions, etc)
  156     auth.setup_authentication()
  157 
  158     # add oslo.cache related config options
  159     cache.configure(conf)
  160 
  161 
  162 def set_external_opts_defaults():
  163     """Update default configuration options for oslo.middleware."""
  164     cors.set_defaults(
  165         allow_headers=['X-Auth-Token',
  166                        'X-Openstack-Request-Id',
  167                        'X-Subject-Token',
  168                        'X-Project-Id',
  169                        'X-Project-Name',
  170                        'X-Project-Domain-Id',
  171                        'X-Project-Domain-Name',
  172                        'X-Domain-Id',
  173                        'X-Domain-Name',
  174                        'Openstack-Auth-Receipt'],
  175         expose_headers=['X-Auth-Token',
  176                         'X-Openstack-Request-Id',
  177                         'X-Subject-Token',
  178                         'Openstack-Auth-Receipt'],
  179         allow_methods=['GET',
  180                        'PUT',
  181                        'POST',
  182                        'DELETE',
  183                        'PATCH']
  184     )
  185 
  186     # configure OSprofiler options
  187     profiler.set_defaults(CONF, enabled=False, trace_sqlalchemy=False)
  188 
  189     # TODO(gmann): Remove setting the default value of config policy_file
  190     # once oslo_policy change the default value to 'policy.yaml'.
  191     # https://github.com/openstack/oslo.policy/blob/a626ad12fe5a3abd49d70e3e5b95589d279ab578/oslo_policy/opts.py#L49
  192     DEFAULT_POLICY_FILE = 'policy.yaml'
  193     policy_opts.set_defaults(cfg.CONF, DEFAULT_POLICY_FILE)
  194 
  195     # Oslo.cache is always enabled by default for request-local caching
  196     # TODO(morganfainberg): Fix this to not use internal interface when
  197     # oslo.cache has proper interface to set defaults added. This is
  198     # just a bad way to do this.
  199     opts = cache._opts.list_opts()
  200     for opt_list in opts:
  201         if opt_list[0] == 'cache':
  202             for o in opt_list[1]:
  203                 if o.name == 'enabled':
  204                     o.default = True
  205 
  206 
  207 def set_config_defaults():
  208     """Override all configuration default values for keystone."""
  209     set_default_for_default_log_levels()
  210     set_external_opts_defaults()