diff --git a/oslo_service/_i18n.py b/oslo_service/_i18n.py new file mode 100644 index 00000000..29d2f2fe --- /dev/null +++ b/oslo_service/_i18n.py @@ -0,0 +1,33 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +"""oslo.i18n integration module. +See http://docs.openstack.org/developer/oslo.i18n/usage.html . +""" + +import oslo_i18n + + +_translators = oslo_i18n.TranslatorFactory(domain='oslo.log') + +# The primary translation function using the well-known name "_" +_ = _translators.primary + +# Translators for log levels. +# +# The abbreviated names are meant to reflect the usual use of a short +# name like '_'. The "L" is for "log" and the other letter comes from +# the level. +_LI = _translators.log_info +_LW = _translators.log_warning +_LE = _translators.log_error +_LC = _translators.log_critical diff --git a/oslo_service/eventlet_backdoor.py b/oslo_service/eventlet_backdoor.py index 7d606e21..b9f0281e 100644 --- a/oslo_service/eventlet_backdoor.py +++ b/oslo_service/eventlet_backdoor.py @@ -30,7 +30,7 @@ import eventlet.backdoor import greenlet from oslo_config import cfg -from openstack.common._i18n import _LI +from oslo_service._i18n import _LI help_for_backdoor_port = ( "Acceptable values are 0, , and :, where 0 results " diff --git a/oslo_service/loopingcall.py b/oslo_service/loopingcall.py index 2bc9a4c9..772ac926 100644 --- a/oslo_service/loopingcall.py +++ b/oslo_service/loopingcall.py @@ -22,7 +22,7 @@ import time from eventlet import event from eventlet import greenthread -from openstack.common._i18n import _LE, _LW +from oslo_service._i18n import _LE, _LW LOG = logging.getLogger(__name__) diff --git a/oslo_service/periodic_task.py b/oslo_service/periodic_task.py index 3d4d38b2..d58a8c74 100644 --- a/oslo_service/periodic_task.py +++ b/oslo_service/periodic_task.py @@ -19,7 +19,7 @@ import time from oslo_config import cfg import six -from openstack.common._i18n import _, _LE, _LI +from oslo_service._i18n import _, _LE, _LI periodic_opts = [ diff --git a/oslo_service/service.py b/oslo_service/service.py index 92228b85..ffb20f30 100644 --- a/oslo_service/service.py +++ b/oslo_service/service.py @@ -30,10 +30,10 @@ import eventlet from eventlet import event from oslo_config import cfg -from openstack.common import eventlet_backdoor -from openstack.common._i18n import _LE, _LI, _LW -from openstack.common import systemd -from openstack.common import threadgroup +from oslo_service import eventlet_backdoor +from oslo_service._i18n import _LE, _LI, _LW +from oslo_service import systemd +from oslo_service import threadgroup CONF = cfg.CONF diff --git a/oslo_service/sslutils.py b/oslo_service/sslutils.py index 9ff8543a..2f7a0abe 100644 --- a/oslo_service/sslutils.py +++ b/oslo_service/sslutils.py @@ -18,7 +18,7 @@ import ssl from oslo_config import cfg -from openstack.common._i18n import _ +from oslo_service._i18n import _ ssl_opts = [ diff --git a/oslo_service/tests/eventlet_service.py b/oslo_service/tests/eventlet_service.py index 074c0480..3706e718 100644 --- a/oslo_service/tests/eventlet_service.py +++ b/oslo_service/tests/eventlet_service.py @@ -23,7 +23,7 @@ import greenlet from oslo_config import cfg -from openstack.common import service +from oslo_service import service CONF = cfg.CONF diff --git a/oslo_service/tests/test_eventlet_backdoor.py b/oslo_service/tests/test_eventlet_backdoor.py index cca59619..34e3d53c 100644 --- a/oslo_service/tests/test_eventlet_backdoor.py +++ b/oslo_service/tests/test_eventlet_backdoor.py @@ -25,7 +25,7 @@ from oslo_config import fixture as config from oslotest import base as test_base from oslotest import moxstubout -from openstack.common import eventlet_backdoor +from oslo_service import eventlet_backdoor class BackdoorPortTest(test_base.BaseTestCase): diff --git a/oslo_service/tests/test_loopingcall.py b/oslo_service/tests/test_loopingcall.py index 81f2d815..6d05f653 100644 --- a/oslo_service/tests/test_loopingcall.py +++ b/oslo_service/tests/test_loopingcall.py @@ -18,7 +18,7 @@ from eventlet import greenthread from mox3 import mox from oslotest import base as test_base -from openstack.common import loopingcall +from oslo_service import loopingcall class LoopingCallTestCase(test_base.BaseTestCase): diff --git a/oslo_service/tests/test_periodic.py b/oslo_service/tests/test_periodic.py index 59edc342..856694f9 100644 --- a/oslo_service/tests/test_periodic.py +++ b/oslo_service/tests/test_periodic.py @@ -23,7 +23,7 @@ from oslo_config import fixture as config from oslotest import base as test_base from testtools import matchers -from openstack.common import periodic_task +from oslo_service import periodic_task class AnException(Exception): diff --git a/oslo_service/tests/test_service.py b/oslo_service/tests/test_service.py index 9e3f7d9e..fe6425c7 100644 --- a/oslo_service/tests/test_service.py +++ b/oslo_service/tests/test_service.py @@ -42,8 +42,8 @@ from oslotest import base as test_base from oslotest import moxstubout from six.moves import queue -from openstack.common import eventlet_backdoor -from openstack.common import service +from oslo_service import eventlet_backdoor +from oslo_service import service LOG = logging.getLogger(__name__) @@ -355,7 +355,7 @@ class LauncherTest(test_base.BaseTestCase): # unit test fixtures in nova bug #1199315) launcher.stop() - @mock.patch('oslo_service.ServiceLauncher.launch_service') + @mock.patch('oslo_service.service.ServiceLauncher.launch_service') def _test_launch_single(self, workers, mock_launch): svc = service.Service() service.launch(svc, workers=workers) @@ -367,7 +367,7 @@ class LauncherTest(test_base.BaseTestCase): def test_launch_one_worker(self): self._test_launch_single(1) - @mock.patch('oslo_service.ProcessLauncher.launch_service') + @mock.patch('oslo_service.service.ProcessLauncher.launch_service') def test_multiple_worker(self, mock_launch): svc = service.Service() service.launch(svc, workers=3) @@ -383,7 +383,7 @@ class ProcessLauncherTest(test_base.BaseTestCase): self.assertTrue(launcher.running) launcher.children = [22, 222] - with mock.patch('oslo_service.os.kill') as mock_kill: + with mock.patch('oslo_service.service.os.kill') as mock_kill: with mock.patch.object(launcher, '_wait_child') as _wait_child: _wait_child.side_effect = lambda: launcher.children.pop() launcher.stop() @@ -395,7 +395,7 @@ class ProcessLauncherTest(test_base.BaseTestCase): mock_kill.mock_calls) @mock.patch( - "oslo_service.ProcessLauncher._signal_handlers_set", + "oslo_service.service.ProcessLauncher._signal_handlers_set", new_callable=lambda: set()) def test__signal_handlers_set(self, signal_handlers_set_mock): callables = set() @@ -409,7 +409,7 @@ class ProcessLauncherTest(test_base.BaseTestCase): service.ProcessLauncher._signal_handlers_set) @mock.patch( - "oslo_service.ProcessLauncher._signal_handlers_set", + "oslo_service.service.ProcessLauncher._signal_handlers_set", new_callable=lambda: set()) def test__handle_class_signals(self, signal_handlers_set_mock): signal_handlers_set_mock.update([mock.Mock(), mock.Mock()]) @@ -418,13 +418,13 @@ class ProcessLauncherTest(test_base.BaseTestCase): m.assert_called_once_with() @mock.patch("os.kill") - @mock.patch("oslo_service.ProcessLauncher.stop") - @mock.patch("oslo_service.ProcessLauncher._respawn_children") - @mock.patch("oslo_service.ProcessLauncher.handle_signal") + @mock.patch("oslo_service.service.ProcessLauncher.stop") + @mock.patch("oslo_service.service.ProcessLauncher._respawn_children") + @mock.patch("oslo_service.service.ProcessLauncher.handle_signal") @mock.patch("oslo_config.cfg.CONF.log_opt_values") - @mock.patch("openstack.common.systemd.notify_once") + @mock.patch("oslo_service.systemd.notify_once") @mock.patch("oslo_config.cfg.CONF.reload_config_files") - @mock.patch("oslo_service._is_sighup_and_daemon") + @mock.patch("oslo_service.service._is_sighup_and_daemon") def test_parent_process_reload_config(self, is_sighup_and_daemon_mock, reload_config_files_mock, diff --git a/oslo_service/tests/test_systemd.py b/oslo_service/tests/test_systemd.py index 902324df..ecbafe37 100644 --- a/oslo_service/tests/test_systemd.py +++ b/oslo_service/tests/test_systemd.py @@ -18,7 +18,7 @@ import socket from oslotest import base as test_base from oslotest import moxstubout -from openstack.common import systemd +from oslo_service import systemd class SystemdTestCase(test_base.BaseTestCase): diff --git a/oslo_service/tests/test_threadgroup.py b/oslo_service/tests/test_threadgroup.py index f2e8cf9e..b88d9863 100644 --- a/oslo_service/tests/test_threadgroup.py +++ b/oslo_service/tests/test_threadgroup.py @@ -21,7 +21,7 @@ import time from oslotest import base as test_base -from openstack.common import threadgroup +from oslo_service import threadgroup class ThreadGroupTestCase(test_base.BaseTestCase): diff --git a/oslo_service/threadgroup.py b/oslo_service/threadgroup.py index 5db1f5aa..315df303 100644 --- a/oslo_service/threadgroup.py +++ b/oslo_service/threadgroup.py @@ -17,8 +17,8 @@ import threading import eventlet from eventlet import greenpool -from openstack.common._i18n import _LE -from openstack.common import loopingcall +from oslo_service._i18n import _LE +from oslo_service import loopingcall LOG = logging.getLogger(__name__) diff --git a/requirements.txt b/requirements.txt index 614c804e..9e6ac43a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,3 +3,6 @@ # process, which may cause wedges in the gate later. Babel>=0.9.6 +eventlet>=0.17.3 +oslo.config>=1.11.0 # Apache-2.0 +oslo.i18n>=1.5.0 # Apache-2.0