Merge "Sync with oslo-incubator"
This commit is contained in:
commit
bf050c6931
|
@ -40,6 +40,6 @@ try:
|
|||
_LC = _translators.log_critical
|
||||
except ImportError:
|
||||
# NOTE(dims): Support for cases where a project wants to use
|
||||
# code from keystone-incubator, but is not ready to be internationalized
|
||||
# code from oslo-incubator, but is not ready to be internationalized
|
||||
# (like tempest)
|
||||
_ = _LI = _LW = _LE = _LC = lambda x: x
|
||||
|
|
|
@ -19,19 +19,18 @@ from __future__ import print_function
|
|||
import copy
|
||||
import errno
|
||||
import gc
|
||||
import logging
|
||||
import os
|
||||
import pprint
|
||||
import socket
|
||||
import sys
|
||||
import traceback
|
||||
|
||||
import eventlet
|
||||
import eventlet.backdoor
|
||||
import greenlet
|
||||
from oslo.config import cfg
|
||||
|
||||
from keystone.openstack.common._i18n import _LI
|
||||
from keystone.openstack.common import log as logging
|
||||
|
||||
help_for_backdoor_port = (
|
||||
"Acceptable values are 0, <port>, and <start>:<end>, where 0 results "
|
||||
|
|
|
@ -17,6 +17,7 @@ import contextlib
|
|||
import errno
|
||||
import logging
|
||||
import os
|
||||
import stat
|
||||
import tempfile
|
||||
|
||||
from oslo.utils import excutils
|
||||
|
@ -24,15 +25,17 @@ from oslo.utils import excutils
|
|||
LOG = logging.getLogger(__name__)
|
||||
|
||||
_FILE_CACHE = {}
|
||||
DEFAULT_MODE = stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO
|
||||
|
||||
|
||||
def ensure_tree(path):
|
||||
def ensure_tree(path, mode=DEFAULT_MODE):
|
||||
"""Create a directory (and any ancestor directories required)
|
||||
|
||||
:param path: Directory to create
|
||||
:param mode: Directory creation permissions
|
||||
"""
|
||||
try:
|
||||
os.makedirs(path)
|
||||
os.makedirs(path, mode)
|
||||
except OSError as exc:
|
||||
if exc.errno == errno.EEXIST:
|
||||
if not os.path.isdir(path):
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import logging
|
||||
import sys
|
||||
import time
|
||||
|
||||
|
@ -22,7 +23,6 @@ from eventlet import event
|
|||
from eventlet import greenthread
|
||||
|
||||
from keystone.openstack.common._i18n import _LE, _LW
|
||||
from keystone.openstack.common import log as logging
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
@ -84,9 +84,9 @@ class FixedIntervalLoopingCall(LoopingCallBase):
|
|||
break
|
||||
delay = end - start - interval
|
||||
if delay > 0:
|
||||
LOG.warn(_LW('task %(func_name)s run outlasted '
|
||||
LOG.warn(_LW('task %(func_name)r run outlasted '
|
||||
'interval by %(delay).2f sec'),
|
||||
{'func_name': repr(self.f), 'delay': delay})
|
||||
{'func_name': self.f, 'delay': delay})
|
||||
greenthread.sleep(-delay if delay < 0 else 0)
|
||||
except LoopingCallDone as e:
|
||||
self.stop()
|
||||
|
@ -127,9 +127,9 @@ class DynamicLoopingCall(LoopingCallBase):
|
|||
|
||||
if periodic_interval_max is not None:
|
||||
idle = min(idle, periodic_interval_max)
|
||||
LOG.debug('Dynamic looping call %(func_name)s sleeping '
|
||||
LOG.debug('Dynamic looping call %(func_name)r sleeping '
|
||||
'for %(idle).02f seconds',
|
||||
{'func_name': repr(self.f), 'idle': idle})
|
||||
{'func_name': self.f, 'idle': idle})
|
||||
greenthread.sleep(idle)
|
||||
except LoopingCallDone as e:
|
||||
self.stop()
|
||||
|
|
|
@ -91,6 +91,7 @@ as it allows particular rules to be explicitly disabled.
|
|||
import abc
|
||||
import ast
|
||||
import copy
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
|
||||
|
@ -102,7 +103,6 @@ import six.moves.urllib.request as urlrequest
|
|||
|
||||
from keystone.openstack.common import fileutils
|
||||
from keystone.openstack.common._i18n import _, _LE, _LI
|
||||
from keystone.openstack.common import log as logging
|
||||
|
||||
|
||||
policy_opts = [
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
"""Generic Node base class for all workers that run on hosts."""
|
||||
|
||||
import errno
|
||||
import logging as std_logging
|
||||
import logging
|
||||
import os
|
||||
import random
|
||||
import signal
|
||||
|
@ -39,7 +39,6 @@ from oslo.config import cfg
|
|||
|
||||
from keystone.openstack.common import eventlet_backdoor
|
||||
from keystone.openstack.common._i18n import _LE, _LI, _LW
|
||||
from keystone.openstack.common import log as logging
|
||||
from keystone.openstack.common import systemd
|
||||
from keystone.openstack.common import threadgroup
|
||||
|
||||
|
@ -163,7 +162,7 @@ class ServiceLauncher(Launcher):
|
|||
signo = 0
|
||||
|
||||
LOG.debug('Full set of CONF:')
|
||||
CONF.log_opt_values(LOG, std_logging.DEBUG)
|
||||
CONF.log_opt_values(LOG, logging.DEBUG)
|
||||
|
||||
try:
|
||||
if ready_callback:
|
||||
|
@ -377,7 +376,7 @@ class ProcessLauncher(object):
|
|||
|
||||
systemd.notify_once()
|
||||
LOG.debug('Full set of CONF:')
|
||||
CONF.log_opt_values(LOG, std_logging.DEBUG)
|
||||
CONF.log_opt_values(LOG, logging.DEBUG)
|
||||
|
||||
try:
|
||||
while True:
|
||||
|
@ -397,7 +396,7 @@ class ProcessLauncher(object):
|
|||
self.running = True
|
||||
self.sigcaught = None
|
||||
except eventlet.greenlet.GreenletExit:
|
||||
LOG.info(_LI("Wait called after thread killed. Cleaning up."))
|
||||
LOG.info(_LI("Wait called after thread killed. Cleaning up."))
|
||||
|
||||
self.stop()
|
||||
|
||||
|
@ -434,8 +433,8 @@ class Service(object):
|
|||
def start(self):
|
||||
pass
|
||||
|
||||
def stop(self):
|
||||
self.tg.stop()
|
||||
def stop(self, graceful=False):
|
||||
self.tg.stop(graceful)
|
||||
self.tg.wait()
|
||||
# Signal that service cleanup is done:
|
||||
if not self._done.ready():
|
||||
|
|
|
@ -16,12 +16,11 @@
|
|||
Helper module for systemd service readiness notification.
|
||||
"""
|
||||
|
||||
import logging
|
||||
import os
|
||||
import socket
|
||||
import sys
|
||||
|
||||
from keystone.openstack.common import log as logging
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
|
|
@ -11,12 +11,12 @@
|
|||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import logging
|
||||
import threading
|
||||
|
||||
import eventlet
|
||||
from eventlet import greenpool
|
||||
|
||||
from keystone.openstack.common import log as logging
|
||||
from keystone.openstack.common import loopingcall
|
||||
|
||||
|
||||
|
|
|
@ -19,15 +19,24 @@ Helpers for comparing version strings.
|
|||
|
||||
import functools
|
||||
import inspect
|
||||
import logging
|
||||
|
||||
from oslo.config import cfg
|
||||
import pkg_resources
|
||||
import six
|
||||
|
||||
from keystone.openstack.common._i18n import _
|
||||
from keystone.openstack.common import log as logging
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
CONF = cfg.CONF
|
||||
|
||||
|
||||
opts = [
|
||||
cfg.BoolOpt('fatal_deprecations',
|
||||
default=False,
|
||||
help='Enables or disables fatal status of deprecations.'),
|
||||
]
|
||||
|
||||
|
||||
class deprecated(object):
|
||||
|
@ -127,7 +136,7 @@ class deprecated(object):
|
|||
|
||||
@six.wraps(func_or_cls)
|
||||
def wrapped(*args, **kwargs):
|
||||
LOG.deprecated(msg, details)
|
||||
report_deprecated_feature(LOG, msg, details)
|
||||
return func_or_cls(*args, **kwargs)
|
||||
return wrapped
|
||||
elif inspect.isclass(func_or_cls):
|
||||
|
@ -136,10 +145,10 @@ class deprecated(object):
|
|||
# TODO(tsufiev): change `functools` module to `six` as
|
||||
# soon as six 1.7.4 (with fix for passing `assigned`
|
||||
# argument to underlying `functools.wraps`) is released
|
||||
# and added to the keystone-incubator requrements
|
||||
# and added to the oslo-incubator requrements
|
||||
@functools.wraps(orig_init, assigned=('__name__', '__doc__'))
|
||||
def new_init(self, *args, **kwargs):
|
||||
LOG.deprecated(msg, details)
|
||||
report_deprecated_feature(LOG, msg, details)
|
||||
orig_init(self, *args, **kwargs)
|
||||
func_or_cls.__init__ = new_init
|
||||
return func_or_cls
|
||||
|
@ -201,3 +210,44 @@ def is_compatible(requested_version, current_version, same_major=True):
|
|||
return False
|
||||
|
||||
return current_parts >= requested_parts
|
||||
|
||||
|
||||
# Track the messages we have sent already. See
|
||||
# report_deprecated_feature().
|
||||
_deprecated_messages_sent = {}
|
||||
|
||||
|
||||
def report_deprecated_feature(logger, msg, *args, **kwargs):
|
||||
"""Call this function when a deprecated feature is used.
|
||||
|
||||
If the system is configured for fatal deprecations then the message
|
||||
is logged at the 'critical' level and :class:`DeprecatedConfig` will
|
||||
be raised.
|
||||
|
||||
Otherwise, the message will be logged (once) at the 'warn' level.
|
||||
|
||||
:raises: :class:`DeprecatedConfig` if the system is configured for
|
||||
fatal deprecations.
|
||||
"""
|
||||
stdmsg = _("Deprecated: %s") % msg
|
||||
CONF.register_opts(opts)
|
||||
if CONF.fatal_deprecations:
|
||||
logger.critical(stdmsg, *args, **kwargs)
|
||||
raise DeprecatedConfig(msg=stdmsg)
|
||||
|
||||
# Using a list because a tuple with dict can't be stored in a set.
|
||||
sent_args = _deprecated_messages_sent.setdefault(msg, list())
|
||||
|
||||
if args in sent_args:
|
||||
# Already logged this message, so don't log it again.
|
||||
return
|
||||
|
||||
sent_args.append(args)
|
||||
logger.warn(stdmsg, *args, **kwargs)
|
||||
|
||||
|
||||
class DeprecatedConfig(Exception):
|
||||
message = _("Fatal call to deprecated config: %(msg)s")
|
||||
|
||||
def __init__(self, msg):
|
||||
super(Exception, self).__init__(self.message % dict(msg=msg))
|
||||
|
|
|
@ -28,7 +28,7 @@ from keystone.common import sql
|
|||
from keystone import config
|
||||
from keystone import exception
|
||||
from keystone.identity.backends import sql as identity_sql
|
||||
from keystone.openstack.common import log as logging
|
||||
from keystone.openstack.common import versionutils
|
||||
from keystone import tests
|
||||
from keystone.tests import default_fixtures
|
||||
from keystone.tests.ksfixtures import database
|
||||
|
@ -839,7 +839,7 @@ class DeprecatedDecorators(SqlTests):
|
|||
role_ref = {
|
||||
'id': uuid.uuid4().hex,
|
||||
'name': uuid.uuid4().hex}
|
||||
self.assertRaises(logging.DeprecatedConfig,
|
||||
self.assertRaises(versionutils.DeprecatedConfig,
|
||||
self.assignment_api.create_role,
|
||||
role_ref['id'], role_ref)
|
||||
|
||||
|
@ -871,6 +871,6 @@ class DeprecatedDecorators(SqlTests):
|
|||
'id': uuid.uuid4().hex,
|
||||
'name': uuid.uuid4().hex,
|
||||
'domain_id': DEFAULT_DOMAIN_ID}
|
||||
self.assertRaises(logging.DeprecatedConfig,
|
||||
self.assertRaises(versionutils.DeprecatedConfig,
|
||||
self.assignment_api.create_project,
|
||||
project_ref['id'], project_ref)
|
||||
|
|
Loading…
Reference in New Issue