예제 #1
0
def configure_model(mongo_db_name, pymongo_connection):
    """This fixture append fake config to the Model."""

    generic.configure_models(pymongo_connection)
    generic.ensure_indexes()
    yield
    generic.configure_models(None)
예제 #2
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
예제 #3
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
예제 #4
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
예제 #5
0
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""
This migration applies default user 'root'
"""


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


with wsgi.application.app_context():
    generic.configure_models(db.MongoDB())

    role_collection = role.RoleModel.collection()
    role_id = role_collection.find_one(
        {"name": "wheel"}, ["model_id"])["model_id"]
    role_model = role.RoleModel.find_by_model_id(role_id)

    user.UserModel.make_user(
        "root",
        "root",
        "*****@*****.**",
        "Root User",
        role_model
    )
# -*- 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()])
예제 #7
0
    def decorator(*args, **kwargs):
        check_mongodb_availability()
        generic.configure_models(db.MongoDB())

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

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

        return func(*args, **kwargs)