Beispiel #1
0
def main_script(options, set_shutdown=True):
    if set_shutdown:
        atexit.register(mainloop.shutdown_callback)

    log.configure_logging(CONF.logging_config)
    generic.configure_models(db.MongoDB())

    try:
        return mainloop.main()
    except KeyboardInterrupt:
        pass
Beispiel #2
0
def create_application():
    """Creates and configures WSGI application."""

    application = flask.Flask(__name__)
    application.url_map.strict_slashes = False

    app_config.configure(application)
    handlers.register_handlers(application)
    views.register_api(application)
    generic_model.configure_models(db.MongoDB())

    log.configure_logging(CONF.logging_config)

    return application
# -*- coding: utf-8 -*-
# Copyright (c) 2016 Mirantis Inc.
#
# 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.
"""
This migration applies default 'wheel' role.
"""

from decapod_api import wsgi
from decapod_common.models import db
from decapod_common.models import generic
from decapod_common.models import role

with wsgi.application.app_context():
    generic.configure_models(db.MongoDB())
    role.RoleModel.make_role("wheel", [{
        "name": k,
        "permissions": sorted(v)
    } for k, v in role.PermissionSet.KNOWN_PERMISSIONS.items()])
Beispiel #4
0
    def decorator(*args, **kwargs):
        check_mongodb_availability()
        generic.configure_models(db.MongoDB())

        return func(*args, **kwargs)
Beispiel #5
0
    def decorator(*args, **kwargs):
        log.configure_logging(CONF.logging_config)
        generic.configure_models(db.MongoDB())

        return func(*args, **kwargs)