Merge pull request #38944 from rallytime/merge-2016.11

[2016.11] Merge forward from 2016.3 to 2016.11
This commit is contained in:
Mike Place 2017-01-25 12:44:42 -07:00 committed by GitHub
commit e420763285
8 changed files with 2370 additions and 10 deletions

File diff suppressed because it is too large Load diff

View file

@ -372,6 +372,9 @@ def cache_file(path, saltenv='base'):
salt '*' cp.cache_file salt://foo/bar.conf saltenv=config
salt '*' cp.cache_file salt://foo/bar.conf?saltenv=config
If the path being cached is a ``salt://`` URI, and the path does not exist,
then ``False`` will be returned.
.. note::
It may be necessary to quote the URL when using the querystring method,
depending on the shell being used to run the command.

View file

@ -821,7 +821,11 @@ def _get_client(timeout=None):
raise CommandExecutionError(
'Docker machine {0} failed: {1}'.format(docker_machine, exc))
__context__['docker.client'] = docker.Client(**client_kwargs)
try:
__context__['docker.client'] = docker.Client(**client_kwargs)
except AttributeError:
# docker-py 2.0 renamed this client attribute
__context__['docker.client'] = docker.APIClient(**client_kwargs)
# Set a new timeout if one was passed
if timeout is not None and __context__['docker.client'].timeout != timeout:

View file

@ -54,7 +54,7 @@ import salt.utils.files
import salt.utils.locales
import salt.utils.templates
import salt.utils.url
from salt.exceptions import CommandExecutionError, SaltInvocationError, get_error_message as _get_error_message
from salt.exceptions import CommandExecutionError, MinionError, SaltInvocationError, get_error_message as _get_error_message
log = logging.getLogger(__name__)
@ -3520,9 +3520,14 @@ def source_list(source, source_hash, saltenv):
ret = (single_src, single_hash)
break
elif proto.startswith('http') or proto == 'ftp':
if __salt__['cp.cache_file'](single_src):
ret = (single_src, single_hash)
break
try:
if __salt__['cp.cache_file'](single_src):
ret = (single_src, single_hash)
break
except MinionError as exc:
# Error downloading file. Log the caught exception and
# continue on to the next source.
log.exception(exc)
elif proto == 'file' and os.path.exists(urlparsed_single_src.path):
ret = (single_src, single_hash)
break

View file

@ -37,7 +37,7 @@ def compound(tgt, minion_id=None):
salt '*' match.compound 'L@cheese,foo and *'
'''
opts = {'grains': __grains__}
opts = {'grains': __grains__, 'pillar': __pillar__}
if minion_id is not None:
if not isinstance(minion_id, string_types):
minion_id = str(minion_id)

View file

@ -198,7 +198,7 @@ def query(url,
log_url = sanitize_url(url_full, hide_fields)
log.debug('Requesting URL {0} using {1} method'.format(log_url, method))
if method == 'POST':
if method == 'POST' and log.isEnabledFor(logging.TRACE):
# Make sure no secret fields show up in logs
if isinstance(data, dict):
log_data = data.copy()
@ -537,7 +537,7 @@ def query(url,
log.trace(('Cannot Trace Log Response Text: {0}. This may be due to '
'incompatibilities between requests and logging.').format(exc))
if text_out is not None and os.path.exists(text_out):
if text_out is not None:
with salt.utils.fopen(text_out, 'w') as tof:
tof.write(result_text)

View file

@ -58,7 +58,7 @@ class Reactor(salt.utils.process.SignalHandlingMultiprocessingProcess, salt.stat
react = {}
if glob_ref.startswith('salt://'):
glob_ref = self.minion.functions['cp.cache_file'](glob_ref)
glob_ref = self.minion.functions['cp.cache_file'](glob_ref) or ''
globbed_ref = glob.glob(glob_ref)
if not globbed_ref:
log.error('Can not render SLS {0} for tag {1}. File missing or not found.'.format(glob_ref, tag))

View file

@ -54,8 +54,9 @@ class DocTestCase(TestCase):
if 'man' in key \
or key.endswith('doc_test.py') \
or key.endswith('doc/conf.py') \
or key.endswith('/conventions/documentation.rst') \
or key.endswith('doc/topics/releases/2016.11.2.rst') \
or key.endswith('/conventions/documentation.rst'):
or key.endswith('doc/topics/releases/2016.3.5.rst'):
continue
# Set up test return dict