Add common support for database configuration

Fixes bug 1096537

Change-Id: I9b7dbc08ae709af81ca968857f7028c150d2c7e5
This commit is contained in:
Gary Kotton 2013-01-06 07:22:45 +00:00
parent f64fa42533
commit 5f8c93519b
19 changed files with 56 additions and 263 deletions

View File

@ -32,11 +32,39 @@ from sqlalchemy.interfaces import PoolListener
from sqlalchemy.orm import sessionmaker from sqlalchemy.orm import sessionmaker
from quantum.db import model_base from quantum.db import model_base
from quantum.openstack.common import cfg
from quantum.openstack.common import log as logging from quantum.openstack.common import log as logging
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
database_opts = [
cfg.StrOpt('sql_connection', default='sqlite://',
help=_('The SQLAlchemy connection string used to connect to '
'the database')),
cfg.IntOpt('sql_max_retries', default=-1,
help=_('Database reconnection retry times')),
cfg.IntOpt('reconnect_interval', default=2,
help=_('Database reconnection interval in seconds')),
cfg.IntOpt('sql_min_pool_size',
default=1,
help=_("Minimum number of SQL connections to keep open in a "
"pool")),
cfg.IntOpt('sql_max_pool_size',
default=5,
help=_("Maximum number of SQL connections to keep open in a "
"pool")),
cfg.IntOpt('sql_idle_timeout',
default=3600,
help=_("Timeout in seconds before idle sql connections are "
"reaped")),
cfg.BoolOpt('sql_dbpool_enable',
default=False,
help=_("Enable the use of eventlet's db_pool for MySQL")),
]
cfg.CONF.register_opts(database_opts, "DATABASE")
_ENGINE = None _ENGINE = None
_MAKER = None _MAKER = None
BASE = model_base.BASEV2 BASE = model_base.BASEV2
@ -75,16 +103,15 @@ class SqliteForeignKeysListener(PoolListener):
dbapi_con.execute('pragma foreign_keys=ON') dbapi_con.execute('pragma foreign_keys=ON')
def configure_db(options): def configure_db():
""" """
Establish the database, create an engine if needed, and Establish the database, create an engine if needed, and
register the models. register the models.
:param options: Mapping of configuration options
""" """
global _ENGINE global _ENGINE
if not _ENGINE: if not _ENGINE:
connection_dict = sql.engine.url.make_url(options['sql_connection']) sql_connection = cfg.CONF.DATABASE.sql_connection
connection_dict = sql.engine.url.make_url(sql_connection)
engine_args = { engine_args = {
'pool_recycle': 3600, 'pool_recycle': 3600,
'echo': False, 'echo': False,
@ -94,36 +121,35 @@ def configure_db(options):
if 'mysql' in connection_dict.drivername: if 'mysql' in connection_dict.drivername:
engine_args['listeners'] = [MySQLPingListener()] engine_args['listeners'] = [MySQLPingListener()]
if (MySQLdb is not None and if (MySQLdb is not None and
options['sql_dbpool_enable']): cfg.CONF.DATABASE.sql_dbpool_enable):
pool_args = { pool_args = {
'db': connection_dict.database, 'db': connection_dict.database,
'passwd': connection_dict.password or '', 'passwd': connection_dict.password or '',
'host': connection_dict.host, 'host': connection_dict.host,
'user': connection_dict.username, 'user': connection_dict.username,
'min_size': options['sql_min_pool_size'], 'min_size': cfg.CONF.DATABASE.sql_min_pool_size,
'max_size': options['sql_max_pool_size'], 'max_size': cfg.CONF.DATABASE.sql_max_pool_size,
'max_idle': options['sql_idle_timeout'] 'max_idle': cfg.CONF.DATABASE.sql_idle_timeout
} }
creator = db_pool.ConnectionPool(MySQLdb, **pool_args) creator = db_pool.ConnectionPool(MySQLdb, **pool_args)
engine_args['creator'] = creator.create engine_args['creator'] = creator.create
if (MySQLdb is None and options['sql_dbpool_enable']): if (MySQLdb is None and cfg.CONF.DATABASE.sql_dbpool_enable):
LOG.warn(_("Eventlet connection pooling will not work without " LOG.warn(_("Eventlet connection pooling will not work without "
"python-mysqldb!")) "python-mysqldb!"))
if 'sqlite' in connection_dict.drivername: if 'sqlite' in connection_dict.drivername:
engine_args['listeners'] = [SqliteForeignKeysListener()] engine_args['listeners'] = [SqliteForeignKeysListener()]
if options['sql_connection'] == "sqlite://": if sql_connection == "sqlite://":
engine_args["connect_args"] = {'check_same_thread': False} engine_args["connect_args"] = {'check_same_thread': False}
_ENGINE = create_engine(options['sql_connection'], **engine_args) _ENGINE = create_engine(sql_connection, **engine_args)
sql.event.listen(_ENGINE, 'checkin', greenthread_yield) sql.event.listen(_ENGINE, 'checkin', greenthread_yield)
base = options.get('base', BASE) if not register_models():
if not register_models(base):
if 'reconnect_interval' in options: if 'reconnect_interval' in options:
remaining = options.get('sql_max_retries', -1) remaining = cfg.CONF.DATABASE.sql_max_retries
reconnect_interval = options['reconnect_interval'] reconnect_interval = cfg.CONF.DATABASE.reconnect_interval
retry_registration(remaining, reconnect_interval, base) retry_registration(remaining, reconnect_interval)
def clear_db(base=BASE): def clear_db(base=BASE):

View File

@ -73,8 +73,7 @@ class QuantumDbPluginV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
# must override __init__ and setup the database # must override __init__ and setup the database
# and not call into this class's __init__. # and not call into this class's __init__.
# This connection is setup as memory for the tests. # This connection is setup as memory for the tests.
db.configure_db({'sql_connection': "sqlite:///:memory:", db.configure_db()
'base': models_v2.model_base.BASEV2})
def _get_tenant_id_for_create(self, context, resource): def _get_tenant_id_for_create(self, context, resource):
if context.is_admin and 'tenant_id' in resource: if context.is_admin and 'tenant_id' in resource:

View File

@ -66,28 +66,6 @@ from quantum.plugins.bigswitch.version import version_string_with_vcs
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
database_opts = [
cfg.StrOpt('sql_connection', default='sqlite://'),
cfg.IntOpt('sql_max_retries', default=-1),
cfg.IntOpt('reconnect_interval', default=2),
cfg.IntOpt('sql_min_pool_size',
default=1,
help="Minimum number of SQL connections to keep open in a "
"pool"),
cfg.IntOpt('sql_max_pool_size',
default=5,
help="Maximum number of SQL connections to keep open in a "
"pool"),
cfg.IntOpt('sql_idle_timeout',
default=3600,
help="Timeout in seconds before idle sql connections are "
"reaped"),
cfg.BoolOpt('sql_dbpool_enable',
default=False,
help="Enable the use of eventlet's db_pool for MySQL"),
]
restproxy_opts = [ restproxy_opts = [
cfg.StrOpt('servers', default='localhost:8800'), cfg.StrOpt('servers', default='localhost:8800'),
cfg.StrOpt('serverauth', default='username:password'), cfg.StrOpt('serverauth', default='username:password'),
@ -97,7 +75,6 @@ restproxy_opts = [
] ]
cfg.CONF.register_opts(database_opts, "DATABASE")
cfg.CONF.register_opts(restproxy_opts, "RESTPROXY") cfg.CONF.register_opts(restproxy_opts, "RESTPROXY")
@ -277,15 +254,7 @@ class QuantumRestProxyV2(db_base_plugin_v2.QuantumDbPluginV2):
version_string_with_vcs()) version_string_with_vcs())
# init DB, proxy's persistent store defaults to in-memory sql-lite DB # init DB, proxy's persistent store defaults to in-memory sql-lite DB
options = {"sql_connection": "%s" % cfg.CONF.DATABASE.sql_connection, db.configure_db()
"sql_max_retries": cfg.CONF.DATABASE.sql_max_retries,
"reconnect_interval": cfg.CONF.DATABASE.reconnect_interval,
"base": models_v2.model_base.BASEV2,
"sql_min_pool_size": cfg.CONF.DATABASE.sql_min_pool_size,
"sql_max_pool_size": cfg.CONF.DATABASE.sql_max_pool_size,
"sql_idle_timeout": cfg.CONF.DATABASE.sql_idle_timeout,
"sql_dbpool_enable": cfg.CONF.DATABASE.sql_dbpool_enable}
db.configure_db(options)
# 'servers' is the list of network controller REST end-points # 'servers' is the list of network controller REST end-points
# (used in order specified till one suceeds, and it is sticky # (used in order specified till one suceeds, and it is sticky

View File

@ -33,27 +33,6 @@ vlan_opts = [
"or <physical_network>"), "or <physical_network>"),
] ]
database_opts = [
cfg.StrOpt('sql_connection', default='sqlite://'),
cfg.IntOpt('sql_max_retries', default=-1),
cfg.IntOpt('reconnect_interval', default=2),
cfg.IntOpt('sql_min_pool_size',
default=1,
help="Minimum number of SQL connections to keep open in a "
"pool"),
cfg.IntOpt('sql_max_pool_size',
default=5,
help="Maximum number of SQL connections to keep open in a "
"pool"),
cfg.IntOpt('sql_idle_timeout',
default=3600,
help="Timeout in seconds before idle sql connections are "
"reaped"),
cfg.BoolOpt('sql_dbpool_enable',
default=False,
help="Enable the use of eventlet's db_pool for MySQL"),
]
bridge_opts = [ bridge_opts = [
cfg.ListOpt('physical_interface_mappings', cfg.ListOpt('physical_interface_mappings',
default=DEFAULT_INTERFACE_MAPPINGS, default=DEFAULT_INTERFACE_MAPPINGS,
@ -67,6 +46,5 @@ agent_opts = [
cfg.CONF.register_opts(vlan_opts, "VLANS") cfg.CONF.register_opts(vlan_opts, "VLANS")
cfg.CONF.register_opts(database_opts, "DATABASE")
cfg.CONF.register_opts(bridge_opts, "LINUX_BRIDGE") cfg.CONF.register_opts(bridge_opts, "LINUX_BRIDGE")
cfg.CONF.register_opts(agent_opts, "AGENT") cfg.CONF.register_opts(agent_opts, "AGENT")

View File

@ -29,17 +29,7 @@ LOG = logging.getLogger(__name__)
def initialize(): def initialize():
options = { db.configure_db()
"sql_connection": cfg.CONF.DATABASE.sql_connection,
"sql_max_retries": cfg.CONF.DATABASE.sql_max_retries,
"reconnect_interval": cfg.CONF.DATABASE.reconnect_interval,
"base": models_v2.model_base.BASEV2,
"sql_min_pool_size": cfg.CONF.DATABASE.sql_min_pool_size,
"sql_max_pool_size": cfg.CONF.DATABASE.sql_max_pool_size,
"sql_idle_timeout": cfg.CONF.DATABASE.sql_idle_timeout,
"sql_dbpool_enable": cfg.CONF.DATABASE.sql_dbpool_enable
}
db.configure_db(options)
def sync_network_states(network_vlan_ranges): def sync_network_states(network_vlan_ranges):

View File

@ -18,27 +18,6 @@
from quantum.openstack.common import cfg from quantum.openstack.common import cfg
database_opts = [
cfg.StrOpt('sql_connection', default='sqlite://'),
cfg.IntOpt('sql_max_retries', default=-1),
cfg.IntOpt('reconnect_interval', default=2),
cfg.IntOpt('sql_min_pool_size',
default=1,
help="Minimum number of SQL connections to keep open in a "
"pool"),
cfg.IntOpt('sql_max_pool_size',
default=5,
help="Maximum number of SQL connections to keep open in a "
"pool"),
cfg.IntOpt('sql_idle_timeout',
default=3600,
help="Timeout in seconds before idle sql connections are "
"reaped"),
cfg.BoolOpt('sql_dbpool_enable',
default=False,
help="Enable the use of eventlet's db_pool for MySQL"),
]
meta_plugin_opts = [ meta_plugin_opts = [
cfg.StrOpt('plugin_list', default=''), cfg.StrOpt('plugin_list', default=''),
cfg.StrOpt('l3_plugin_list', default=''), cfg.StrOpt('l3_plugin_list', default=''),
@ -57,6 +36,5 @@ proxy_plugin_opts = [
cfg.StrOpt('auth_region'), cfg.StrOpt('auth_region'),
] ]
cfg.CONF.register_opts(database_opts, "DATABASE")
cfg.CONF.register_opts(meta_plugin_opts, "META") cfg.CONF.register_opts(meta_plugin_opts, "META")
cfg.CONF.register_opts(proxy_plugin_opts, "PROXY") cfg.CONF.register_opts(proxy_plugin_opts, "PROXY")

View File

@ -50,16 +50,6 @@ class MetaPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
def __init__(self, configfile=None): def __init__(self, configfile=None):
LOG.debug(_("Start initializing metaplugin")) LOG.debug(_("Start initializing metaplugin"))
options = {
"sql_connection": "%s" % cfg.CONF.DATABASE.sql_connection,
"sql_max_retries": cfg.CONF.DATABASE.sql_max_retries,
"reconnect_interval": cfg.CONF.DATABASE.reconnect_interval,
"base": models_v2.model_base.BASEV2,
"sql_min_pool_size": cfg.CONF.DATABASE.sql_min_pool_size,
"sql_max_pool_size": cfg.CONF.DATABASE.sql_max_pool_size,
"sql_idle_timeout": cfg.CONF.DATABASE.sql_idle_timeout,
"sql_dbpool_enable": cfg.CONF.DATABASE.sql_dbpool_enable
}
self.supported_extension_aliases = \ self.supported_extension_aliases = \
cfg.CONF.META.supported_extension_aliases.split(',') cfg.CONF.META.supported_extension_aliases.split(',')
self.supported_extension_aliases += ['flavor', 'router'] self.supported_extension_aliases += ['flavor', 'router']
@ -108,7 +98,7 @@ class MetaPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
raise exc.Invalid(_('default_l3_flavor %s is not plugin list') % raise exc.Invalid(_('default_l3_flavor %s is not plugin list') %
self.default_l3_flavor) self.default_l3_flavor)
db.configure_db(options) db.configure_db()
self.extension_map = {} self.extension_map = {}
if not cfg.CONF.META.extension_map == '': if not cfg.CONF.META.extension_map == '':

View File

@ -33,13 +33,7 @@ class ProxyPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
supported_extension_aliases = ["router"] supported_extension_aliases = ["router"]
def __init__(self, configfile=None): def __init__(self, configfile=None):
options = {"sql_connection": cfg.CONF.DATABASE.sql_connection} db.configure_db()
options.update({'base': models_v2.model_base.BASEV2})
sql_max_retries = cfg.CONF.DATABASE.sql_max_retries
options.update({"sql_max_retries": sql_max_retries})
reconnect_interval = cfg.CONF.DATABASE.reconnect_interval
options.update({"reconnect_interval": reconnect_interval})
db.configure_db(options)
self.quantum = client.Client( self.quantum = client.Client(
username=cfg.CONF.PROXY.admin_user, username=cfg.CONF.PROXY.admin_user,
password=cfg.CONF.PROXY.admin_password, password=cfg.CONF.PROXY.admin_password,

View File

@ -20,27 +20,6 @@ from quantum.openstack.common import cfg
from quantum.openstack.common import rpc from quantum.openstack.common import rpc
database_opts = [
cfg.StrOpt('sql_connection', default='sqlite://'),
cfg.IntOpt('sql_max_retries', default=-1),
cfg.IntOpt('reconnect_interval', default=2),
cfg.IntOpt('sql_min_pool_size',
default=1,
help=_("Minimum number of SQL connections to keep open in a "
"pool")),
cfg.IntOpt('sql_max_pool_size',
default=5,
help=_("Maximum number of SQL connections to keep open in a "
"pool")),
cfg.IntOpt('sql_idle_timeout',
default=3600,
help=_("Timeout in seconds before idle sql connections are "
"reaped")),
cfg.BoolOpt('sql_dbpool_enable',
default=False,
help=_("Enable the use of eventlet's db_pool for MySQL")),
]
ovs_opts = [ ovs_opts = [
cfg.StrOpt('integration_bridge', default='br-int'), cfg.StrOpt('integration_bridge', default='br-int'),
] ]
@ -61,7 +40,6 @@ ofc_opts = [
] ]
cfg.CONF.register_opts(database_opts, "DATABASE")
cfg.CONF.register_opts(ovs_opts, "OVS") cfg.CONF.register_opts(ovs_opts, "OVS")
cfg.CONF.register_opts(agent_opts, "AGENT") cfg.CONF.register_opts(agent_opts, "AGENT")
cfg.CONF.register_opts(ofc_opts, "OFC") cfg.CONF.register_opts(ofc_opts, "OFC")

View File

@ -30,15 +30,7 @@ OFP_VLAN_NONE = 0xffff
def initialize(): def initialize():
options = {"sql_connection": "%s" % config.DATABASE.sql_connection, db.configure_db()
"sql_max_retries": config.DATABASE.sql_max_retries,
"reconnect_interval": config.DATABASE.reconnect_interval,
"base": model_base.BASEV2,
"sql_min_pool_size": config.CONF.DATABASE.sql_min_pool_size,
"sql_max_pool_size": config.CONF.DATABASE.sql_max_pool_size,
"sql_idle_timeout": config.CONF.DATABASE.sql_idle_timeout,
"sql_dbpool_enable": config.CONF.DATABASE.sql_dbpool_enable}
db.configure_db(options)
def clear_db(base=model_base.BASEV2): def clear_db(base=model_base.BASEV2):

View File

@ -76,16 +76,6 @@ def parse_config():
NVPCluster objects, 'plugin_config' is a dictionary with plugin NVPCluster objects, 'plugin_config' is a dictionary with plugin
parameters (currently only 'max_lp_per_bridged_ls'). parameters (currently only 'max_lp_per_bridged_ls').
""" """
db_options = {
"sql_connection": "%s" % cfg.CONF.DATABASE.sql_connection,
"sql_max_retries": cfg.CONF.DATABASE.sql_max_retries,
"reconnect_interval": cfg.CONF.DATABASE.reconnect_interval,
"base": models_v2.model_base.BASEV2,
"sql_min_pool_size": cfg.CONF.DATABASE.sql_min_pool_size,
"sql_max_pool_size": cfg.CONF.DATABASE.sql_max_pool_size,
"sql_idle_timeout": cfg.CONF.DATABASE.sql_idle_timeout,
"sql_dbpool_enable": cfg.CONF.DATABASE.sql_dbpool_enable
}
nvp_options = cfg.CONF.NVP nvp_options = cfg.CONF.NVP
nvp_conf = config.ClusterConfigOptions(cfg.CONF) nvp_conf = config.ClusterConfigOptions(cfg.CONF)
cluster_names = config.register_cluster_groups(nvp_conf) cluster_names = config.register_cluster_groups(nvp_conf)
@ -104,7 +94,7 @@ def parse_config():
'nvp_controller_connection': 'nvp_controller_connection':
nvp_conf[cluster_name].nvp_controller_connection, }) nvp_conf[cluster_name].nvp_controller_connection, })
LOG.debug(_("Cluster options: %s"), clusters_options) LOG.debug(_("Cluster options: %s"), clusters_options)
return db_options, nvp_options, clusters_options return nvp_options, clusters_options
class NVPRpcCallbacks(dhcp_rpc_base.DhcpRpcCallbackMixin): class NVPRpcCallbacks(dhcp_rpc_base.DhcpRpcCallbackMixin):
@ -137,7 +127,7 @@ class NvpPluginV2(db_base_plugin_v2.QuantumDbPluginV2):
nvplib.LOG.setLevel(loglevel) nvplib.LOG.setLevel(loglevel)
NvpApiClient.LOG.setLevel(loglevel) NvpApiClient.LOG.setLevel(loglevel)
self.db_opts, self.nvp_opts, self.clusters_opts = parse_config() self.nvp_opts, self.clusters_opts = parse_config()
self.clusters = {} self.clusters = {}
for c_opts in self.clusters_opts: for c_opts in self.clusters_opts:
# Password is guaranteed to be the same across all controllers # Password is guaranteed to be the same across all controllers
@ -189,7 +179,7 @@ class NvpPluginV2(db_base_plugin_v2.QuantumDbPluginV2):
# otherwise set 1st cluster as default # otherwise set 1st cluster as default
self.default_cluster = self.clusters[first_cluster_name] self.default_cluster = self.clusters[first_cluster_name]
db.configure_db(self.db_opts) db.configure_db()
# Extend the fault map # Extend the fault map
self._extend_fault_map() self._extend_fault_map()
# Set up RPC interface for DHCP agent # Set up RPC interface for DHCP agent

View File

@ -17,27 +17,6 @@
from quantum.openstack.common import cfg from quantum.openstack.common import cfg
database_opts = [
cfg.StrOpt('sql_connection', default='sqlite://'),
cfg.IntOpt('sql_max_retries', default=-1),
cfg.IntOpt('reconnect_interval', default=2),
cfg.IntOpt('sql_min_pool_size',
default=1,
help="Minimum number of SQL connections to keep open in a "
"pool"),
cfg.IntOpt('sql_max_pool_size',
default=5,
help="Maximum number of SQL connections to keep open in a "
"pool"),
cfg.IntOpt('sql_idle_timeout',
default=3600,
help="Timeout in seconds before idle sql connections are "
"reaped"),
cfg.BoolOpt('sql_dbpool_enable',
default=False,
help="Enable the use of eventlet's db_pool for MySQL"),
]
nvp_opts = [ nvp_opts = [
cfg.IntOpt('max_lp_per_bridged_ls', default=64), cfg.IntOpt('max_lp_per_bridged_ls', default=64),
cfg.IntOpt('max_lp_per_overlay_ls', default=256), cfg.IntOpt('max_lp_per_overlay_ls', default=256),
@ -53,7 +32,6 @@ cluster_opts = [
cfg.MultiStrOpt('nvp_controller_connection') cfg.MultiStrOpt('nvp_controller_connection')
] ]
cfg.CONF.register_opts(database_opts, "DATABASE")
cfg.CONF.register_opts(nvp_opts, "NVP") cfg.CONF.register_opts(nvp_opts, "NVP")

View File

@ -21,27 +21,6 @@ DEFAULT_BRIDGE_MAPPINGS = []
DEFAULT_VLAN_RANGES = [] DEFAULT_VLAN_RANGES = []
DEFAULT_TUNNEL_RANGES = [] DEFAULT_TUNNEL_RANGES = []
database_opts = [
cfg.StrOpt('sql_connection', default='sqlite://'),
cfg.IntOpt('sql_max_retries', default=-1),
cfg.IntOpt('reconnect_interval', default=2),
cfg.IntOpt('sql_min_pool_size',
default=1,
help="Minimum number of SQL connections to keep open in a "
"pool"),
cfg.IntOpt('sql_max_pool_size',
default=5,
help="Maximum number of SQL connections to keep open in a "
"pool"),
cfg.IntOpt('sql_idle_timeout',
default=3600,
help="Timeout in seconds before idle sql connections are "
"reaped"),
cfg.BoolOpt('sql_dbpool_enable',
default=False,
help="Enable the use of eventlet's db_pool for MySQL"),
]
ovs_opts = [ ovs_opts = [
cfg.StrOpt('integration_bridge', default='br-int'), cfg.StrOpt('integration_bridge', default='br-int'),
cfg.BoolOpt('enable_tunneling', default=False), cfg.BoolOpt('enable_tunneling', default=False),
@ -72,6 +51,5 @@ agent_opts = [
] ]
cfg.CONF.register_opts(database_opts, "DATABASE")
cfg.CONF.register_opts(ovs_opts, "OVS") cfg.CONF.register_opts(ovs_opts, "OVS")
cfg.CONF.register_opts(agent_opts, "AGENT") cfg.CONF.register_opts(agent_opts, "AGENT")

View File

@ -30,17 +30,7 @@ LOG = logging.getLogger(__name__)
def initialize(): def initialize():
options = { db.configure_db()
"sql_connection": cfg.CONF.DATABASE.sql_connection,
"sql_max_retries": cfg.CONF.DATABASE.sql_max_retries,
"reconnect_interval": cfg.CONF.DATABASE.reconnect_interval,
"base": models_v2.model_base.BASEV2,
"sql_min_pool_size": cfg.CONF.DATABASE.sql_min_pool_size,
"sql_max_pool_size": cfg.CONF.DATABASE.sql_max_pool_size,
"sql_idle_timeout": cfg.CONF.DATABASE.sql_idle_timeout,
"sql_dbpool_enable": cfg.CONF.DATABASE.sql_dbpool_enable
}
db.configure_db(options)
def get_network_binding(session, network_id): def get_network_binding(session, network_id):

View File

@ -17,27 +17,6 @@
from quantum.openstack.common import cfg from quantum.openstack.common import cfg
database_opts = [
cfg.StrOpt('sql_connection', default='sqlite://'),
cfg.IntOpt('sql_max_retries', default=-1),
cfg.IntOpt('reconnect_interval', default=2),
cfg.IntOpt('sql_min_pool_size',
default=1,
help=_("Minimum number of SQL connections to keep open in a "
"pool")),
cfg.IntOpt('sql_max_pool_size',
default=5,
help=_("Maximum number of SQL connections to keep open in a "
"pool")),
cfg.IntOpt('sql_idle_timeout',
default=3600,
help=_("Timeout in seconds before idle sql connections are "
"reaped")),
cfg.BoolOpt('sql_dbpool_enable',
default=False,
help=_("Enable the use of eventlet's db_pool for MySQL")),
]
ovs_opts = [ ovs_opts = [
cfg.StrOpt('integration_bridge', default='br-int'), cfg.StrOpt('integration_bridge', default='br-int'),
cfg.StrOpt('openflow_controller', default='127.0.0.1:6633'), cfg.StrOpt('openflow_controller', default='127.0.0.1:6633'),
@ -57,6 +36,5 @@ agent_opts = [
] ]
cfg.CONF.register_opts(database_opts, "DATABASE")
cfg.CONF.register_opts(ovs_opts, "OVS") cfg.CONF.register_opts(ovs_opts, "OVS")
cfg.CONF.register_opts(agent_opts, "AGENT") cfg.CONF.register_opts(agent_opts, "AGENT")

View File

@ -55,17 +55,7 @@ class RyuQuantumPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
supported_extension_aliases = ["router"] supported_extension_aliases = ["router"]
def __init__(self, configfile=None): def __init__(self, configfile=None):
options = { db.configure_db()
"sql_connection": "%s" % cfg.CONF.DATABASE.sql_connection,
"sql_max_retries": cfg.CONF.DATABASE.sql_max_retries,
"reconnect_interval": cfg.CONF.DATABASE.reconnect_interval,
"base": models_v2.model_base.BASEV2,
"sql_min_pool_size": cfg.CONF.DATABASE.sql_min_pool_size,
"sql_max_pool_size": cfg.CONF.DATABASE.sql_max_pool_size,
"sql_idle_timeout": cfg.CONF.DATABASE.sql_idle_timeout,
"sql_dbpool_enable": cfg.CONF.DATABASE.sql_dbpool_enable
}
db.configure_db(options)
self.tunnel_key = db_api_v2.TunnelKey( self.tunnel_key = db_api_v2.TunnelKey(
cfg.CONF.OVS.tunnel_key_min, cfg.CONF.OVS.tunnel_key_max) cfg.CONF.OVS.tunnel_key_min, cfg.CONF.OVS.tunnel_key_max)

View File

@ -42,8 +42,7 @@ class CiscoNetworkPluginV2TestCase(test_db_plugin.QuantumDbPluginV2TestCase):
def setUp(self): def setUp(self):
def new_init(): def new_init():
db.configure_db({'sql_connection': 'sqlite:///:memory:', db.configure_db()
'base': network_models_v2.model_base.BASEV2})
with mock.patch.object(network_db_v2, with mock.patch.object(network_db_v2,
'initialize', new=new_init): 'initialize', new=new_init):

View File

@ -53,8 +53,7 @@ class TestCiscoNexusPlugin(unittest.TestCase):
self.second_vlan_id = 265 self.second_vlan_id = 265
def new_cdb_init(): def new_cdb_init():
db.configure_db({'sql_connection': 'sqlite://', db.configure_db()
'base': network_models_v2.model_base.BASEV2})
def new_nexus_init(self): def new_nexus_init(self):
self._client = importutils.import_object(NEXUS_DRIVER) self._client = importutils.import_object(NEXUS_DRIVER)

View File

@ -80,10 +80,7 @@ class MetaQuantumPluginV2Test(unittest.TestCase):
self.fake_tenant_id = uuidutils.generate_uuid() self.fake_tenant_id = uuidutils.generate_uuid()
self.context = context.get_admin_context() self.context = context.get_admin_context()
sql_connection = 'sqlite:///:memory:' db.configure_db()
options = {"sql_connection": sql_connection}
options.update({'base': models_v2.model_base.BASEV2})
db.configure_db(options)
setup_metaplugin_conf() setup_metaplugin_conf()