mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge pull request #37048 from rallytime/merge-2016.3
[2016.3] Merge forward from 2015.8 to 2016.3
This commit is contained in:
commit
9378b22d80
4 changed files with 45 additions and 27 deletions
|
@ -85,7 +85,8 @@ def __clean_tmp(sfn):
|
|||
'''
|
||||
Clean out a template temp file
|
||||
'''
|
||||
if sfn.startswith(tempfile.gettempdir()):
|
||||
if sfn.startswith(os.path.join(tempfile.gettempdir(),
|
||||
salt.utils.files.TEMPFILE_PREFIX)):
|
||||
# Don't remove if it exists in file_roots (any saltenv)
|
||||
all_roots = itertools.chain.from_iterable(
|
||||
six.itervalues(__opts__['file_roots']))
|
||||
|
@ -1283,7 +1284,7 @@ def _mkstemp_copy(path,
|
|||
temp_file = None
|
||||
# Create the temp file
|
||||
try:
|
||||
temp_file = salt.utils.mkstemp()
|
||||
temp_file = salt.utils.mkstemp(prefix=salt.utils.files.TEMPFILE_PREFIX)
|
||||
except (OSError, IOError) as exc:
|
||||
raise CommandExecutionError(
|
||||
"Unable to create temp file. "
|
||||
|
@ -4065,7 +4066,8 @@ def check_file_meta(
|
|||
|
||||
if contents is not None:
|
||||
# Write a tempfile with the static contents
|
||||
tmp = salt.utils.mkstemp(text=True)
|
||||
tmp = salt.utils.mkstemp(prefix=salt.utils.files.TEMPFILE_PREFIX,
|
||||
text=True)
|
||||
with salt.utils.fopen(tmp, 'wb') as tmp_:
|
||||
tmp_.write(str(contents))
|
||||
# Compare the static contents with the named file
|
||||
|
@ -4333,7 +4335,8 @@ def manage_file(name,
|
|||
|
||||
if contents is not None:
|
||||
# Write the static contents to a temporary file
|
||||
tmp = salt.utils.mkstemp(text=True)
|
||||
tmp = salt.utils.mkstemp(prefix=salt.utils.files.TEMPFILE_PREFIX,
|
||||
text=True)
|
||||
if salt.utils.is_windows():
|
||||
contents = os.linesep.join(contents.splitlines())
|
||||
with salt.utils.fopen(tmp, 'w') as tmp_:
|
||||
|
@ -4516,7 +4519,8 @@ def manage_file(name,
|
|||
|
||||
if contents is not None:
|
||||
# Write the static contents to a temporary file
|
||||
tmp = salt.utils.mkstemp(text=True)
|
||||
tmp = salt.utils.mkstemp(prefix=salt.utils.files.TEMPFILE_PREFIX,
|
||||
text=True)
|
||||
if salt.utils.is_windows():
|
||||
contents = os.linesep.join(contents.splitlines())
|
||||
with salt.utils.fopen(tmp, 'w') as tmp_:
|
||||
|
|
|
@ -26,9 +26,11 @@ def _check_error(result, success_message):
|
|||
ret = {}
|
||||
|
||||
if 'ERROR' in result:
|
||||
if 'already started' in result:
|
||||
ret['comment'] = success_message
|
||||
elif 'not running' in result:
|
||||
if any(substring in result for substring in [
|
||||
'already started',
|
||||
'not running',
|
||||
'process group already active'
|
||||
]):
|
||||
ret['comment'] = success_message
|
||||
else:
|
||||
ret['comment'] = result
|
||||
|
@ -151,25 +153,14 @@ def running(name,
|
|||
|
||||
changes = []
|
||||
just_updated = False
|
||||
if to_add:
|
||||
comment = 'Adding service: {0}'.format(name)
|
||||
__salt__['supervisord.reread'](
|
||||
user=user,
|
||||
conf_file=conf_file,
|
||||
bin_env=bin_env
|
||||
)
|
||||
result = __salt__['supervisord.add'](
|
||||
name,
|
||||
user=user,
|
||||
conf_file=conf_file,
|
||||
bin_env=bin_env
|
||||
)
|
||||
|
||||
ret.update(_check_error(result, comment))
|
||||
changes.append(comment)
|
||||
log.debug(comment)
|
||||
|
||||
elif update:
|
||||
if update:
|
||||
# If the state explicitly asks to update, we don't care if the process
|
||||
# is being added or not, since it'll take care of this for us,
|
||||
# so give this condition priority in order
|
||||
#
|
||||
# That is, unless `to_add` somehow manages to contain processes
|
||||
# we don't want running, in which case adding them may be a mistake
|
||||
comment = 'Updating supervisor'
|
||||
result = __salt__['supervisord.update'](
|
||||
user=user,
|
||||
|
@ -181,6 +172,27 @@ def running(name,
|
|||
|
||||
if '{0}: updated'.format(name) in result:
|
||||
just_updated = True
|
||||
elif to_add:
|
||||
# Not sure if this condition is precise enough.
|
||||
comment = 'Adding service: {0}'.format(name)
|
||||
__salt__['supervisord.reread'](
|
||||
user=user,
|
||||
conf_file=conf_file,
|
||||
bin_env=bin_env
|
||||
)
|
||||
# Causes supervisorctl to throw `ERROR: process group already active`
|
||||
# if process group exists. At this moment, I'm not sure how to handle
|
||||
# this outside of grepping out the expected string in `_check_error`.
|
||||
result = __salt__['supervisord.add'](
|
||||
name,
|
||||
user=user,
|
||||
conf_file=conf_file,
|
||||
bin_env=bin_env
|
||||
)
|
||||
|
||||
ret.update(_check_error(result, comment))
|
||||
changes.append(comment)
|
||||
log.debug(comment)
|
||||
|
||||
is_stopped = None
|
||||
|
||||
|
|
|
@ -21,6 +21,8 @@ from salt.ext import six
|
|||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
TEMPFILE_PREFIX = '__salt.tmp.'
|
||||
|
||||
|
||||
def recursive_copy(source, dest):
|
||||
'''
|
||||
|
|
|
@ -332,7 +332,7 @@ class ReactWrap(object):
|
|||
Wrap Caller to enable executing :ref:`caller modules <all-salt.caller>`
|
||||
'''
|
||||
log.debug("in caller with fun {0} args {1} kwargs {2}".format(fun, args, kwargs))
|
||||
args = kwargs['args']
|
||||
args = kwargs.get('args', [])
|
||||
if 'caller' not in self.client_cache:
|
||||
self.client_cache['caller'] = salt.client.Caller(self.opts['conf_file'])
|
||||
try:
|
||||
|
|
Loading…
Add table
Reference in a new issue