Use OVN mech driver OVSDB connections for l3 plugin
It is possible to re-use the mech driver ovsdb connections in the ovn l3 plugin, saving the overhead of two db connections/in-memory copies of the db per process. Closes-Bug: #1864548 Change-Id: I022dea485f42cf76c4cec67ee43eed9a3770ec9c
This commit is contained in:
parent
230c25d209
commit
d92e71c297
|
@ -138,6 +138,16 @@ class OVNMechanismDriver(api.MechanismDriver):
|
|||
self._sb_ovn)
|
||||
return self._ovn_client_inst
|
||||
|
||||
@property
|
||||
def nb_ovn(self):
|
||||
# NOTE (twilson): This and sb_ovn can be moved to instance variables
|
||||
# once all references to the private versions are changed
|
||||
return self._nb_ovn
|
||||
|
||||
@property
|
||||
def sb_ovn(self):
|
||||
return self._sb_ovn
|
||||
|
||||
def _setup_vif_port_bindings(self):
|
||||
self.supported_vnic_types = [portbindings.VNIC_NORMAL,
|
||||
portbindings.VNIC_DIRECT]
|
||||
|
|
|
@ -37,7 +37,6 @@ from neutron.common.ovn import extensions
|
|||
from neutron.common.ovn import utils
|
||||
from neutron.db import l3_fip_port_details
|
||||
from neutron.db import ovn_revision_numbers_db as db_rev
|
||||
from neutron.plugins.ml2.drivers.ovn.mech_driver.ovsdb import impl_idl_ovn
|
||||
from neutron.plugins.ml2.drivers.ovn.mech_driver.ovsdb import ovn_client
|
||||
from neutron.scheduler import l3_ovn_scheduler
|
||||
|
||||
|
@ -68,9 +67,8 @@ class OVNL3RouterPlugin(service_base.ServicePluginBase,
|
|||
def __init__(self):
|
||||
LOG.info("Starting OVNL3RouterPlugin")
|
||||
super(OVNL3RouterPlugin, self).__init__()
|
||||
self._nb_ovn_idl = None
|
||||
self._sb_ovn_idl = None
|
||||
self._plugin_property = None
|
||||
self._mech = None
|
||||
self._ovn_client_inst = None
|
||||
self.scheduler = l3_ovn_scheduler.get_scheduler()
|
||||
self._register_precommit_callbacks()
|
||||
|
@ -92,19 +90,11 @@ class OVNL3RouterPlugin(service_base.ServicePluginBase,
|
|||
|
||||
@property
|
||||
def _ovn(self):
|
||||
if self._nb_ovn_idl is None:
|
||||
LOG.info("Getting OvsdbNbOvnIdl")
|
||||
conn = impl_idl_ovn.get_connection(impl_idl_ovn.OvsdbNbOvnIdl)
|
||||
self._nb_ovn_idl = impl_idl_ovn.OvsdbNbOvnIdl(conn)
|
||||
return self._nb_ovn_idl
|
||||
return self._plugin_driver.nb_ovn
|
||||
|
||||
@property
|
||||
def _sb_ovn(self):
|
||||
if self._sb_ovn_idl is None:
|
||||
LOG.info("Getting OvsdbSbOvnIdl")
|
||||
conn = impl_idl_ovn.get_connection(impl_idl_ovn.OvsdbSbOvnIdl)
|
||||
self._sb_ovn_idl = impl_idl_ovn.OvsdbSbOvnIdl(conn)
|
||||
return self._sb_ovn_idl
|
||||
return self._plugin_driver.sb_ovn
|
||||
|
||||
@property
|
||||
def _plugin(self):
|
||||
|
@ -112,6 +102,12 @@ class OVNL3RouterPlugin(service_base.ServicePluginBase,
|
|||
self._plugin_property = directory.get_plugin()
|
||||
return self._plugin_property
|
||||
|
||||
@property
|
||||
def _plugin_driver(self):
|
||||
if self._mech is None:
|
||||
self._mech = self._plugin.mechanism_manager.mech_drivers['ovn'].obj
|
||||
return self._mech
|
||||
|
||||
def get_plugin_type(self):
|
||||
return plugin_constants.L3
|
||||
|
||||
|
|
|
@ -312,25 +312,12 @@ class TestOVNFunctionalBase(test_plugin.Ml2PluginV2TestCase,
|
|||
|
||||
def restart(self):
|
||||
self.stop()
|
||||
# The OVN sync test starts its own synchronizers...
|
||||
self.l3_plugin._nb_ovn_idl.ovsdb_connection.stop()
|
||||
self.l3_plugin._sb_ovn_idl.ovsdb_connection.stop()
|
||||
# Stop our monitor connections
|
||||
self.nb_api.ovsdb_connection.stop()
|
||||
self.sb_api.ovsdb_connection.stop()
|
||||
|
||||
if self.ovsdb_server_mgr:
|
||||
self.ovsdb_server_mgr.stop()
|
||||
if self.ovn_northd_mgr:
|
||||
self.ovn_northd_mgr.stop()
|
||||
|
||||
self.mech_driver._nb_ovn = None
|
||||
self.mech_driver._sb_ovn = None
|
||||
self.l3_plugin._nb_ovn_idl = None
|
||||
self.l3_plugin._sb_ovn_idl = None
|
||||
self.nb_api.ovsdb_connection = None
|
||||
self.sb_api.ovsdb_connection = None
|
||||
|
||||
self.ovsdb_server_mgr.delete_dbs()
|
||||
self._start_ovsdb_server_and_idls()
|
||||
self._start_ovn_northd()
|
||||
|
|
Loading…
Reference in New Issue