Sync with OS-Common 3d6c2368a5de16d875341426db8ddc9888213264
Change-Id: I6a468a63f45047d51d145ec595e7ed6adf31be72
This commit is contained in:
parent
4c095e3e8c
commit
e843f72117
|
@ -239,7 +239,7 @@ in order to support a common usage pattern in OpenStack:
|
|||
from openstack.common import cfg
|
||||
|
||||
opts = [
|
||||
cfg.StrOpt('bind_host' default='0.0.0.0'),
|
||||
cfg.StrOpt('bind_host', default='0.0.0.0'),
|
||||
cfg.IntOpt('bind_port', default=9292),
|
||||
]
|
||||
|
||||
|
|
|
@ -76,6 +76,9 @@ log_opts = [
|
|||
cfg.BoolOpt('publish_errors',
|
||||
default=False,
|
||||
help='publish error events'),
|
||||
cfg.BoolOpt('fatal_deprecations',
|
||||
default=False,
|
||||
help='make deprecations fatal'),
|
||||
|
||||
# NOTE(mikal): there are two options here because sometimes we are handed
|
||||
# a full instance (and could include more information), and other times we
|
||||
|
@ -170,6 +173,14 @@ class ContextAdapter(logging.LoggerAdapter):
|
|||
def audit(self, msg, *args, **kwargs):
|
||||
self.log(logging.AUDIT, msg, *args, **kwargs)
|
||||
|
||||
def deprecated(self, msg, *args, **kwargs):
|
||||
stdmsg = _("Deprecated Config: %s") % msg
|
||||
if CONF.fatal_deprecations:
|
||||
self.critical(stdmsg, *args, **kwargs)
|
||||
raise DeprecatedConfig(msg=stdmsg)
|
||||
else:
|
||||
self.warn(stdmsg, *args, **kwargs)
|
||||
|
||||
def process(self, msg, kwargs):
|
||||
if 'extra' not in kwargs:
|
||||
kwargs['extra'] = {}
|
||||
|
@ -450,3 +461,10 @@ class ColorHandler(logging.StreamHandler):
|
|||
def format(self, record):
|
||||
record.color = self.LEVEL_COLORS[record.levelno]
|
||||
return logging.StreamHandler.format(self, record)
|
||||
|
||||
|
||||
class DeprecatedConfig(Exception):
|
||||
message = _("Fatal call to deprecated config: %(msg)s")
|
||||
|
||||
def __init__(self, msg):
|
||||
super(Exception, self).__init__(self.message % dict(msg=msg))
|
||||
|
|
|
@ -22,8 +22,8 @@ import sys
|
|||
from eventlet import event
|
||||
from eventlet import greenthread
|
||||
|
||||
from moniker.openstack.common import log as logging
|
||||
from moniker.openstack.common.gettextutils import _
|
||||
from moniker.openstack.common import log as logging
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
|
|
@ -31,9 +31,9 @@ import kombu.messaging
|
|||
|
||||
from moniker.openstack.common import cfg
|
||||
from moniker.openstack.common.gettextutils import _
|
||||
from moniker.openstack.common import network_utils
|
||||
from moniker.openstack.common.rpc import amqp as rpc_amqp
|
||||
from moniker.openstack.common.rpc import common as rpc_common
|
||||
from moniker.openstack.common import network_utils
|
||||
|
||||
kombu_opts = [
|
||||
cfg.StrOpt('kombu_ssl_version',
|
||||
|
@ -267,6 +267,7 @@ class FanoutConsumer(ConsumerBase):
|
|||
|
||||
# Default options
|
||||
options = {'durable': False,
|
||||
'queue_arguments': _get_queue_arguments(conf),
|
||||
'auto_delete': True,
|
||||
'exclusive': True}
|
||||
options.update(kwargs)
|
||||
|
|
|
@ -556,7 +556,7 @@ def _call(addr, context, msg_id, topic, msg, timeout=None):
|
|||
timeout = timeout or CONF.rpc_response_timeout
|
||||
|
||||
# The msg_id is used to track replies.
|
||||
msg_id = str(uuid.uuid4().hex)
|
||||
msg_id = uuid.uuid4().hex
|
||||
|
||||
# Replies always come into the reply service.
|
||||
reply_topic = "zmq_replies.%s" % CONF.rpc_zmq_host
|
||||
|
|
|
@ -32,9 +32,9 @@ import logging as std_logging
|
|||
|
||||
from moniker.openstack.common import cfg
|
||||
from moniker.openstack.common import eventlet_backdoor
|
||||
from moniker.openstack.common.gettextutils import _
|
||||
from moniker.openstack.common import log as logging
|
||||
from moniker.openstack.common import threadgroup
|
||||
from moniker.openstack.common.gettextutils import _
|
||||
|
||||
try:
|
||||
from openstack.common import rpc
|
||||
|
|
|
@ -136,15 +136,17 @@ def _get_git_next_version_suffix(branch_name):
|
|||
_run_shell_command("git fetch origin +refs/meta/*:refs/remotes/meta/*")
|
||||
milestone_cmd = "git show meta/openstack/release:%s" % branch_name
|
||||
milestonever = _run_shell_command(milestone_cmd)
|
||||
if not milestonever:
|
||||
milestonever = ""
|
||||
if milestonever:
|
||||
first_half = "%s~%s" % (milestonever, datestamp)
|
||||
else:
|
||||
first_half = datestamp
|
||||
|
||||
post_version = _get_git_post_version()
|
||||
# post version should look like:
|
||||
# 0.1.1.4.gcc9e28a
|
||||
# where the bit after the last . is the short sha, and the bit between
|
||||
# the last and second to last is the revno count
|
||||
(revno, sha) = post_version.split(".")[-2:]
|
||||
first_half = "%s~%s" % (milestonever, datestamp)
|
||||
second_half = "%s%s.%s" % (revno_prefix, revno, sha)
|
||||
return ".".join((first_half, second_half))
|
||||
|
||||
|
|
|
@ -13,23 +13,25 @@
|
|||
# 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 os
|
||||
import sys
|
||||
|
||||
from eventlet import event
|
||||
from eventlet import greenthread
|
||||
from eventlet import greenlet
|
||||
from eventlet import greenpool
|
||||
from eventlet import greenthread
|
||||
|
||||
from moniker.openstack.common import loopingcall
|
||||
from moniker.openstack.common.gettextutils import _
|
||||
from moniker.openstack.common import log as logging
|
||||
from moniker.openstack.common import loopingcall
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def _thread_done(gt, *args, **kwargs):
|
||||
args[0].thread_done(args[1])
|
||||
'''
|
||||
Callback function to be passed to GreenThread.link() when we spawn()
|
||||
Calls the ThreadGroup to notify if.
|
||||
'''
|
||||
kwargs['group'].thread_done(kwargs['thread'])
|
||||
|
||||
|
||||
class Thread(object):
|
||||
|
@ -42,7 +44,7 @@ class Thread(object):
|
|||
def __init__(self, name, thread, group):
|
||||
self.name = name
|
||||
self.thread = thread
|
||||
self.thread.link(_thread_done, group, self)
|
||||
self.thread.link(_thread_done, group=group, thread=self)
|
||||
|
||||
def stop(self):
|
||||
self.thread.cancel()
|
||||
|
@ -77,12 +79,7 @@ class ThreadGroup():
|
|||
self.threads.append(th)
|
||||
|
||||
def thread_done(self, thread):
|
||||
try:
|
||||
thread.wait()
|
||||
except Exception as ex:
|
||||
LOG.exception(ex)
|
||||
finally:
|
||||
self.threads.remove(thread)
|
||||
self.threads.remove(thread)
|
||||
|
||||
def stop(self):
|
||||
current = greenthread.getcurrent()
|
||||
|
@ -106,6 +103,8 @@ class ThreadGroup():
|
|||
for x in self.timers:
|
||||
try:
|
||||
x.wait()
|
||||
except greenlet.GreenletExit:
|
||||
pass
|
||||
except Exception as ex:
|
||||
LOG.exception(ex)
|
||||
current = greenthread.getcurrent()
|
||||
|
@ -114,5 +113,7 @@ class ThreadGroup():
|
|||
continue
|
||||
try:
|
||||
x.wait()
|
||||
except greenlet.GreenletExit:
|
||||
pass
|
||||
except Exception as ex:
|
||||
LOG.exception(ex)
|
||||
|
|
|
@ -23,8 +23,8 @@ import logging
|
|||
import random
|
||||
import shlex
|
||||
|
||||
from eventlet import greenthread
|
||||
from eventlet.green import subprocess
|
||||
from eventlet import greenthread
|
||||
|
||||
from moniker.openstack.common import exception
|
||||
from moniker.openstack.common.gettextutils import _
|
||||
|
|
|
@ -33,8 +33,8 @@ from xml.parsers import expat
|
|||
|
||||
from moniker.openstack.common import exception
|
||||
from moniker.openstack.common.gettextutils import _
|
||||
from moniker.openstack.common import log as logging
|
||||
from moniker.openstack.common import jsonutils
|
||||
from moniker.openstack.common import log as logging
|
||||
from moniker.openstack.common import service
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue