Merge remote-tracking branch 'upstream/2015.5' into merge-forward-2015.8

Conflicts:
    salt/config.py
    salt/minion.py
    salt/modules/yumpkg.py
    salt/runners/ssh.py
    salt/states/git.py
    salt/states/http.py
This commit is contained in:
Colton Myers 2015-09-22 15:20:17 -06:00
commit 95e70f0bef
16 changed files with 117 additions and 80 deletions

View file

@ -417,7 +417,7 @@ configuration requirements. Read the returner's documentation.
``master_job_cache``
--------------------
.. versionadded:: 2014.7
.. versionadded:: 2014.7.0
Default: 'local_cache'

View file

@ -229,7 +229,7 @@ Amazon AWS
----------
A number of configuration options are required for Amazon AWS including ``id``,
``key``, ``keyname``, ``sercuritygroup``, and ``private_key``:
``key``, ``keyname``, ``securitygroup``, and ``private_key``:
.. code-block:: yaml

View file

@ -39,7 +39,7 @@ multiple calls of the same function with different arguments. There is a differ
syntax for passing positional and key-value arguments. Mixing positional and
key-value arguments is not supported.
.. versionadded:: 2014.7
.. versionadded:: 2014.7.0
.. code-block:: yaml

View file

@ -117,7 +117,7 @@ class SSHClient(object):
'''
Execute a salt-ssh call synchronously.
.. versionaddedd:: 2015.5.0
.. versionadded:: 2015.5.0
WARNING: Eauth is **NOT** respected

View file

@ -3856,15 +3856,17 @@ def create_snapshot(kwargs=None, call=None, wait_to_finish=False):
for d in data:
for k, v in six.iteritems(d):
r_data[k] = v
snapshot_id = r_data['snapshotId']
# Waits till volume is available
if wait_to_finish:
salt.utils.cloud.run_func_until_ret_arg(fun=describe_snapshots,
kwargs={'snapshot_id': snapshot_id},
fun_call=call,
argument_being_watched='status',
required_argument_response='completed')
if 'snapshotId' in r_data:
snapshot_id = r_data['snapshotId']
# Waits till volume is available
if wait_to_finish:
salt.utils.cloud.run_func_until_ret_arg(fun=describe_snapshots,
kwargs={'snapshot_id': snapshot_id},
fun_call=call,
argument_being_watched='status',
required_argument_response='completed')
return r_data

View file

@ -370,6 +370,9 @@ VALID_OPTS = {
# in the event of a disconnect event
'recon_randomize': float, # FIXME This should really be a bool, according to the implementation
'return_retry_timer': int,
'return_retry_random': bool,
# Specify a returner in which all events will be sent to. Requires that the returner in question
# have an event_return(event) function!
'event_return': str,
@ -882,6 +885,8 @@ DEFAULT_MINION_OPTS = {
'recon_max': 10000,
'recon_default': 1000,
'recon_randomize': True,
'return_retry_timer': 4,
'return_retry_random': True,
'syndic_log_file': os.path.join(salt.syspaths.LOGS_DIR, 'syndic'),
'syndic_pidfile': os.path.join(salt.syspaths.PIDFILE_DIR, 'salt-syndic.pid'),
'random_reauth_delay': 10,

View file

@ -17,6 +17,7 @@ import threading
import traceback
import multiprocessing
from random import shuffle
from salt.config import DEFAULT_MINION_OPTS
from stat import S_IMODE
# Import Salt Libs
@ -791,6 +792,30 @@ class Minion(MinionBase):
self.grains_cache = self.opts['grains']
def _return_retry_timer(self):
'''
Based on the minion configuration, either return a randomized timer or
just return the value of the return_retry_timer.
'''
msg = 'Minion return retry timer set to {0} seconds'
if self.opts['return_retry_random']:
try:
random_retry = randint(1, self.opts['return_retry_timer'])
except ValueError:
# Catch wiseguys using negative integers here
log.error(
'Invalid value ({0}) for return_retry_timer, must be a '
'positive integer'.format(self.opts['return_retry_timer'])
)
log.debug(msg.format(DEFAULT_MINION_OPTS['return_retry_timer']))
return DEFAULT_MINION_OPTS['return_retry_timer']
else:
log.debug(msg.format(random_retry) + ' (randomized)')
return random_retry
else:
log.debug(msg.format(self.opts['return_retry_timer']))
return self.opts['return_retry_timer']
def _prep_mod_opts(self):
'''
Returns a copy of the opts with key bits stripped out
@ -1083,7 +1108,10 @@ class Minion(MinionBase):
ret['metadata'] = data['metadata']
else:
log.warning('The metadata parameter must be a dictionary. Ignoring.')
minion_instance._return_pub(ret)
minion_instance._return_pub(
ret,
timeout=minion_instance._return_retry_timer()
)
if data['ret']:
if 'ret_config' in data:
ret['ret_config'] = data['ret_config']
@ -1140,7 +1168,10 @@ class Minion(MinionBase):
ret['fun_args'] = data['arg']
if 'metadata' in data:
ret['metadata'] = data['metadata']
minion_instance._return_pub(ret)
minion_instance._return_pub(
ret,
timeout=minion_instance._return_retry_timer()
)
if data['ret']:
if 'ret_config' in data:
ret['ret_config'] = data['ret_config']
@ -1896,7 +1927,9 @@ class Syndic(Minion):
pretag=tagify(self.opts['id'], base='syndic'),
)
for jid in self.jids:
self._return_pub(self.jids[jid], '_syndic_return')
self._return_pub(self.jids[jid],
'_syndic_return',
timeout=self._return_retry_timer())
self._reset_event_aggregation()
def destroy(self):

