Sync oslo incubator
Sync with oslo incubator at commit ea9ead81417e942495f3cc19be400801e7aa9cb4 to get the new config generator script options. Change-Id: I52e006325d5cf7ea731d85a73fb7c3675f1f7e41
This commit is contained in:
parent
fb6b9100a4
commit
7b589f9000
@ -59,7 +59,10 @@ _SANITIZE_PATTERNS = []
|
|||||||
_FORMAT_PATTERNS = [r'(%(key)s\s*[=]\s*[\"\']).*?([\"\'])',
|
_FORMAT_PATTERNS = [r'(%(key)s\s*[=]\s*[\"\']).*?([\"\'])',
|
||||||
r'(<%(key)s>).*?(</%(key)s>)',
|
r'(<%(key)s>).*?(</%(key)s>)',
|
||||||
r'([\"\']%(key)s[\"\']\s*:\s*[\"\']).*?([\"\'])',
|
r'([\"\']%(key)s[\"\']\s*:\s*[\"\']).*?([\"\'])',
|
||||||
r'([\'"].*?%(key)s[\'"]\s*:\s*u?[\'"]).*?([\'"])']
|
r'([\'"].*?%(key)s[\'"]\s*:\s*u?[\'"]).*?([\'"])',
|
||||||
|
r'([\'"].*?%(key)s[\'"]\s*,\s*\'--?[A-z]+\'\s*,\s*u?[\'"])'
|
||||||
|
'.*?([\'"])',
|
||||||
|
r'(%(key)s\s*--?[A-z]+\s*).*?([\s])']
|
||||||
|
|
||||||
for key in _SANITIZE_KEYS:
|
for key in _SANITIZE_KEYS:
|
||||||
for pattern in _FORMAT_PATTERNS:
|
for pattern in _FORMAT_PATTERNS:
|
||||||
|
@ -28,19 +28,19 @@ LOG = logging.getLogger(__name__)
|
|||||||
|
|
||||||
|
|
||||||
class LoopingCallDone(Exception):
|
class LoopingCallDone(Exception):
|
||||||
"""Exception to break out and stop a LoopingCall.
|
"""Exception to break out and stop a LoopingCallBase.
|
||||||
|
|
||||||
The poll-function passed to LoopingCall can raise this exception to
|
The poll-function passed to LoopingCallBase can raise this exception to
|
||||||
break out of the loop normally. This is somewhat analogous to
|
break out of the loop normally. This is somewhat analogous to
|
||||||
StopIteration.
|
StopIteration.
|
||||||
|
|
||||||
An optional return-value can be included as the argument to the exception;
|
An optional return-value can be included as the argument to the exception;
|
||||||
this return-value will be returned by LoopingCall.wait()
|
this return-value will be returned by LoopingCallBase.wait()
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, retvalue=True):
|
def __init__(self, retvalue=True):
|
||||||
""":param retvalue: Value that LoopingCall.wait() should return."""
|
""":param retvalue: Value that LoopingCallBase.wait() should return."""
|
||||||
self.retvalue = retvalue
|
self.retvalue = retvalue
|
||||||
|
|
||||||
|
|
||||||
@ -98,11 +98,6 @@ class FixedIntervalLoopingCall(LoopingCallBase):
|
|||||||
return self.done
|
return self.done
|
||||||
|
|
||||||
|
|
||||||
# TODO(mikal): this class name is deprecated in Havana and should be removed
|
|
||||||
# in the I release
|
|
||||||
LoopingCall = FixedIntervalLoopingCall
|
|
||||||
|
|
||||||
|
|
||||||
class DynamicLoopingCall(LoopingCallBase):
|
class DynamicLoopingCall(LoopingCallBase):
|
||||||
"""A looping call which sleeps until the next known event.
|
"""A looping call which sleeps until the next known event.
|
||||||
|
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
#
|
|
||||||
# Copyright 2011 OpenStack Foundation.
|
# Copyright 2011 OpenStack Foundation.
|
||||||
# All Rights Reserved.
|
# All Rights Reserved.
|
||||||
#
|
#
|
||||||
@ -18,6 +17,7 @@
|
|||||||
System-level utilities and helper functions.
|
System-level utilities and helper functions.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import errno
|
||||||
import logging as stdlib_logging
|
import logging as stdlib_logging
|
||||||
import os
|
import os
|
||||||
import random
|
import random
|
||||||
@ -26,8 +26,9 @@ import signal
|
|||||||
|
|
||||||
from eventlet.green import subprocess
|
from eventlet.green import subprocess
|
||||||
from eventlet import greenthread
|
from eventlet import greenthread
|
||||||
|
import six
|
||||||
|
|
||||||
from heat.openstack.common.gettextutils import _ # noqa
|
from heat.openstack.common.gettextutils import _
|
||||||
from heat.openstack.common import log as logging
|
from heat.openstack.common import log as logging
|
||||||
|
|
||||||
|
|
||||||
@ -54,11 +55,18 @@ class ProcessExecutionError(Exception):
|
|||||||
self.description = description
|
self.description = description
|
||||||
|
|
||||||
if description is None:
|
if description is None:
|
||||||
description = "Unexpected error while running command."
|
description = _("Unexpected error while running command.")
|
||||||
if exit_code is None:
|
if exit_code is None:
|
||||||
exit_code = '-'
|
exit_code = '-'
|
||||||
message = ("%s\nCommand: %s\nExit code: %s\nStdout: %r\nStderr: %r"
|
message = _('%(description)s\n'
|
||||||
% (description, cmd, exit_code, stdout, stderr))
|
'Command: %(cmd)s\n'
|
||||||
|
'Exit code: %(exit_code)s\n'
|
||||||
|
'Stdout: %(stdout)r\n'
|
||||||
|
'Stderr: %(stderr)r') % {'description': description,
|
||||||
|
'cmd': cmd,
|
||||||
|
'exit_code': exit_code,
|
||||||
|
'stdout': stdout,
|
||||||
|
'stderr': stderr}
|
||||||
super(ProcessExecutionError, self).__init__(message)
|
super(ProcessExecutionError, self).__init__(message)
|
||||||
|
|
||||||
|
|
||||||
@ -82,6 +90,9 @@ def execute(*cmd, **kwargs):
|
|||||||
:type cmd: string
|
:type cmd: string
|
||||||
:param process_input: Send to opened process.
|
:param process_input: Send to opened process.
|
||||||
:type process_input: string
|
:type process_input: string
|
||||||
|
:param env_variables: Environment variables and their values that
|
||||||
|
will be set for the process.
|
||||||
|
:type env_variables: dict
|
||||||
:param check_exit_code: Single bool, int, or list of allowed exit
|
:param check_exit_code: Single bool, int, or list of allowed exit
|
||||||
codes. Defaults to [0]. Raise
|
codes. Defaults to [0]. Raise
|
||||||
:class:`ProcessExecutionError` unless
|
:class:`ProcessExecutionError` unless
|
||||||
@ -112,6 +123,7 @@ def execute(*cmd, **kwargs):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
process_input = kwargs.pop('process_input', None)
|
process_input = kwargs.pop('process_input', None)
|
||||||
|
env_variables = kwargs.pop('env_variables', None)
|
||||||
check_exit_code = kwargs.pop('check_exit_code', [0])
|
check_exit_code = kwargs.pop('check_exit_code', [0])
|
||||||
ignore_exit_code = False
|
ignore_exit_code = False
|
||||||
delay_on_retry = kwargs.pop('delay_on_retry', True)
|
delay_on_retry = kwargs.pop('delay_on_retry', True)
|
||||||
@ -134,8 +146,8 @@ def execute(*cmd, **kwargs):
|
|||||||
if run_as_root and hasattr(os, 'geteuid') and os.geteuid() != 0:
|
if run_as_root and hasattr(os, 'geteuid') and os.geteuid() != 0:
|
||||||
if not root_helper:
|
if not root_helper:
|
||||||
raise NoRootWrapSpecified(
|
raise NoRootWrapSpecified(
|
||||||
message=('Command requested root, but did not specify a root '
|
message=_('Command requested root, but did not '
|
||||||
'helper.'))
|
'specify a root helper.'))
|
||||||
cmd = shlex.split(root_helper) + list(cmd)
|
cmd = shlex.split(root_helper) + list(cmd)
|
||||||
|
|
||||||
cmd = map(str, cmd)
|
cmd = map(str, cmd)
|
||||||
@ -143,7 +155,8 @@ def execute(*cmd, **kwargs):
|
|||||||
while attempts > 0:
|
while attempts > 0:
|
||||||
attempts -= 1
|
attempts -= 1
|
||||||
try:
|
try:
|
||||||
LOG.log(loglevel, _('Running cmd (subprocess): %s'), ' '.join(cmd))
|
LOG.log(loglevel, 'Running cmd (subprocess): %s',
|
||||||
|
' '.join(logging.mask_password(cmd)))
|
||||||
_PIPE = subprocess.PIPE # pylint: disable=E1101
|
_PIPE = subprocess.PIPE # pylint: disable=E1101
|
||||||
|
|
||||||
if os.name == 'nt':
|
if os.name == 'nt':
|
||||||
@ -159,15 +172,25 @@ def execute(*cmd, **kwargs):
|
|||||||
stderr=_PIPE,
|
stderr=_PIPE,
|
||||||
close_fds=close_fds,
|
close_fds=close_fds,
|
||||||
preexec_fn=preexec_fn,
|
preexec_fn=preexec_fn,
|
||||||
shell=shell)
|
shell=shell,
|
||||||
|
env=env_variables)
|
||||||
result = None
|
result = None
|
||||||
if process_input is not None:
|
for _i in six.moves.range(20):
|
||||||
result = obj.communicate(process_input)
|
# NOTE(russellb) 20 is an arbitrary number of retries to
|
||||||
else:
|
# prevent any chance of looping forever here.
|
||||||
result = obj.communicate()
|
try:
|
||||||
|
if process_input is not None:
|
||||||
|
result = obj.communicate(process_input)
|
||||||
|
else:
|
||||||
|
result = obj.communicate()
|
||||||
|
except OSError as e:
|
||||||
|
if e.errno in (errno.EAGAIN, errno.EINTR):
|
||||||
|
continue
|
||||||
|
raise
|
||||||
|
break
|
||||||
obj.stdin.close() # pylint: disable=E1101
|
obj.stdin.close() # pylint: disable=E1101
|
||||||
_returncode = obj.returncode # pylint: disable=E1101
|
_returncode = obj.returncode # pylint: disable=E1101
|
||||||
LOG.log(loglevel, _('Result was %s') % _returncode)
|
LOG.log(loglevel, 'Result was %s' % _returncode)
|
||||||
if not ignore_exit_code and _returncode not in check_exit_code:
|
if not ignore_exit_code and _returncode not in check_exit_code:
|
||||||
(stdout, stderr) = result
|
(stdout, stderr) = result
|
||||||
raise ProcessExecutionError(exit_code=_returncode,
|
raise ProcessExecutionError(exit_code=_returncode,
|
||||||
@ -179,7 +202,7 @@ def execute(*cmd, **kwargs):
|
|||||||
if not attempts:
|
if not attempts:
|
||||||
raise
|
raise
|
||||||
else:
|
else:
|
||||||
LOG.log(loglevel, _('%r failed. Retrying.'), cmd)
|
LOG.log(loglevel, '%r failed. Retrying.', cmd)
|
||||||
if delay_on_retry:
|
if delay_on_retry:
|
||||||
greenthread.sleep(random.randint(20, 200) / 100.0)
|
greenthread.sleep(random.randint(20, 200) / 100.0)
|
||||||
finally:
|
finally:
|
||||||
@ -206,7 +229,7 @@ def trycmd(*args, **kwargs):
|
|||||||
out, err = execute(*args, **kwargs)
|
out, err = execute(*args, **kwargs)
|
||||||
failed = False
|
failed = False
|
||||||
except ProcessExecutionError as exn:
|
except ProcessExecutionError as exn:
|
||||||
out, err = '', str(exn)
|
out, err = '', six.text_type(exn)
|
||||||
failed = True
|
failed = True
|
||||||
|
|
||||||
if not failed and discard_warnings and err:
|
if not failed and discard_warnings and err:
|
||||||
@ -218,7 +241,7 @@ def trycmd(*args, **kwargs):
|
|||||||
|
|
||||||
def ssh_execute(ssh, cmd, process_input=None,
|
def ssh_execute(ssh, cmd, process_input=None,
|
||||||
addl_env=None, check_exit_code=True):
|
addl_env=None, check_exit_code=True):
|
||||||
LOG.debug(_('Running cmd (SSH): %s'), cmd)
|
LOG.debug('Running cmd (SSH): %s', cmd)
|
||||||
if addl_env:
|
if addl_env:
|
||||||
raise InvalidArgumentError(_('Environment not supported over SSH'))
|
raise InvalidArgumentError(_('Environment not supported over SSH'))
|
||||||
|
|
||||||
@ -239,7 +262,7 @@ def ssh_execute(ssh, cmd, process_input=None,
|
|||||||
|
|
||||||
# exit_status == -1 if no exit code was returned
|
# exit_status == -1 if no exit code was returned
|
||||||
if exit_status != -1:
|
if exit_status != -1:
|
||||||
LOG.debug(_('Result was %s') % exit_status)
|
LOG.debug('Result was %s' % exit_status)
|
||||||
if check_exit_code and exit_status != 0:
|
if check_exit_code and exit_status != 0:
|
||||||
raise ProcessExecutionError(exit_code=exit_status,
|
raise ProcessExecutionError(exit_code=exit_status,
|
||||||
stdout=stdout,
|
stdout=stdout,
|
||||||
|
@ -95,6 +95,10 @@ then
|
|||||||
source "$RC_FILE"
|
source "$RC_FILE"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
for filename in ${HEAT_CONFIG_GENERATOR_EXCLUDED_FILES}; do
|
||||||
|
FILES="${FILES[@]/$filename/}"
|
||||||
|
done
|
||||||
|
|
||||||
for mod in ${HEAT_CONFIG_GENERATOR_EXTRA_MODULES}; do
|
for mod in ${HEAT_CONFIG_GENERATOR_EXTRA_MODULES}; do
|
||||||
MODULES="$MODULES -m $mod"
|
MODULES="$MODULES -m $mod"
|
||||||
done
|
done
|
||||||
|
Loading…
Reference in New Issue
Block a user