本文整理汇总了Python中trove.db.get_db_api函数的典型用法代码示例。如果您正苦于以下问题:Python get_db_api函数的具体用法?Python get_db_api怎么用?Python get_db_api使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_db_api函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: launch_services
def launch_services():
get_db_api().configure_db(CONF)
manager = 'trove.conductor.manager.Manager'
topic = CONF.conductor_queue
server = rpc_service.RpcService(manager=manager, topic=topic)
launcher = openstack_service.launch(server,
workers=CONF.trove_conductor_workers)
launcher.wait()
示例2: setUp
def setUp(self):
super(Test_Manager, self).setUp()
sqlstr = "mysql://root:[email protected]/trove"
options = {"sql_connection": sqlstr}
get_db_api().configure_db(options)
self.manager = manager.KSC_Manager()
示例3: load_datastore_configuration_parameters
def load_datastore_configuration_parameters(datastore, datastore_version, config_file):
get_db_api().configure_db(CONF)
(ds, ds_v) = dstore_models.get_datastore_version(type=datastore, version=datastore_version)
with open(config_file) as f:
config = json.load(f)
for param in config["configuration-parameters"]:
create_or_update_datastore_configuration_parameter(
param["name"], ds_v.id, param["restart_required"], param["type"], param.get("max"), param.get("min")
)
示例4: main
def main():
cfg.parse_args(sys.argv)
logging.setup(None)
get_db_api().configure_db(CONF)
conf_file = CONF.find_file(CONF.api_paste_config)
launcher = wsgi.launch('trove', CONF.bind_port or 8779, conf_file,
workers=CONF.trove_api_workers)
launcher.wait()
示例5: initialize_rdl_config
def initialize_rdl_config(config_file):
from trove.common import cfg
from trove.openstack.common import log
from trove.db import get_db_api
conf = cfg.CONF
cfg.parse_args(['int_tests'], default_config_files=[config_file])
log.setup(None)
try:
get_db_api().configure_db(conf)
conf_file = conf.find_file(conf.api_paste_config)
except RuntimeError as error:
import traceback
print traceback.format_exc()
sys.exit("ERROR: %s" % error)
示例6: save
def save(self):
if not self.is_valid():
raise exception.InvalidModelError(errors=self.errors)
self['updated_at'] = utils.utcnow()
LOG.debug("Saving %(name)s: %(dict)s" %
{'name': self.__class__.__name__, 'dict': self.__dict__})
return get_db_api().save(self)
示例7: save
def save(self):
if not self.is_valid():
raise exception.InvalidModelError(errors=self.errors)
self['updated_at'] = utils.utcnow()
LOG.debug(_("Saving %s: %s") %
(self.__class__.__name__, self.__dict__))
return get_db_api().save(self)
示例8: init_db
def init_db():
from trove.common import cfg
from trove.db import get_db_api
from trove.db.sqlalchemy import session
CONF = cfg.CONF
db_api = get_db_api()
db_api.db_sync(CONF)
session.configure_db(CONF)
示例9: init_db
def init_db():
with LOCK:
global DB_SETUP
if not DB_SETUP:
db_api = get_db_api()
db_api.db_sync(CONF)
session.configure_db(CONF)
DB_SETUP = True
示例10: initialize
def initialize(extra_opts=None, pre_logging=None):
# Initialize localization support (the underscore character).
import gettext
gettext.install('trove', unicode=1)
# Apply whole eventlet.monkey_patch excluding 'thread' module.
# Decision for 'thread' module patching will be made
# after debug_utils is set up.
import eventlet
eventlet.monkey_patch(all=True, thread=False)
# Import only the modules necessary to initialize logging and determine if
# debug_utils are enabled.
import sys
from oslo_log import log as logging
from trove.common import cfg
from trove.common import debug_utils
conf = cfg.CONF
if extra_opts:
conf.register_cli_opts(extra_opts)
cfg.parse_args(sys.argv)
if pre_logging:
pre_logging(conf)
logging.setup(conf, None)
debug_utils.setup()
# Patch 'thread' module if debug is disabled.
if not debug_utils.enabled():
eventlet.monkey_patch(thread=True)
# rpc module must be loaded after decision about thread monkeypatching
# because if thread module is not monkeypatched we can't use eventlet
# executor from oslo_messaging library.
from trove import rpc
rpc.init(conf)
# Initialize Trove database.
from trove.db import get_db_api
get_db_api().configure_db(conf)
return conf # May be used by other scripts
示例11: get_backup_child
def get_backup_child(cls, backup_id):
backup_child_list = db.get_db_api().find_all(models.DBBackup, deleted=False, type=Type.AUTOBACKUP) \
.filter(and_(models.DBBackup.parent_id == backup_id)) \
.filter(and_(models.DBBackup.state == models.BackupState.COMPLETED)).all()
if backup_child_list:
return backup_child_list[0]
else:
return None
示例12: load_datastore_configuration_parameters
def load_datastore_configuration_parameters(datastore,
datastore_version,
config_file):
get_db_api().configure_db(CONF)
(ds, ds_v) = dstore_models.get_datastore_version(
type=datastore, version=datastore_version, return_inactive=True)
with open(config_file) as f:
config = json.load(f)
for param in config['configuration-parameters']:
create_or_update_datastore_configuration_parameter(
param['name'],
ds_v.id,
param['restart_required'],
param['type'],
param.get('max'),
param.get('min'),
)
示例13: initialize_database
def initialize_database():
from trove.db import get_db_api
from trove.db.sqlalchemy import session
db_api = get_db_api()
db_api.drop_db(CONF) # Destroys the database, if it exists.
db_api.db_sync(CONF)
session.configure_db(CONF)
datastore_init()
db_api.configure_db(CONF)
示例14: clean_db
def clean_db():
from trove.common import cfg
from trove.db import get_db_api
from trove.db.sqlalchemy import session
CONF = cfg.CONF
if CONF.sql_connection == "sqlite:///trove_test.sqlite":
db_api = get_db_api()
db_api.clean_db()
session.clean_db()
示例15: get_last_full_backup
def get_last_full_backup(cls, group_id):
full_backup_list = db.get_db_api().find_all(models.DBBackup, group_id=group_id, deleted=False,
type=Type.AUTOBACKUP) \
.filter(models.DBBackup.parent_id == None) \
.filter(and_(models.DBBackup.state == models.BackupState.COMPLETED)).order_by("created desc").all()
LOG.debug("full_backup_list: %s", full_backup_list)
if full_backup_list:
return full_backup_list[0]
else:
return None