
Implement Oslo Config options for Ranger. Change-Id: I5f4b3f58281b9e840dcd3ae49db9363f35ab58d0
42 lines
1.1 KiB
Python
42 lines
1.1 KiB
Python
import os
|
|
import sys
|
|
|
|
from orm.common.orm_common.policy import policy
|
|
from orm.services.flavor_manager.fms_rest.data import wsme
|
|
from orm.services.flavor_manager.fms_rest.logger import get_logger
|
|
from orm.services.flavor_manager.fms_rest.utils import authentication
|
|
|
|
from oslo_config import cfg
|
|
|
|
from pecan.commands import CommandRunner
|
|
from pecan import make_app
|
|
|
|
logger = get_logger(__name__)
|
|
|
|
|
|
def setup_app(config):
|
|
wsme.init_model()
|
|
token_conf = authentication.get_token_conf(config)
|
|
policy.init(config.authentication.policy_file, token_conf)
|
|
app_conf = dict(config.app)
|
|
|
|
app = make_app(
|
|
app_conf.pop('root'),
|
|
logging=getattr(config, 'logging', {}),
|
|
**app_conf
|
|
)
|
|
logger.info('Starting FMS...')
|
|
return app
|
|
|
|
|
|
def main(argv=None):
|
|
if argv is None:
|
|
argv = sys.argv
|
|
cfg.CONF(argv[1:], project='ranger', validate_default_values=True)
|
|
|
|
dir_name = os.path.dirname(__file__)
|
|
drive, path_and_file = os.path.splitdrive(dir_name)
|
|
path, filename = os.path.split(path_and_file)
|
|
runner = CommandRunner()
|
|
runner.run(['serve', path + '/config.py'])
|