def setUp(self): super(TpoolDbapiWrapperTestCase, self).setUp() self.db_api = concurrency.TpoolDbapiWrapper( conf=self.conf, backend_mapping=FAKE_BACKEND_MAPPING) # NOTE(akurilin): We are not going to add `eventlet` to `oslo.db` in # requirements (`requirements.txt` and `test-requirements.txt`) due to # the following reasons: # - supporting of eventlet's thread pooling is totally optional; # - we don't need to test `tpool.Proxy` functionality itself, # because it's a tool from the third party library; # - `eventlet` would prevent us from running unit tests on Python 3.x # versions, because it doesn't support them yet. # # As we don't test `tpool.Proxy`, we can safely mock it in tests. self.proxy = mock.MagicMock() self.eventlet = mock.MagicMock() self.eventlet.tpool.Proxy.return_value = self.proxy sys.modules['eventlet'] = self.eventlet self.addCleanup(sys.modules.pop, 'eventlet', None)
default=True, help='Services to be added to the available pool on create'), cfg.StrOpt('instance_name_template', default='instance-%08x', help='Template string to be used to generate instance names'), cfg.StrOpt('snapshot_name_template', default='snapshot-%s', help='Template string to be used to generate snapshot names'), ] CONF = cfg.CONF CONF.register_opts(db_opts) _BACKEND_MAPPING = {'sqlalchemy': 'nova.huawei.db.sqlalchemy.affinity_db_api'} IMPL = concurrency.TpoolDbapiWrapper(CONF, backend_mapping=_BACKEND_MAPPING) LOG = logging.getLogger(__name__) class NoMoreNetworks(exception.NovaException): """No more available networks.""" pass class NoMoreTargets(exception.NovaException): """No more available targets.""" pass ###################
cfg.StrOpt('snapshot_name_template', default='snapshot-%s', help='Template string to be used to generate snapshot names'), cfg.StrOpt('backup_name_template', default='backup-%s', help='Template string to be used to generate backup names'), ] CONF = cfg.CONF CONF.register_opts(db_opts) db_options.set_defaults(CONF) CONF.set_default('sqlite_db', 'cinder.sqlite', group='database') _BACKEND_MAPPING = {'sqlalchemy': 'cinder.db.sqlalchemy.api'} IMPL = db_concurrency.TpoolDbapiWrapper(CONF, _BACKEND_MAPPING) ################### def service_destroy(context, service_id): """Destroy the service or raise if it does not exist.""" return IMPL.service_destroy(context, service_id) def service_get(context, service_id): """Get a service or raise if it does not exist.""" return IMPL.service_get(context, service_id) def service_get_by_host_and_topic(context, host, topic):