summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2017-06-16 15:36:08 +0000
committerGerrit Code Review <review@openstack.org>2017-06-16 15:36:08 +0000
commit5a1de1be7dc0a1f29582a76c3098da3a3f56ea6f (patch)
treed005cbb47531b960639787b658a7e8454d3acad4
parent243c742f4e316195c18706fb939392f933330675 (diff)
parent7cae827b6b18f55fdfb3868c973f92c709df253e (diff)
Merge "replace WorkerSupportServiceMixin with neutron-lib's WorkerBase"
-rw-r--r--neutron/db/l3_db.py3
-rw-r--r--neutron/neutron_plugin_base_v2.py5
-rw-r--r--neutron/worker.py33
3 files changed, 4 insertions, 37 deletions
diff --git a/neutron/db/l3_db.py b/neutron/db/l3_db.py
index e53ba24..1969803 100644
--- a/neutron/db/l3_db.py
+++ b/neutron/db/l3_db.py
@@ -27,6 +27,7 @@ from neutron_lib import constants
27from neutron_lib import context as n_ctx 27from neutron_lib import context as n_ctx
28from neutron_lib import exceptions as n_exc 28from neutron_lib import exceptions as n_exc
29from neutron_lib.plugins import directory 29from neutron_lib.plugins import directory
30from neutron_lib.services import base as base_services
30from oslo_log import log as logging 31from oslo_log import log as logging
31from oslo_utils import uuidutils 32from oslo_utils import uuidutils
32import six 33import six
@@ -70,7 +71,7 @@ CORE_ROUTER_ATTRS = ('id', 'name', 'tenant_id', 'admin_state_up', 'status')
70 71
71@registry.has_registry_receivers 72@registry.has_registry_receivers
72class L3_NAT_dbonly_mixin(l3.RouterPluginBase, 73class L3_NAT_dbonly_mixin(l3.RouterPluginBase,
73 neutron_worker.WorkerSupportServiceMixin, 74 base_services.WorkerBase,
74 st_attr.StandardAttrDescriptionMixin): 75 st_attr.StandardAttrDescriptionMixin):
75 """Mixin class to add L3/NAT router methods to db_base_plugin_v2.""" 76 """Mixin class to add L3/NAT router methods to db_base_plugin_v2."""
76 77
diff --git a/neutron/neutron_plugin_base_v2.py b/neutron/neutron_plugin_base_v2.py
index 513890f..58cd83c 100644
--- a/neutron/neutron_plugin_base_v2.py
+++ b/neutron/neutron_plugin_base_v2.py
@@ -22,13 +22,12 @@ methods that needs to be implemented by a v2 Neutron Plug-in.
22 22
23import abc 23import abc
24 24
25from neutron_lib.services import base as base_services
25import six 26import six
26 27
27from neutron import worker as neutron_worker
28
29 28
30@six.add_metaclass(abc.ABCMeta) 29@six.add_metaclass(abc.ABCMeta)
31class NeutronPluginBaseV2(neutron_worker.WorkerSupportServiceMixin): 30class NeutronPluginBaseV2(base_services.WorkerBase):
32 31
33 @abc.abstractmethod 32 @abc.abstractmethod
34 def create_subnet(self, context, subnet): 33 def create_subnet(self, context, subnet):
diff --git a/neutron/worker.py b/neutron/worker.py
index 97693da..6d80835 100644
--- a/neutron/worker.py
+++ b/neutron/worker.py
@@ -14,39 +14,6 @@ from neutron_lib import worker
14from oslo_service import loopingcall 14from oslo_service import loopingcall
15 15
16 16
17class WorkerSupportServiceMixin(object):
18
19 @property
20 def _workers(self):
21 try:
22 return self.__workers
23 except AttributeError:
24 self.__workers = []
25 return self.__workers
26
27 def get_workers(self):
28 """Returns a collection neutron_lib.worker.BaseWorker instances
29 needed by this service
30 """
31 return list(self._workers)
32
33 def add_worker(self, worker):
34 """Adds neutron_lib.worker.BaseWorker needed for this service
35
36 If a object needs to define workers thread/processes outside of API/RPC
37 workers then it will call this method to register worker. Should be
38 called on initialization stage before running services
39 """
40 self._workers.append(worker)
41
42 def add_workers(self, workers):
43 """Adds neutron_lib.worker.BaseWorker list needed for this service
44
45 The same as add_worker but adds a list of workers
46 """
47 self._workers.extend(workers)
48
49
50class PeriodicWorker(worker.BaseWorker): 17class PeriodicWorker(worker.BaseWorker):
51 """A worker that runs a function at a fixed interval.""" 18 """A worker that runs a function at a fixed interval."""
52 19