def deploy(conf, project_name): """Assemble the middleware pipeline leading to the placement app.""" if conf.auth_strategy == 'noauth2': auth_middleware = auth.NoAuthMiddleware else: # Do not provide global conf to middleware here. auth_middleware = auth_token.filter_factory( {}, olso_config_project=project_name) context_middleware = auth.PlacementKeystoneContext req_id_middleware = request_id.RequestId microversion_middleware = microversion.MicroversionMiddleware fault_wrap = common_api.FaultWrapper request_log = requestlog.RequestLog application = handler.PlacementHandler() # NOTE(cdent): The ordering here is important. The list is ordered # from the inside out. For a single request req_id_middleware is called # first and microversion_middleware last. Then the request is finally # passed to the application (the PlacementHandler). At that point # the response ascends the middleware in the reverse of the # order the request went in. This order ensures that log messages # all see the same contextual information including request id and # authentication information. for middleware in (microversion_middleware, fault_wrap, request_log, context_middleware, auth_middleware, req_id_middleware, ): application = middleware(application) return application
def make_app(): """App builder (wsgi). Entry point for Blazar REST API server. """ app = flask.Flask('blazar.api') app.route('/', methods=['GET'])(version_list) app.route('/versions', methods=['GET'])(version_list) app.register_blueprint(api_v1_0.rest, url_prefix='/v1') LOG.debug("List of plugins: %s", cfg.CONF.manager.plugins) # TODO(sbauza) : Change this whole crap by removing hardcoded values and # maybe using stevedore for achieving this if (cfg.CONF.manager.plugins and 'physical.host.plugin' in cfg.CONF.manager.plugins): app.register_blueprint(host_api_v1_0.rest, url_prefix='/v1/os-hosts') for code in werkzeug_exceptions.default_exceptions: app.error_handler_spec[None][code] = make_json_error if cfg.CONF.debug and not cfg.CONF.log_exchange: LOG.debug('Logging of request/response exchange could be enabled ' 'using flag --log_exchange') if cfg.CONF.log_exchange: app.wsgi_app = debug.Debug.factory(app.config)(app.wsgi_app) app.wsgi_app = auth_token.filter_factory(app.config)(app.wsgi_app) return app
def deploy(conf, project_name): """Assemble the middleware pipeline leading to the placement app.""" if conf.auth_strategy == 'noauth2': auth_middleware = auth.NoAuthMiddleware else: # Do not provide global conf to middleware here. auth_middleware = auth_token.filter_factory( {}, olso_config_project=project_name) context_middleware = auth.PlacementKeystoneContext req_id_middleware = request_id.RequestId microversion_middleware = microversion.MicroversionMiddleware fault_wrap = common_api.FaultWrapper request_log = requestlog.RequestLog application = handler.PlacementHandler() for middleware in (context_middleware, auth_middleware, microversion_middleware, fault_wrap, req_id_middleware, request_log, ): application = middleware(application) return application
def deploy(conf, project_name): """Assemble the middleware pipeline leading to the placement app.""" if conf.api.auth_strategy == 'noauth2': auth_middleware = auth.NoAuthMiddleware else: # Do not provide global conf to middleware here. auth_middleware = auth_token.filter_factory( {}, olso_config_project=project_name) context_middleware = auth.PlacementKeystoneContext req_id_middleware = request_id.RequestId microversion_middleware = microversion.MicroversionMiddleware fault_wrap = common_api.FaultWrapper request_log = requestlog.RequestLog application = handler.PlacementHandler() # NOTE(cdent): The ordering here is important. The list is ordered # from the inside out. For a single request req_id_middleware is called # first and microversion_middleware last. Then the request is finally # passed to the application (the PlacementHandler). At that point # the response ascends the middleware in the reverse of the # order the request went in. This order ensures that log messages # all see the same contextual information including request id and # authentication information. for middleware in (microversion_middleware, fault_wrap, request_log, context_middleware, auth_middleware, req_id_middleware, ): application = middleware(application) return application
def deploy(conf, project_name): """Assemble the middleware pipeline leading to the placement app.""" if conf.api.auth_strategy == 'noauth2': auth_middleware = auth.NoAuthMiddleware else: # Do not use 'oslo_config_project' param here as the conf # location may have been overridden earlier in the deployment # process with OS_PLACEMENT_CONFIG_DIR in wsgi.py. auth_middleware = auth_token.filter_factory({}, oslo_config_config=conf) # Pass in our CORS config, if any, manually as that's a) # explicit, b) makes testing more straightfoward, c) let's # us control the use of cors by the presence of its config. conf.register_opts(cors.CORS_OPTS, 'cors') if conf.cors.allowed_origin: cors_middleware = oslo_middleware.CORS.factory({}, **conf.cors) else: cors_middleware = None context_middleware = auth.PlacementKeystoneContext req_id_middleware = oslo_middleware.RequestId microversion_middleware = microversion.MicroversionMiddleware fault_wrap = common_api.FaultWrapper request_log = requestlog.RequestLog application = handler.PlacementHandler() # NOTE(cdent): The ordering here is important. The list is ordered # from the inside out. For a single request req_id_middleware is called # first and microversion_middleware last. Then the request is finally # passed to the application (the PlacementHandler). At that point # the response ascends the middleware in the reverse of the # order the request went in. This order ensures that log messages # all see the same contextual information including request id and # authentication information. for middleware in ( microversion_middleware, fault_wrap, request_log, context_middleware, auth_middleware, cors_middleware, req_id_middleware, ): if middleware: application = middleware(application) return application
def setup(*args, **kwargs): if not cfg.has_section(__name__): logger.error('No section for [%s] in haas.cfg; authentication will ' 'not work without this. Please add this section and try ' 'again.', __name__) sys.exit(1) keystone_cfg = {} for key in cfg.options(__name__): keystone_cfg[key] = cfg.get(__name__, key) # Great job with the API design Openstack! </sarcasm> factory = filter_factory(keystone_cfg) app.wsgi_app = factory(app.wsgi_app) auth.set_auth_backend(KeystoneAuthBackend())
def setup(*args, **kwargs): if not cfg.has_section(__name__): logger.error( 'No section for [%s] in hil.cfg; authentication will ' 'not work without this. Please add this section and try ' 'again.', __name__) sys.exit(1) keystone_cfg = {} for key in cfg.options(__name__): keystone_cfg[key] = cfg.get(__name__, key) # Great job with the API design Openstack! </sarcasm> factory = filter_factory(keystone_cfg) app.wsgi_app = factory(app.wsgi_app) auth.set_auth_backend(KeystoneAuthBackend())
def deploy(conf, project_name): """Assemble the middleware pipeline leading to the placement app.""" if conf.api.auth_strategy == 'noauth2': auth_middleware = auth.NoAuthMiddleware else: # Do not provide global conf to middleware here. auth_middleware = auth_token.filter_factory( {}, oslo_config_project=project_name) # Pass in our CORS config, if any, manually as that's a) # explicit, b) makes testing more straightfoward, c) let's # us control the use of cors by the presence of its config. conf.register_opts(cors.CORS_OPTS, 'cors') if conf.cors.allowed_origin: cors_middleware = oslo_middleware.CORS.factory( {}, **conf.cors) else: cors_middleware = None context_middleware = auth.PlacementKeystoneContext req_id_middleware = oslo_middleware.RequestId microversion_middleware = microversion.MicroversionMiddleware fault_wrap = common_api.FaultWrapper request_log = requestlog.RequestLog application = handler.PlacementHandler() # NOTE(cdent): The ordering here is important. The list is ordered # from the inside out. For a single request req_id_middleware is called # first and microversion_middleware last. Then the request is finally # passed to the application (the PlacementHandler). At that point # the response ascends the middleware in the reverse of the # order the request went in. This order ensures that log messages # all see the same contextual information including request id and # authentication information. for middleware in (microversion_middleware, fault_wrap, request_log, context_middleware, auth_middleware, cors_middleware, req_id_middleware, ): if middleware: application = middleware(application) return application
def make_app(): """App builder (wsgi). Entry point for Climate REST API server. """ app = flask.Flask('climate.api') app.route('/', methods=['GET'])(version_list) app.route('/versions', methods=['GET'])(version_list) app.register_blueprint(api_v1_0.rest, url_prefix='/v1') LOG.debug("List of plugins: %s", cfg.CONF.manager.plugins) # TODO(sbauza) : Change this whole crap by removing hardcoded values and # maybe using stevedore for achieving this if (cfg.CONF.manager.plugins and 'physical.host.plugin' in cfg.CONF.manager.plugins): app.register_blueprint(host_api_v1_0.rest, url_prefix='/v1/os-hosts') for code in werkzeug_exceptions.default_exceptions.iterkeys(): app.error_handler_spec[None][code] = make_json_error if cfg.CONF.debug and not cfg.CONF.log_exchange: LOG.debug('Logging of request/response exchange could be enabled ' 'using flag --log_exchange') if cfg.CONF.log_exchange: app.wsgi_app = debug.Debug.factory(app.config)(app.wsgi_app) app.wsgi_app = auth_token.filter_factory( app.config, auth_host=cfg.CONF.os_auth_host, auth_port=cfg.CONF.os_auth_port, auth_protocol=cfg.CONF.os_auth_protocol, admin_user=cfg.CONF.os_admin_username, admin_password=cfg.CONF.os_admin_password, admin_tenant_name=cfg.CONF.os_admin_project_name, auth_version=cfg.CONF.os_auth_version, )(app.wsgi_app) return app
def make_app(): """App builder (wsgi). Entry point for Blazar REST API server. """ app = flask.Flask('blazar.api') app.route('/', methods=['GET'])(version_list) app.route('/versions', methods=['GET'])(version_list) LOG.debug("List of plugins: %s", cfg.CONF.manager.plugins) plugins = cfg.CONF.manager.plugins + ['leases'] extension_manager = enabled.EnabledExtensionManager( check_func=lambda ext: ext.name in plugins, namespace='blazar.api.v1.extensions', invoke_on_load=False) for ext in extension_manager.extensions: bp = ext.plugin() app.register_blueprint(bp, url_prefix=bp.url_prefix) for code in werkzeug_exceptions.default_exceptions: app.register_error_handler(code, make_json_error) if cfg.CONF.debug and not cfg.CONF.log_exchange: LOG.debug('Logging of request/response exchange could be enabled ' 'using flag --log_exchange') if cfg.CONF.log_exchange: app.wsgi_app = debug.Debug.factory(app.config)(app.wsgi_app) app.wsgi_app = request_id.BlazarReqIdMiddleware(app.wsgi_app) app.wsgi_app = request_log.RequestLog(app.wsgi_app) app.wsgi_app = auth_token.filter_factory(app.config)(app.wsgi_app) return app