View file

@ -2954,7 +2954,7 @@ def statvfs(path):
'f_blocks', 'f_bsize', 'f_favail', 'f_ffree', 'f_files', 'f_flag',
'f_frsize', 'f_namemax'))
except (OSError, IOError):
raise CommandExecutionError('Could not create {0!r}'.format(link))
raise CommandExecutionError('Could not statvfs {0!r}'.format(path))
return False

View file

@ -735,7 +735,7 @@ def interface(iface):
'''
Return the inet address for a given interface
.. versionadded:: 2014.7
.. versionadded:: 2014.7.0
CLI Example:
@ -750,7 +750,7 @@ def interface_ip(iface):
'''
Return the inet address for a given interface
.. versionadded:: 2014.7
.. versionadded:: 2014.7.0
CLI Example:
@ -993,7 +993,7 @@ def connect(host, port=None, **kwargs):
Test connectivity to a host using a particular
port from the minion.
.. versionadded:: 2014.7
.. versionadded:: 2014.7.0
CLI Example:

View file

@ -878,7 +878,7 @@ def runner(_fun, **kwargs):
'''
Execute a runner module (this function must be run on the master)
.. versionadded:: 2014.7
.. versionadded:: 2014.7.0
name
The name of the function to run
@ -908,7 +908,7 @@ def wheel(_fun, **kwargs):
'''
Execute a wheel module (this function must be run on the master)
.. versionadded:: 2014.7
.. versionadded:: 2014.7.0
name
The name of the function to run

View file

