summaryrefslogtreecommitdiffstats
path: root/keystone-moon/keystone/contrib/moon/service.py
blob: cd68e98a66598297049f6760faf1b8784b2ea049 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import functools
import sys

from oslo_config import cfg
from oslo_log import log
from paste import deploy
import routes
from keystone.contrib.moon.routers import Routers

from keystone import assignment
from keystone import auth
from keystone import catalog
from keystone.common import wsgi
from keystone import controllers
from keystone import credential
from keystone import endpoint_policy
from keystone import identity
from keystone import policy
from keystone import resource
from keystone import routers
from keystone import token
from keystone import trust


CONF = cfg.CONF
LOG = log.getLogger(__name__)


# def loadapp(conf, name):
#     # NOTE(blk-u): Save the application being loaded in the controllers module.
#     # This is similar to how public_app_factory() and v3_app_factory()
#     # register the version with the controllers module.
#     controllers.latest_app = deploy.loadapp(conf, name=name)
#     return controllers.latest_app


def fail_gracefully(f):
    """Logs exceptions and aborts."""
    @functools.wraps(f)
    def wrapper(*args, **kw):
        try:
            return f(*args, **kw)
        except Exception as e:
            LOG.debug(e, exc_info=True)

            # exception message is printed to all logs
            LOG.critical(e)
            sys.exit(1)

    return wrapper


@fail_gracefully
def moon_app_factory(global_conf, **local_conf):
    return wsgi.ComposingRouter(routes.Mapper(),
                                [Routers('moon_service')])