81b45f2c1d
The statless design was developed in the experiment branch, the experiment shows advantage in removing the status synchronization, uuid mapping compared to the stateful design, and also fully reduce the coupling with OpenStack services like Nova, Cinder. The overhead query latency for resources also acceptable. It's time to move the statless design to the master branch BP: https://blueprints.launchpad.net/tricircle/+spec/implement-stateless Change-Id: I51bbb60dc07da5b2e79f25e02209aa2eb72711ac Signed-off-by: Chaoyi Huang <joehuang@huawei.com>
53 lines
1.5 KiB
Python
53 lines
1.5 KiB
Python
# All Rights Reserved.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
# not use this file except in compliance with the License. You may obtain
|
|
# a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
# License for the specific language governing permissions and limitations
|
|
# under the License.
|
|
|
|
from keystonemiddleware import auth_token
|
|
from oslo_config import cfg
|
|
from oslo_middleware import request_id
|
|
from oslo_service import service
|
|
|
|
import exceptions as t_exc
|
|
from i18n import _
|
|
|
|
|
|
def auth_app(app):
|
|
app = request_id.RequestId(app)
|
|
|
|
if cfg.CONF.auth_strategy == 'noauth':
|
|
pass
|
|
elif cfg.CONF.auth_strategy == 'keystone':
|
|
# NOTE(zhiyuan) pkg_resources will try to load tricircle to get module
|
|
# version, passing "project" as empty string to bypass it
|
|
app = auth_token.AuthProtocol(app, {'project': ''})
|
|
else:
|
|
raise t_exc.InvalidConfigurationOption(
|
|
opt_name='auth_strategy', opt_value=cfg.CONF.auth_strategy)
|
|
|
|
return app
|
|
|
|
|
|
_launcher = None
|
|
|
|
|
|
def serve(api_service, conf, workers=1):
|
|
global _launcher
|
|
if _launcher:
|
|
raise RuntimeError(_('serve() can only be called once'))
|
|
|
|
_launcher = service.launch(conf, api_service, workers=workers)
|
|
|
|
|
|
def wait():
|
|
_launcher.wait()
|