def _get_facade(): global _facade if not _facade: _facade = enginefacade.LegacyEngineFacade( cfg.CONF.database.connection, sqlite_fk=True, autocommit=False, **dict(cfg.CONF.database.items())) if cfg.CONF.profiler.enabled: if cfg.CONF.profiler.trace_sqlalchemy: osprofiler.sqlalchemy.add_tracing(sa, _facade.get_engine(), 'db') return _facade
def __init__(self, conf, url): # Set max_retries to 0, since oslo.db in certain cases may attempt # to retry making the db connection retried max_retries ^ 2 times # in failure case and db reconnection has already been implemented # in storage.__init__.get_connection_from_config function options = dict(conf.database.items()) options['max_retries'] = 0 # oslo.db doesn't support options defined by Aodh for opt in storage.OPTS: options.pop(opt.name, None) self._engine_facade = enginefacade.LegacyEngineFacade( self.dress_url(url), **options) if osprofiler_sqlalchemy: osprofiler_sqlalchemy.add_tracing(sqlalchemy, self._engine_facade.get_engine(), 'db') self.conf = conf