@ -421,7 +421,7 @@ def latest_version(*names, **kwargs):
# Refresh before looking for the latest version available
if refresh:
refresh_db(_get_branch_option(**kwargs), repo_arg, exclude_arg)
refresh_db(**kwargs)
# Get updates for specified package(s)
# Sort by version number (highest to lowest) for loop below
@ -668,7 +668,7 @@ def list_upgrades(refresh=True, **kwargs):
exclude_arg = _get_excludes_option(**kwargs)
if salt.utils.is_true(refresh):
refresh_db(_get_branch_option(**kwargs), repo_arg, exclude_arg)
refresh_db(**kwargs)
updates = _repoquery_pkginfo(
'{0} {1} --all --pkgnarrow=updates'.format(repo_arg, exclude_arg)
)
@ -770,7 +770,7 @@ def check_db(*names, **kwargs):
return ret
def refresh_db(branch_arg=None, repo_arg=None, exclude_arg=None, branch=None, repo=None, exclude=None):
def refresh_db(**kwargs):
'''
Check the yum repos for updated packages
@ -780,60 +780,58 @@ def refresh_db(branch_arg=None, repo_arg=None, exclude_arg=None, branch=None, re
- ``False``: An error occurred
- ``None``: No updates are available
repo
Refresh just the specified repo
disablerepo
Do not refresh the specified repo
enablerepo
Refesh a disabled repo using this option
branch
Add the specified branch when refreshing
disableexcludes
Disable the excludes defined in your config files. Takes one of three
options:
- ``all`` - disable all excludes
- ``main`` - disable excludes defined in [main] in yum.conf
- ``repoid`` - disable excludes defined for that repo
CLI Example:
.. code-block:: bash
salt '*' pkg.refresh_db
'''
def warn(old, new):
'''
warn about old arguments
'''
salt.utils.warn_until(
'Carbon',
'"{0}" is being deprecated in favor of "{1}"'.format(old, new)
)
if branch_arg:
warn(branch_arg, branch)
branch = branch_arg
if repo_arg:
warn(repo_arg, repo)
repo = repo_arg
if exclude_arg:
warn(exclude_arg, exclude)
exclude = exclude_arg
retcodes = {
100: True,
0: None,
1: False,
}
clean_cmd = [_yum(), '-q', 'clean', 'expire-cache']
update_cmd = [_yum(), '-q', 'check-update']
repo_arg = _get_repo_options(**kwargs)
exclude_arg = _get_excludes_option(**kwargs)
branch_arg = _get_branch_option(**kwargs)
if repo:
clean_cmd.append(repo)
update_cmd.append(repo)
clean_cmd = 'yum -q clean expire-cache {repo} {exclude} {branch}'.format(
repo=repo_arg,
exclude=exclude_arg,
branch=branch_arg
)
update_cmd = 'yum -q check-update {repo} {exclude} {branch}'.format(
repo=repo_arg,
exclude=exclude_arg,
branch=branch_arg
)
if exclude:
clean_cmd.append(exclude)
update_cmd.append(exclude)
if branch:
clean_cmd.append(branch)
update_cmd.append(branch)
__salt__['cmd.run'](clean_cmd, python_shell=False)
ret = __salt__['cmd.retcode'](update_cmd,
python_shell=False,
ignore_retcode=True)
return retcodes.get(ret, False)
__salt__['cmd.run'](clean_cmd)
return retcodes.get(
__salt__['cmd.retcode'](update_cmd, ignore_retcode=True),
False
)
def clean_metadata(**kwargs):
@ -849,12 +847,11 @@ def clean_metadata(**kwargs):
salt '*' pkg.clean_metadata
'''
return refresh_db(_get_branch_option(**kwargs), _get_repo_options(**kwargs), _get_excludes_option(**kwargs))
return refresh_db(**kwargs)
def install(name=None,
refresh=False,
fromrepo=None,
skip_verify=False,
pkgs=None,
sources=None,
@ -971,12 +968,12 @@ def install(name=None,
{'<package>': {'old': '<old-version>',
'new': '<new-version>'}}
'''
branch_arg = _get_branch_option(**kwargs)
repo_arg = _get_repo_options(fromrepo=fromrepo, **kwargs)
repo_arg = _get_repo_options(**kwargs)
exclude_arg = _get_excludes_option(**kwargs)
branch_arg = _get_branch_option(**kwargs)
if salt.utils.is_true(refresh):
refresh_db(branch_arg, repo_arg, exclude_arg)
refresh_db(**kwargs)
reinstall = salt.utils.is_true(reinstall)
try:
@ -1125,7 +1122,7 @@ def install(name=None,
return ret
def upgrade(refresh=True, fromrepo=None, skip_verify=False, **kwargs):
def upgrade(refresh=True, skip_verify=False, **kwargs):
'''
Run a full system upgrade, a yum upgrade
@ -1162,12 +1159,12 @@ def upgrade(refresh=True, fromrepo=None, skip_verify=False, **kwargs):
.. versionadded:: 2014.7.0
'''
repo_arg = _get_repo_options(fromrepo=fromrepo, **kwargs)
repo_arg = _get_repo_options(**kwargs)
exclude_arg = _get_excludes_option(**kwargs)
branch_arg = _get_branch_option(**kwargs)
if salt.utils.is_true(refresh):
refresh_db(branch_arg, repo_arg, exclude_arg)
refresh_db(**kwargs)
old = list_pkgs()
cmd = '{yum_command} -q -y {repo} {exclude} {branch} {gpgcheck} upgrade'.format(

View file

@ -23,7 +23,7 @@ def cmd(
Execute a single command via the salt-ssh subsystem and return all
routines at once
.. versionadded:: 2015.2
.. versionadded:: 2015.5.0
A wrapper around the :py:meth:`SSHClient.cmd
<salt.client.ssh.client.SSHClient.cmd>` method.

View file

@ -524,13 +524,13 @@ def file(name,
return ret
if ret['changes']:
cron_ret = __salt__['cron.write_cron_file_verbose'](user, cron_path)
ret['changes'] = {'diff': ret['changes']['diff']}
ret['comment'] = 'Crontab for user {0} was updated'.format(user)
elif ret['result']:
ret['comment'] = 'Crontab for user {0} is in the correct ' \
'state'.format(user)
cron_ret = __salt__['cron.write_cron_file_verbose'](user, cron_path)
if cron_ret['retcode']:
ret['comment'] = 'Unable to update user {0} crontab {1}.' \
' Error: {2}'.format(user, cron_path, cron_ret['stderr'])

View file

@ -4,7 +4,7 @@ HTTP monitoring states
Perform an HTTP query and statefully return the result
.. versionadded:: 2015.2
.. versionadded:: 2015.5.0
'''
from __future__ import absolute_import
@ -21,7 +21,7 @@ def query(name, match=None, match_type='string', status=None, **kwargs):
'''
Perform an HTTP query and statefully return the result
.. versionadded:: 2015.2
.. versionadded:: 2015.5.0
'''
# Monitoring state, but changes may be made over HTTP
ret = {'name': name,

View file

@ -447,7 +447,7 @@ def wait_for_event(
'''
Watch Salt's event bus and block until a condition is met
.. versionadded:: 2014.7
.. versionadded:: 2014.7.0
name
An event tag to watch for; supports Reactor-style globbing.
@ -549,7 +549,7 @@ def runner(name, **kwargs):
'''
Execute a runner module on the master
.. versionadded:: 2014.7
.. versionadded:: 2014.7.0
name
The name of the function to run
@ -578,7 +578,7 @@ def wheel(name, **kwargs):
'''
Execute a wheel module on the master
.. versionadded:: 2014.7
.. versionadded:: 2014.7.0
name
The name of the function to run

View file

@ -3,7 +3,7 @@
Utils for making various web calls. Primarily designed for REST, SOAP, webhooks
and the like, but also useful for basic HTTP testing.
.. versionaddedd:: 2015.2
.. versionadded:: 2015.5.0
'''
# Import python libs