summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorReedip <rbanerje@redhat.com>2018-12-13 07:17:27 +0000
committerReedip <rbanerje@redhat.com>2018-12-13 07:40:03 +0000
commit41fa7e8a80151924d0437433121792b5a9c88b87 (patch)
tree2a5c57c96a648c9b2436874c301f030575747ce0
parentcfdd81c6375f445116f56e656a042916db513df9 (diff)
Migrate OvnWorker to a separate location
This patch migrates OvnWorker to a separate plugin file, so that importing ovsdb_monitor in any other process( like Octavia ) does not cause any duplicate configuration issues. Change-Id: I16a7f9971f4e429512e959f36ac745c98010b2a0
Notes
Notes (review): Code-Review+2: Lucas Alvares Gomes <lucasagomes@gmail.com> Code-Review+2: Numan Siddique <nusiddiq@redhat.com> Workflow+1: Numan Siddique <nusiddiq@redhat.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Wed, 16 Jan 2019 23:28:56 +0000 Reviewed-on: https://review.openstack.org/624872 Project: openstack/networking-ovn Branch: refs/heads/master
-rw-r--r--doc/source/contributor/design/ovn_worker.rst2
-rw-r--r--networking_ovn/ml2/mech_driver.py6
-rw-r--r--networking_ovn/ovsdb/impl_idl_ovn.py3
-rw-r--r--networking_ovn/ovsdb/ovsdb_monitor.py22
-rw-r--r--networking_ovn/ovsdb/worker.py36
-rw-r--r--networking_ovn/tests/functional/base.py3
6 files changed, 44 insertions, 28 deletions
diff --git a/doc/source/contributor/design/ovn_worker.rst b/doc/source/contributor/design/ovn_worker.rst
index 17cbabf..1e4be38 100644
--- a/doc/source/contributor/design/ovn_worker.rst
+++ b/doc/source/contributor/design/ovn_worker.rst
@@ -10,7 +10,7 @@ port's status to 'ACTIVE' or 'DOWN' in the db, it needs to monitor the
10OVN Northbound db. A neutron worker is created for this purpose. 10OVN Northbound db. A neutron worker is created for this purpose.
11 11
12The implementation of the ovn worker can be found here - 12The implementation of the ovn worker can be found here -
13'networking_ovn.ovsdb.ovsdb_monitor.OvnWorker'. 13'networking_ovn.ovsdb.worker.OvnWorker'.
14 14
15Neutron service will create 'n' api workers and 'm' rpc workers and 1 ovn 15Neutron service will create 'n' api workers and 'm' rpc workers and 1 ovn
16worker (all these workers are separate processes). 16worker (all these workers are separate processes).
diff --git a/networking_ovn/ml2/mech_driver.py b/networking_ovn/ml2/mech_driver.py
index eb1a359..6702c6d 100644
--- a/networking_ovn/ml2/mech_driver.py
+++ b/networking_ovn/ml2/mech_driver.py
@@ -52,7 +52,7 @@ from networking_ovn.ml2 import qos_driver
52from networking_ovn.ml2 import trunk_driver 52from networking_ovn.ml2 import trunk_driver
53from networking_ovn import ovn_db_sync 53from networking_ovn import ovn_db_sync
54from networking_ovn.ovsdb import impl_idl_ovn 54from networking_ovn.ovsdb import impl_idl_ovn
55from networking_ovn.ovsdb import ovsdb_monitor 55from networking_ovn.ovsdb import worker
56 56
57 57
58LOG = log.getLogger(__name__) 58LOG = log.getLogger(__name__)
@@ -193,7 +193,7 @@ class OVNMechanismDriver(api.MechanismDriver):
193 # Now IDL connections can be safely used. 193 # Now IDL connections can be safely used.
194 self._post_fork_event.set() 194 self._post_fork_event.set()
195 195
196 if utils.get_method_class(trigger) == ovsdb_monitor.OvnWorker: 196 if utils.get_method_class(trigger) == worker.OvnWorker:
197 # Call the synchronization task if its ovn worker 197 # Call the synchronization task if its ovn worker
198 # This sync neutron DB to OVN-NB DB only in inconsistent states 198 # This sync neutron DB to OVN-NB DB only in inconsistent states
199 self.nb_synchronizer = ovn_db_sync.OvnNbSynchronizer( 199 self.nb_synchronizer = ovn_db_sync.OvnNbSynchronizer(
@@ -695,7 +695,7 @@ class OVNMechanismDriver(api.MechanismDriver):
695 workers, can return a sequence of worker instances. 695 workers, can return a sequence of worker instances.
696 """ 696 """
697 # See doc/source/design/ovn_worker.rst for more details. 697 # See doc/source/design/ovn_worker.rst for more details.
698 return [ovsdb_monitor.OvnWorker(), maintenance.MaintenanceWorker()] 698 return [worker.OvnWorker(), maintenance.MaintenanceWorker()]
699 699
700 def _update_subport_host_if_needed(self, port_id): 700 def _update_subport_host_if_needed(self, port_id):
701 parent_port = self._ovn_client.get_parent_port(port_id) 701 parent_port = self._ovn_client.get_parent_port(port_id)
diff --git a/networking_ovn/ovsdb/impl_idl_ovn.py b/networking_ovn/ovsdb/impl_idl_ovn.py
index 168057d..c7c6188 100644
--- a/networking_ovn/ovsdb/impl_idl_ovn.py
+++ b/networking_ovn/ovsdb/impl_idl_ovn.py
@@ -34,6 +34,7 @@ from networking_ovn.common import exceptions as ovn_exc
34from networking_ovn.common import utils 34from networking_ovn.common import utils
35from networking_ovn.ovsdb import commands as cmd 35from networking_ovn.ovsdb import commands as cmd
36from networking_ovn.ovsdb import ovsdb_monitor 36from networking_ovn.ovsdb import ovsdb_monitor
37from networking_ovn.ovsdb import worker
37 38
38 39
39LOG = log.getLogger(__name__) 40LOG = log.getLogger(__name__)
@@ -135,7 +136,7 @@ def get_connection(db_class, trigger=None, driver=None):
135 args = (cfg.get_ovn_sb_connection(), 'OVN_Southbound') 136 args = (cfg.get_ovn_sb_connection(), 'OVN_Southbound')
136 cls = ovsdb_monitor.OvnSbIdl 137 cls = ovsdb_monitor.OvnSbIdl
137 138
138 if trigger and utils.get_method_class(trigger) == ovsdb_monitor.OvnWorker: 139 if trigger and utils.get_method_class(trigger) == worker.OvnWorker:
139 idl_ = cls.from_server(*args, driver=driver) 140 idl_ = cls.from_server(*args, driver=driver)
140 else: 141 else:
141 if db_class == OvsdbSbOvnIdl: 142 if db_class == OvsdbSbOvnIdl:
diff --git a/networking_ovn/ovsdb/ovsdb_monitor.py b/networking_ovn/ovsdb/ovsdb_monitor.py
index eb99b14..8c3b013 100644
--- a/networking_ovn/ovsdb/ovsdb_monitor.py
+++ b/networking_ovn/ovsdb/ovsdb_monitor.py
@@ -12,11 +12,9 @@
12# License for the specific language governing permissions and limitations 12# License for the specific language governing permissions and limitations
13# under the License. 13# under the License.
14 14
15from neutron.common import config
16from neutron_lib.plugins import constants 15from neutron_lib.plugins import constants
17from neutron_lib.plugins import directory 16from neutron_lib.plugins import directory
18from neutron_lib.utils import helpers 17from neutron_lib.utils import helpers
19from neutron_lib import worker
20from oslo_log import log 18from oslo_log import log
21from ovs.stream import Stream 19from ovs.stream import Stream
22from ovsdbapp.backend.ovs_idl import connection 20from ovsdbapp.backend.ovs_idl import connection
@@ -383,23 +381,3 @@ def _check_and_set_ssl_files(schema_name):
383 381
384 if ca_cert_file: 382 if ca_cert_file:
385 Stream.ssl_set_ca_cert_file(ca_cert_file) 383 Stream.ssl_set_ca_cert_file(ca_cert_file)
386
387
388class OvnWorker(worker.BaseWorker):
389 def start(self):
390 super(OvnWorker, self).start()
391 # NOTE(twilson) The super class will trigger the post_fork_initialize
392 # in the driver, which starts the connection/IDL notify loop which
393 # keeps the process from exiting
394
395 def stop(self):
396 """Stop service."""
397 # TODO(numans)
398
399 def wait(self):
400 """Wait for service to complete."""
401 # TODO(numans)
402
403 @staticmethod
404 def reset():
405 config.reset_service()
diff --git a/networking_ovn/ovsdb/worker.py b/networking_ovn/ovsdb/worker.py
new file mode 100644
index 0000000..4a335ef
--- /dev/null
+++ b/networking_ovn/ovsdb/worker.py
@@ -0,0 +1,36 @@
1# Copyright 2016 Red Hat, Inc.
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may
4# not use this file except in compliance with the License. You may obtain
5# a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations
13# under the License.
14
15from neutron.common import config
16from neutron_lib import worker
17
18
19class OvnWorker(worker.BaseWorker):
20 def start(self):
21 super(OvnWorker, self).start()
22 # NOTE(twilson) The super class will trigger the post_fork_initialize
23 # in the driver, which starts the connection/IDL notify loop which
24 # keeps the process from exiting
25
26 def stop(self):
27 """Stop service."""
28 # TODO(numans)
29
30 def wait(self):
31 """Wait for service to complete."""
32 # TODO(numans)
33
34 @staticmethod
35 def reset():
36 config.reset_service()
diff --git a/networking_ovn/tests/functional/base.py b/networking_ovn/tests/functional/base.py
index 0342cac..5e8d910 100644
--- a/networking_ovn/tests/functional/base.py
+++ b/networking_ovn/tests/functional/base.py
@@ -33,6 +33,7 @@ from ovsdbapp.backend.ovs_idl import connection
33from networking_ovn.db import models # noqa 33from networking_ovn.db import models # noqa
34from networking_ovn.ovsdb import impl_idl_ovn 34from networking_ovn.ovsdb import impl_idl_ovn
35from networking_ovn.ovsdb import ovsdb_monitor 35from networking_ovn.ovsdb import ovsdb_monitor
36from networking_ovn.ovsdb import worker
36from networking_ovn.tests import base 37from networking_ovn.tests import base
37from networking_ovn.tests.functional.resources import process 38from networking_ovn.tests.functional.resources import process
38 39
@@ -210,7 +211,7 @@ class TestOVNFunctionalBase(test_plugin.Ml2PluginV2TestCase):
210 211
211 trigger_cls = TriggerCls() 212 trigger_cls = TriggerCls()
212 if self.ovn_worker: 213 if self.ovn_worker:
213 trigger_cls.trigger.__self__.__class__ = ovsdb_monitor.OvnWorker 214 trigger_cls.trigger.__self__.__class__ = worker.OvnWorker
214 cfg.CONF.set_override('neutron_sync_mode', 'off', 'ovn') 215 cfg.CONF.set_override('neutron_sync_mode', 'off', 'ovn')
215 216
216 self.addCleanup(self.stop) 217 self.addCleanup(self.stop)