mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 01:18:58 +00:00
Merge branch 'hotfix/transifex-updates' into develop
This commit is contained in:
commit
d177d99148
@ -4808,3 +4808,9 @@ source_file = _build/locale/topics/tutorials/multimaster_pki.pot
|
||||
source_lang = en
|
||||
source_name = topics/tutorials/multimaster_pki.rst
|
||||
|
||||
[salt.ref--output--all--salt_output_newline_values_only]
|
||||
file_filter = locale/<lang>/LC_MESSAGES/ref/output/all/salt.output.newline_values_only.po
|
||||
source_file = _build/locale/ref/output/all/salt.output.newline_values_only.pot
|
||||
source_lang = en
|
||||
source_name = ref/output/all/salt.output.newline_values_only.rst
|
||||
|
||||
|
@ -17,6 +17,7 @@ Follow one of the below links for further information and examples
|
||||
json_out
|
||||
key
|
||||
nested
|
||||
newline_values_only
|
||||
no_out
|
||||
no_return
|
||||
overstatestage
|
||||
|
6
doc/ref/output/all/salt.output.newline_values_only.rst
Normal file
6
doc/ref/output/all/salt.output.newline_values_only.rst
Normal file
@ -0,0 +1,6 @@
|
||||
===============================
|
||||
salt.output.newline_values_only
|
||||
===============================
|
||||
|
||||
.. automodule:: salt.output.newline_values_only
|
||||
:members:
|
@ -687,7 +687,7 @@ class Single(object):
|
||||
|
||||
ssh_py_shim_args = [
|
||||
'--config', self.minion_config,
|
||||
'--delimeter', RSTR,
|
||||
'--delimiter', RSTR,
|
||||
'--saltdir', DEFAULT_THIN_DIR,
|
||||
'--checksum', thin_sum,
|
||||
'--hashfunc', 'sha1',
|
||||
|
@ -39,7 +39,7 @@ def parse_argv(argv):
|
||||
help="YAML configuration for salt thin",
|
||||
)
|
||||
oparser.add_option(
|
||||
"-d", "--delimeter",
|
||||
"-d", "--delimiter",
|
||||
help="Delimeter string (viz. magic string) to indicate beginning of salt output",
|
||||
)
|
||||
oparser.add_option(
|
||||
@ -67,7 +67,7 @@ def parse_argv(argv):
|
||||
(OPTIONS, ARGS) = oparser.parse_args(argv[argv.index('--')+1:])
|
||||
|
||||
for option in (
|
||||
'delimeter',
|
||||
'delimiter',
|
||||
'saltdir',
|
||||
'checksum',
|
||||
'version',
|
||||
@ -91,7 +91,7 @@ def need_deployment():
|
||||
os.chmod(OPTIONS.saltdir, st.st_mode | stat.S_IWGRP | stat.S_IRGRP | stat.S_IXGRP)
|
||||
|
||||
# Delimeter emitted on stdout *only* to indicate shim message to master.
|
||||
sys.stdout.write("{0}\ndeploy\n".format(OPTIONS.delimeter))
|
||||
sys.stdout.write("{0}\ndeploy\n".format(OPTIONS.delimiter))
|
||||
sys.exit(EX_THIN_DEPLOY)
|
||||
|
||||
|
||||
@ -174,9 +174,9 @@ def main(argv):
|
||||
|
||||
# Only emit the delimiter on *both* stdout and stderr when completely successful.
|
||||
# Yes, the flush() is necessary.
|
||||
sys.stdout.write(OPTIONS.delimeter + '\n')
|
||||
sys.stdout.write(OPTIONS.delimiter + '\n')
|
||||
sys.stdout.flush()
|
||||
sys.stderr.write(OPTIONS.delimeter + '\n')
|
||||
sys.stderr.write(OPTIONS.delimiter + '\n')
|
||||
sys.stderr.flush()
|
||||
os.execv(sys.executable, salt_argv)
|
||||
|
||||
|
@ -1860,6 +1860,7 @@ class Syndic(Minion):
|
||||
|
||||
self._set_reconnect_ivl_max()
|
||||
self._set_tcp_keepalive()
|
||||
self._set_ipv4only()
|
||||
|
||||
def _fire_master_syndic_start(self):
|
||||
# Send an event to the master that the minion is live
|
||||
|
@ -1246,9 +1246,8 @@ def tty(device, echo=None):
|
||||
else:
|
||||
return {'Error': 'The specified device is not a valid TTY'}
|
||||
|
||||
cmd = 'echo {0} > {1}'.format(echo, teletype)
|
||||
ret = run_all(cmd)
|
||||
if ret['retcode'] == 0:
|
||||
ret = subprocess.call(['echo', echo, '>', teletype], shell=False, stdout=open(os.devnull, 'wb'))
|
||||
if ret == 0:
|
||||
return {
|
||||
'Success': 'Message was successfully echoed to {0}'.format(teletype)
|
||||
}
|
||||
|
@ -804,18 +804,18 @@ def config_set(cwd=None, setting_name=None, setting_value=None, user=None, is_gl
|
||||
Set a key in the git configuration file (.git/config) of the repository or
|
||||
globally.
|
||||
|
||||
setting_name
|
||||
The name of the configuration key to set
|
||||
|
||||
setting_value
|
||||
The (new) value to set
|
||||
|
||||
cwd : None
|
||||
Options path to the Git repository
|
||||
|
||||
.. versionchanged:: 2014.7.0
|
||||
Made ``cwd`` optional
|
||||
|
||||
setting_name : None
|
||||
The name of the configuration key to set. Required.
|
||||
|
||||
setting_value : None
|
||||
The (new) value to set. Required.
|
||||
|
||||
user : None
|
||||
Run git as a user other than what the minion runs as
|
||||
|
||||
@ -826,7 +826,7 @@ def config_set(cwd=None, setting_name=None, setting_value=None, user=None, is_gl
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' git.config_set user.email me@example.com /path/to/repo
|
||||
salt '*' git.config_set /path/to/repo user.email me@example.com
|
||||
'''
|
||||
if setting_name is None or setting_value is None:
|
||||
raise TypeError
|
||||
@ -848,15 +848,15 @@ def config_get(cwd=None, setting_name=None, user=None):
|
||||
'''
|
||||
Get a key or keys from the git configuration file (.git/config).
|
||||
|
||||
setting_name
|
||||
The name of the configuration key to get
|
||||
|
||||
cwd : None
|
||||
Optional path to a Git repository
|
||||
|
||||
.. versionchanged:: 2014.7.0
|
||||
Made ``cwd`` optional
|
||||
|
||||
setting_name : None
|
||||
The name of the configuration key to get. Required.
|
||||
|
||||
user : None
|
||||
Run git as a user other than what the minion runs as
|
||||
|
||||
@ -864,8 +864,8 @@ def config_get(cwd=None, setting_name=None, user=None):
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' git.config_get user.email
|
||||
salt '*' git.config_get user.name cwd=/path/to/repo user=arthur
|
||||
salt '*' git.config_get setting_name=user.email
|
||||
salt '*' git.config_get /path/to/repo user.name arthur
|
||||
'''
|
||||
if setting_name is None:
|
||||
raise TypeError
|
||||
|
@ -61,7 +61,7 @@ _SANITIZERS = {
|
||||
}
|
||||
|
||||
|
||||
def get(key, default='', delim=':'):
|
||||
def get(key, default='', delimiter=':'):
|
||||
'''
|
||||
Attempt to retrieve the named value from grains, if the named value is not
|
||||
available return the passed default. The default return is an empty string.
|
||||
@ -77,7 +77,7 @@ def get(key, default='', delim=':'):
|
||||
pkg:apache
|
||||
|
||||
|
||||
delim
|
||||
delimiter
|
||||
Specify an alternate delimiter to use when traversing a nested dict
|
||||
|
||||
.. versionadded:: 2014.7.0
|
||||
@ -88,7 +88,10 @@ def get(key, default='', delim=':'):
|
||||
|
||||
salt '*' grains.get pkg:apache
|
||||
'''
|
||||
return salt.utils.traverse_dict_and_list(__grains__, key, default, delim)
|
||||
return salt.utils.traverse_dict_and_list(__grains__,
|
||||
key,
|
||||
default,
|
||||
delimiter)
|
||||
|
||||
|
||||
def has_value(key):
|
||||
@ -439,7 +442,7 @@ def filter_by(lookup_dict, grain='os_family', merge=None, default='default'):
|
||||
return ret
|
||||
|
||||
|
||||
def _dict_from_path(path, val, delim=':'):
|
||||
def _dict_from_path(path, val, delimiter=':'):
|
||||
'''
|
||||
Given a lookup string in the form of 'foo:bar:baz" return a nested
|
||||
dictionary of the appropriate depth with the final segment as a value.
|
||||
@ -448,7 +451,7 @@ def _dict_from_path(path, val, delim=':'):
|
||||
{"foo": {"bar": {"baz": "somevalue"}}
|
||||
'''
|
||||
nested_dict = _infinitedict()
|
||||
keys = path.rsplit(delim)
|
||||
keys = path.rsplit(delimiter)
|
||||
lastplace = reduce(operator.getitem, keys[:-1], nested_dict)
|
||||
lastplace[keys[-1]] = val
|
||||
|
||||
|
@ -10,6 +10,7 @@ import sys
|
||||
|
||||
# Import salt libs
|
||||
import salt.minion
|
||||
import salt.utils
|
||||
from salt._compat import string_types
|
||||
|
||||
__func_alias__ = {
|
||||
@ -67,24 +68,41 @@ def ipcidr(tgt):
|
||||
return False
|
||||
|
||||
|
||||
def pillar(tgt, delim=':'):
|
||||
def pillar(tgt, delimiter=':', delim=None):
|
||||
'''
|
||||
Return True if the minion matches the given pillar target. The
|
||||
``delim`` argument can be used to specify a different delimiter.
|
||||
``delimiter`` argument can be used to specify a different delimiter.
|
||||
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' match.pillar 'cheese:foo'
|
||||
salt '*' match.pillar 'clone_url|https://github.com/saltstack/salt.git' delim='|'
|
||||
salt '*' match.pillar 'clone_url|https://github.com/saltstack/salt.git' delimiter='|'
|
||||
|
||||
.. versionchanged:: 0.16.4
|
||||
``delim`` argument added
|
||||
delimiter
|
||||
Specify an alternate delimiter to use when traversing a nested dict
|
||||
|
||||
.. versionadded:: 2014.7.0
|
||||
|
||||
delim
|
||||
Specify an alternate delimiter to use when traversing a nested dict
|
||||
|
||||
.. versionadded:: 0.16.4
|
||||
.. deprecated:: 2014.7.0
|
||||
'''
|
||||
if delim is not None:
|
||||
salt.utils.warn_until(
|
||||
'Beryllium',
|
||||
'The \'delim\' argument to match.pillar has been deprecated and '
|
||||
'will be removed in a future release. Please use \'delimiter\' '
|
||||
'instead.'
|
||||
)
|
||||
delimiter = delim
|
||||
|
||||
matcher = salt.minion.Matcher({'pillar': __pillar__}, __salt__)
|
||||
try:
|
||||
return matcher.pillar_match(tgt, delim=delim)
|
||||
return matcher.pillar_match(tgt, delim=delimiter)
|
||||
except Exception as exc:
|
||||
log.exception(exc)
|
||||
return False
|
||||
@ -108,32 +126,49 @@ def data(tgt):
|
||||
return False
|
||||
|
||||
|
||||
def grain_pcre(tgt, delim=':'):
|
||||
def grain_pcre(tgt, delimiter=':', delim=None):
|
||||
'''
|
||||
Return True if the minion matches the given grain_pcre target. The
|
||||
``delim`` argument can be used to specify a different delimiter.
|
||||
``delimiter`` argument can be used to specify a different delimiter.
|
||||
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' match.grain_pcre 'os:Fedo.*'
|
||||
salt '*' match.grain_pcre 'ipv6|2001:.*' delim='|'
|
||||
salt '*' match.grain_pcre 'ipv6|2001:.*' delimiter='|'
|
||||
|
||||
.. versionchanged:: 0.16.4
|
||||
``delim`` argument added
|
||||
delimiter
|
||||
Specify an alternate delimiter to use when traversing a nested dict
|
||||
|
||||
.. versionadded:: 2014.7.0
|
||||
|
||||
delim
|
||||
Specify an alternate delimiter to use when traversing a nested dict
|
||||
|
||||
.. versionadded:: 0.16.4
|
||||
.. deprecated:: 2014.7.0
|
||||
'''
|
||||
if delim is not None:
|
||||
salt.utils.warn_until(
|
||||
'Beryllium',
|
||||
'The \'delim\' argument to match.grain_pcre has been deprecated '
|
||||
'and will be removed in a future release. Please use '
|
||||
'\'delimiter\' instead.'
|
||||
)
|
||||
delimiter = delim
|
||||
|
||||
matcher = salt.minion.Matcher({'grains': __grains__}, __salt__)
|
||||
try:
|
||||
return matcher.grain_pcre_match(tgt, delim=delim)
|
||||
return matcher.grain_pcre_match(tgt, delim=delimiter)
|
||||
except Exception as exc:
|
||||
log.exception(exc)
|
||||
return False
|
||||
|
||||
|
||||
def grain(tgt, delim=':'):
|
||||
def grain(tgt, delimiter=':', delim=None):
|
||||
'''
|
||||
Return True if the minion matches the given grain target. The ``delim``
|
||||
Return True if the minion matches the given grain target. The ``delimiter``
|
||||
argument can be used to specify a different delimiter.
|
||||
|
||||
CLI Example:
|
||||
@ -141,14 +176,31 @@ def grain(tgt, delim=':'):
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' match.grain 'os:Ubuntu'
|
||||
salt '*' match.grain_pcre 'ipv6|2001:db8::ff00:42:8329' delim='|'
|
||||
salt '*' match.grain 'ipv6|2001:db8::ff00:42:8329' delimiter='|'
|
||||
|
||||
.. versionchanged:: 0.16.4
|
||||
``delim`` argument added
|
||||
delimiter
|
||||
Specify an alternate delimiter to use when traversing a nested dict
|
||||
|
||||
.. versionadded:: 2014.7.0
|
||||
|
||||
delim
|
||||
Specify an alternate delimiter to use when traversing a nested dict
|
||||
|
||||
.. versionadded:: 0.16.4
|
||||
.. deprecated:: 2014.7.0
|
||||
'''
|
||||
if delim is not None:
|
||||
salt.utils.warn_until(
|
||||
'Beryllium',
|
||||
'The \'delim\' argument to match.grain has been deprecated and '
|
||||
'will be removed in a future release. Please use \'delimiter\' '
|
||||
'instead.'
|
||||
)
|
||||
delimiter = delim
|
||||
|
||||
matcher = salt.minion.Matcher({'grains': __grains__}, __salt__)
|
||||
try:
|
||||
return matcher.grain_match(tgt, delim=delim)
|
||||
return matcher.grain_match(tgt, delim=delimiter)
|
||||
except Exception as exc:
|
||||
log.exception(exc)
|
||||
return False
|
||||
|
@ -17,7 +17,7 @@ from salt._compat import string_types
|
||||
__proxyenabled__ = ['*']
|
||||
|
||||
|
||||
def get(key, default='', merge=False, delim=':'):
|
||||
def get(key, default='', merge=False, delimiter=':'):
|
||||
'''
|
||||
.. versionadded:: 0.14
|
||||
|
||||
@ -43,7 +43,7 @@ def get(key, default='', merge=False, delim=':'):
|
||||
|
||||
.. versionadded:: 2014.7.0
|
||||
|
||||
delim
|
||||
delimiter
|
||||
Specify an alternate delimiter to use when traversing a nested dict
|
||||
|
||||
.. versionadded:: 2014.7.0
|
||||
@ -55,12 +55,15 @@ def get(key, default='', merge=False, delim=':'):
|
||||
salt '*' pillar.get pkg:apache
|
||||
'''
|
||||
if merge:
|
||||
ret = salt.utils.traverse_dict_and_list(__pillar__, key, {}, delim)
|
||||
ret = salt.utils.traverse_dict_and_list(__pillar__, key, {}, delimiter)
|
||||
if isinstance(ret, collections.Mapping) and \
|
||||
isinstance(default, collections.Mapping):
|
||||
return salt.utils.dictupdate.update(default, ret)
|
||||
|
||||
return salt.utils.traverse_dict_and_list(__pillar__, key, default, delim)
|
||||
return salt.utils.traverse_dict_and_list(__pillar__,
|
||||
key,
|
||||
default,
|
||||
delimiter)
|
||||
|
||||
|
||||
def items(*args):
|
||||
|
@ -1,35 +1,76 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
'''
|
||||
Display values only with simple data.
|
||||
=================================
|
||||
Display values only, separated by newlines
|
||||
==========================================
|
||||
|
||||
Example input 1::
|
||||
.. versionadded:: Lithium
|
||||
|
||||
This outputter is designed for Salt CLI return data. It will do the following
|
||||
to the return dict:
|
||||
|
||||
1. Get just the values (ignoring the minion IDs).
|
||||
2. Each value, if it is iterable, is split a separate line.
|
||||
3. Each minion's values are separated by newlines.
|
||||
|
||||
This results in a single string of return data containing all the values from
|
||||
the various minions.
|
||||
|
||||
.. warning::
|
||||
|
||||
As noted above, this outputter will discard the minion ID. If the minion ID
|
||||
is important, then an outputter that returns the full return dictionary in
|
||||
a parsable format (such as :mod:`json <salt.output.json>`, :mod:`pprint,
|
||||
<salt.output.pprint>`, or :mod:`yaml <salt.output.yaml>`) may be more
|
||||
suitable.
|
||||
|
||||
|
||||
Example 1
|
||||
~~~~~~~~~
|
||||
|
||||
Input
|
||||
-----
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
{
|
||||
'myminion': ["127.0.0.1", "10.0.0.1"],
|
||||
'second-minion': ["127.0.0.1", "10.0.0.2"]
|
||||
'myminion': ['127.0.0.1', '10.0.0.1'],
|
||||
'second-minion': ['127.0.0.1', '10.0.0.2']
|
||||
}
|
||||
|
||||
Example output 1::
|
||||
Output
|
||||
------
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
127.0.0.1
|
||||
10.0.0.1
|
||||
127.0.0.1
|
||||
10.0.0.2
|
||||
|
||||
Example input 2::
|
||||
Example 2
|
||||
~~~~~~~~~
|
||||
|
||||
Input
|
||||
-----
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
{
|
||||
'myminion': 8,
|
||||
'second-minion': 10
|
||||
'myminion': 8,
|
||||
'second-minion': 10
|
||||
}
|
||||
|
||||
Example output 2::
|
||||
Output
|
||||
------
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
8
|
||||
10
|
||||
'''
|
||||
|
||||
|
||||
def get_values(data):
|
||||
def _get_values(data):
|
||||
# This should be able to be improved
|
||||
# by parsing kargs from command line
|
||||
# instantiation.
|
||||
@ -46,16 +87,16 @@ def get_values(data):
|
||||
return values
|
||||
|
||||
|
||||
def one_level_values(data):
|
||||
return '\n'.join(string_list(get_values(data)))
|
||||
def _one_level_values(data):
|
||||
return '\n'.join(_string_list(_get_values(data)))
|
||||
|
||||
|
||||
def string_list(a_list):
|
||||
def _string_list(a_list):
|
||||
return [str(item) for item in a_list]
|
||||
|
||||
|
||||
def output(data):
|
||||
'''
|
||||
Rather basic....
|
||||
Display modified ret data
|
||||
'''
|
||||
return one_level_values(data)
|
||||
return _one_level_values(data)
|
||||
|
@ -150,12 +150,18 @@ def installed(name,
|
||||
ret['changes'] = {'old': [], 'new': pkgs_to_install}
|
||||
|
||||
if pkgs_satisfied:
|
||||
comment_msg.append('Package(s) {0!r} satisfied by {1}@{2}'
|
||||
.format(', '.join(pkgs_satisfied)))
|
||||
comment_msg.append('Package(s) {0!r} satisfied by {1}'
|
||||
.format(', '.join(pkg_list), ', '.join(pkgs_satisfied)))
|
||||
|
||||
ret['comment'] = '. '.join(comment_msg)
|
||||
return ret
|
||||
|
||||
if not pkgs_to_install:
|
||||
ret['result'] = True
|
||||
ret['comment'] = ('Package(s) {0!r} satisfied by {1}'
|
||||
.format(', '.join(pkg_list), ', '.join(pkgs_satisfied)))
|
||||
return ret
|
||||
|
||||
try:
|
||||
cmd_args = {
|
||||
'dir': dir,
|
||||
|
Loading…
Reference in New Issue
Block a user