diff --git a/neutron/plugins/ml2/drivers/ovn/mech_driver/mech_driver.py b/neutron/plugins/ml2/drivers/ovn/mech_driver/mech_driver.py index 9437fdf6658..115bb1bd9b8 100644 --- a/neutron/plugins/ml2/drivers/ovn/mech_driver/mech_driver.py +++ b/neutron/plugins/ml2/drivers/ovn/mech_driver/mech_driver.py @@ -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] diff --git a/neutron/services/ovn_l3/plugin.py b/neutron/services/ovn_l3/plugin.py index e91d1230452..bca3be8abdf 100644 --- a/neutron/services/ovn_l3/plugin.py +++ b/neutron/services/ovn_l3/plugin.py @@ -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 diff --git a/neutron/tests/functional/base.py b/neutron/tests/functional/base.py index bd5ec5ec700..3e408b7a66f 100644 --- a/neutron/tests/functional/base.py +++ b/neutron/tests/functional/base.py @@ -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()