示例#1
0
文件: api.py 项目: vandita31/heat
from oslo.config import cfg

from heat.db import utils

SQL_CONNECTION = 'sqlite://'
SQL_IDLE_TIMEOUT = 3600
db_opts = [
    cfg.StrOpt('db_backend',
               default='sqlalchemy',
               help='The backend to use for db')
]

cfg.CONF.register_opts(db_opts)

IMPL = utils.LazyPluggable('db_backend', sqlalchemy='heat.db.sqlalchemy.api')

cfg.CONF.import_opt('sql_connection', 'heat.common.config')
cfg.CONF.import_opt('sql_idle_timeout', 'heat.common.config')


def configure():
    global SQL_CONNECTION
    global SQL_IDLE_TIMEOUT
    SQL_CONNECTION = cfg.CONF.sql_connection
    SQL_IDLE_TIMEOUT = cfg.CONF.sql_idle_timeout


def get_session():
    return IMPL.get_session()
示例#2
0
#    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.
"""Database setup and migration commands."""

from heat.db import utils

IMPL = utils.LazyPluggable('db_backend',
                           sqlalchemy='heat.db.sqlalchemy.migration')

INIT_VERSION = 14


def db_sync(version=None):
    """Migrate the database to `version` or the most recent version."""
    return IMPL.db_sync(version=version)


def db_version():
    """Display the current database version."""
    return IMPL.db_version()