Merge branch '2016.11' into '2017.7'

This commit is contained in:
Mike Place 2017-06-21 15:49:39 -06:00
commit 481797b147
No known key found for this signature in database
GPG Key ID: 9136F4F13705CFD3
14 changed files with 181 additions and 150 deletions

View File

@ -716,7 +716,7 @@ class RemoteFuncs(object):
load.get('saltenv', load.get('env')),
load.get('ext'),
self.mminion.functions,
pillar=load.get('pillar_override', {}))
pillar_override=load.get('pillar_override', {}))
pillar_dirs = {}
data = pillar.compile_pillar(pillar_dirs=pillar_dirs)
if self.opts.get('minion_data_cache', False):

View File

@ -556,7 +556,7 @@ def ssh_wrapper(opts, functions=None, context=None):
)
def render(opts, functions, states=None):
def render(opts, functions, states=None, proxy=None):
'''
Returns the render modules
'''
@ -564,6 +564,7 @@ def render(opts, functions, states=None):
'__grains__': opts.get('grains', {})}
if states:
pack['__states__'] = states
pack['__proxy__'] = proxy or {}
ret = LazyLoader(
_module_dirs(
opts,

View File

@ -1343,7 +1343,7 @@ class AESFuncs(object):
load['id'],
load.get('saltenv', load.get('env')),
ext=load.get('ext'),
pillar=load.get('pillar_override', {}),
pillar_override=load.get('pillar_override', {}),
pillarenv=load.get('pillarenv'))
data = pillar.compile_pillar(pillar_dirs=pillar_dirs)
self.fs_.update_opts()

View File

@ -214,7 +214,7 @@ def _gather_pillar(pillarenv, pillar_override):
__grains__,
__opts__['id'],
__opts__['environment'],
pillar=pillar_override,
pillar_override=pillar_override,
pillarenv=pillarenv
)
ret = pillar.compile_pillar()

View File

@ -49,7 +49,7 @@ def _gather_pillar(pillarenv, pillar_override):
__grains__,
__opts__['id'],
__opts__['environment'],
pillar=pillar_override,
pillar_override=pillar_override,
pillarenv=pillarenv
)
ret = pillar.compile_pillar()

View File

@ -5121,7 +5121,7 @@ def _gather_pillar(pillarenv, pillar_override, **grains):
# Not sure if these two are correct
__opts__['id'],
__opts__['environment'],
pillar=pillar_override,
pillar_override=pillar_override,
pillarenv=pillarenv
)
ret = pillar.compile_pillar()

View File

@ -139,6 +139,63 @@ def _netstat_linux():
return ret
def _ss_linux():
'''
Return ss information for Linux distros
(netstat is deprecated and may not be available)
'''
ret = []
cmd = 'ss -tulpnea'
out = __salt__['cmd.run'](cmd)
for line in out.splitlines():
comps = line.split()
ss_user = 0
ss_inode = 0
ss_program = ''
length = len(comps)
if line.startswith('tcp') or line.startswith('udp'):
i = 6
while i < (length - 1):
fields = comps[i].split(":")
if fields[0] == "users":
users = fields[1].split(",")
ss_program = users[0].split("\"")[1]
if fields[0] == "uid":
ss_user = fields[1]
if fields[0] == "ino":
ss_inode = fields[1]
i += 1
if line.startswith('tcp'):
ss_state = comps[1]
if ss_state == "ESTAB":
ss_state = "ESTABLISHED"
ret.append({
'proto': comps[0],
'recv-q': comps[2],
'send-q': comps[3],
'local-address': comps[4],
'remote-address': comps[5],
'state': ss_state,
'user': ss_user,
'inode': ss_inode,
'program': ss_program})
if line.startswith('udp'):
ret.append({
'proto': comps[0],
'recv-q': comps[2],
'send-q': comps[3],
'local-address': comps[4],
'remote-address': comps[5],
'user': ss_user,
'inode': ss_inode,
'program': ss_program})
return ret
def _netinfo_openbsd():
'''
Get process information for network connections using fstat
@ -409,7 +466,7 @@ def _netstat_route_linux():
'destination': comps[0],
'gateway': comps[1],
'netmask': '',
'flags': comps[3],
'flags': comps[2],
'interface': comps[5]})
elif len(comps) == 7:
ret.append({
@ -417,13 +474,109 @@ def _netstat_route_linux():
'destination': comps[0],
'gateway': comps[1],
'netmask': '',
'flags': comps[3],
'flags': comps[2],
'interface': comps[6]})
else:
continue
return ret
def _ip_route_linux():
'''
Return ip routing information for Linux distros
(netstat is deprecated and may not be available)
'''
# table main closest to old netstat inet output
ret = []
cmd = 'ip -4 route show table main'
out = __salt__['cmd.run'](cmd, python_shell=True)
for line in out.splitlines():
comps = line.split()
# need to fake similar output to that provided by netstat
# to maintain output format
if comps[0] == "unreachable":
continue
if comps[0] == "default":
ip_interface = ''
if comps[3] == "dev":
ip_interface = comps[4]
ret.append({
'addr_family': 'inet',
'destination': '0.0.0.0',
'gateway': comps[2],
'netmask': '0.0.0.0',
'flags': 'UG',
'interface': ip_interface})
else:
address_mask = convert_cidr(comps[0])
ip_interface = ''
if comps[1] == "dev":
ip_interface = comps[2]
ret.append({
'addr_family': 'inet',
'destination': address_mask['network'],
'gateway': '0.0.0.0',
'netmask': address_mask['netmask'],
'flags': 'U',
'interface': ip_interface})
# table all closest to old netstat inet6 output
cmd = 'ip -6 route show table all'
out = __salt__['cmd.run'](cmd, python_shell=True)
for line in out.splitlines():
comps = line.split()
# need to fake similar output to that provided by netstat
# to maintain output format
if comps[0] == "unreachable":
continue
if comps[0] == "default":
ip_interface = ''
if comps[3] == "dev":
ip_interface = comps[4]
ret.append({
'addr_family': 'inet6',
'destination': '::',
'gateway': comps[2],
'netmask': '',
'flags': 'UG',
'interface': ip_interface})
elif comps[0] == "local":
ip_interface = ''
if comps[2] == "dev":
ip_interface = comps[3]
local_address = comps[1] + "/128"
ret.append({
'addr_family': 'inet6',
'destination': local_address,
'gateway': '::',
'netmask': '',
'flags': 'U',
'interface': ip_interface})
else:
address_mask = convert_cidr(comps[0])
ip_interface = ''
if comps[1] == "dev":
ip_interface = comps[2]
ret.append({
'addr_family': 'inet6',
'destination': comps[0],
'gateway': '::',
'netmask': '',
'flags': 'U',
'interface': ip_interface})
return ret
def _netstat_route_freebsd():
'''
Return netstat routing information for FreeBSD and macOS
@ -607,7 +760,10 @@ def netstat():
salt '*' network.netstat
'''
if __grains__['kernel'] == 'Linux':
return _netstat_linux()
if not salt.utils.which('netstat'):
return _ss_linux()
else:
return _netstat_linux()
elif __grains__['kernel'] in ('OpenBSD', 'FreeBSD', 'NetBSD'):
return _netstat_bsd()
elif __grains__['kernel'] == 'SunOS':
@ -1445,7 +1601,10 @@ def routes(family=None):
raise CommandExecutionError('Invalid address family {0}'.format(family))
if __grains__['kernel'] == 'Linux':
routes_ = _netstat_route_linux()
if not salt.utils.which('netstat'):
routes_ = _ip_route_linux()
else:
routes_ = _netstat_route_linux()
elif __grains__['kernel'] == 'SunOS':
routes_ = _netstat_route_sunos()
elif __grains__['os'] in ['FreeBSD', 'MacOS', 'Darwin']:

View File

@ -257,13 +257,8 @@ def items(*args, **kwargs):
__opts__,
__grains__,
__opts__['id'],
<<<<<<< HEAD
pillar=pillar_override,
pillarenv=pillarenv)
=======
pillar_override=kwargs.get('pillar'),
pillarenv=kwargs.get('pillarenv') or __opts__['pillarenv'])
>>>>>>> 2016.11
return pillar.compile_pillar()

View File

@ -351,14 +351,7 @@ def high(data, test=None, queue=False, **kwargs):
'Pillar data must be formatted as a dictionary, unless pillar_enc '
'is specified.'
)
try:
<<<<<<< HEAD
st_ = salt.state.State(opts, pillar, pillar_enc=pillar_enc, proxy=__proxy__,
context=__context__)
except NameError:
st_ = salt.state.State(opts, pillar, pillar_enc=pillar_enc)
=======
st_ = salt.state.State(opts,
pillar_override,
pillar_enc=pillar_enc,
@ -370,7 +363,6 @@ def high(data, test=None, queue=False, **kwargs):
pillar_override,
pillar_enc=pillar_enc,
initial_pillar=_get_initial_pillar(opts))
>>>>>>> 2016.11
ret = st_.call_high(data)
_set_retcode(ret, highstate=data)
@ -836,7 +828,6 @@ def highstate(test=None, queue=False, **kwargs):
)
kwargs.pop('env')
<<<<<<< HEAD
if 'saltenv' in kwargs:
opts['environment'] = kwargs['saltenv']
@ -844,9 +835,7 @@ def highstate(test=None, queue=False, **kwargs):
opts['pillarenv'] = kwargs['pillarenv']
pillar = kwargs.get('pillar')
=======
pillar_override = kwargs.get('pillar')
>>>>>>> 2016.11
pillar_enc = kwargs.get('pillar_enc')
if pillar_enc is None \
and pillar_override is not None \
@ -1143,16 +1132,7 @@ def sls(mods, test=None, exclude=None, queue=False, **kwargs):
return ret
<<<<<<< HEAD
def top(topfn,
test=None,
queue=False,
saltenv=None,
pillarenv=None,
**kwargs):
=======
def top(topfn, test=None, queue=False, **kwargs):
>>>>>>> 2016.11
'''
Execute a specific top file instead of the default. This is useful to apply
configurations from a different environment (for example, dev or prod), without
@ -1192,17 +1172,7 @@ def top(topfn, test=None, queue=False, **kwargs):
opts = _get_opts(**kwargs)
opts['test'] = _get_test_value(test, **kwargs)
<<<<<<< HEAD
if saltenv is not None:
opts['environment'] = saltenv
if pillarenv is not None:
opts['pillarenv'] = pillarenv
pillar = kwargs.get('pillar')
=======
pillar_override = kwargs.get('pillar')
>>>>>>> 2016.11
pillar_enc = kwargs.get('pillar_enc')
if pillar_enc is None \
and pillar_override is not None \
@ -1326,7 +1296,6 @@ def show_lowstate(queue=False, **kwargs):
return ret
<<<<<<< HEAD
def show_state_usage(queue=False, **kwargs):
'''
Retrieve the highstate data from the salt master to analyse used and unused states
@ -1363,17 +1332,7 @@ def show_state_usage(queue=False, **kwargs):
return ret
def sls_id(
id_,
mods,
saltenv='base',
pillarenv=None,
test=None,
queue=False,
**kwargs):
=======
def sls_id(id_, mods, test=None, queue=False, **kwargs):
>>>>>>> 2016.11
'''
Call a single ID from the named module(s) and handle all requisites
@ -1411,24 +1370,6 @@ def sls_id(id_, mods, test=None, queue=False, **kwargs):
orig_test = __opts__.get('test', None)
opts = _get_opts(**kwargs)
opts['test'] = _get_test_value(test, **kwargs)
<<<<<<< HEAD
opts['environment'] = saltenv
if pillarenv is not None:
opts['pillarenv'] = pillarenv
pillar = kwargs.get('pillar')
pillar_enc = kwargs.get('pillar_enc')
if pillar_enc is None \
and pillar is not None \
and not isinstance(pillar, dict):
raise SaltInvocationError(
'Pillar data must be formatted as a dictionary, unless pillar_enc '
'is specified.'
)
try:
st_ = salt.state.HighState(opts, pillar=pillar, pillar_enc=pillar_enc, proxy=__proxy__)
=======
# Since this is running a specific ID within a specific SLS file, fall back
# to the 'base' saltenv if none is configured and none was passed.
@ -1439,7 +1380,6 @@ def sls_id(id_, mods, test=None, queue=False, **kwargs):
st_ = salt.state.HighState(opts,
proxy=__proxy__,
initial_pillar=_get_initial_pillar(opts))
>>>>>>> 2016.11
except NameError:
st_ = salt.state.HighState(opts,
initial_pillar=_get_initial_pillar(opts))
@ -1479,16 +1419,7 @@ def sls_id(id_, mods, test=None, queue=False, **kwargs):
return ret
<<<<<<< HEAD
def show_low_sls(mods,
saltenv='base',
pillarenv=None,
test=None,
queue=False,
**kwargs):
=======
def show_low_sls(mods, test=None, queue=False, **kwargs):
>>>>>>> 2016.11
'''
Display the low data from a specific sls. The default environment is
``base``, use ``saltenv`` to specify a different environment.
@ -1525,12 +1456,6 @@ def show_low_sls(mods, test=None, queue=False, **kwargs):
orig_test = __opts__.get('test', None)
opts = _get_opts(**kwargs)
opts['test'] = _get_test_value(test, **kwargs)
<<<<<<< HEAD
opts['environment'] = saltenv
if pillarenv is not None:
opts['pillarenv'] = pillarenv
st_ = salt.state.HighState(opts)
=======
# Since this is dealing with a specific SLS file (or files), fall back to
# the 'base' saltenv if none is configured and none was passed.
@ -1538,7 +1463,6 @@ def show_low_sls(mods, test=None, queue=False, **kwargs):
opts['environment'] = 'base'
st_ = salt.state.HighState(opts, initial_pillar=_get_initial_pillar(opts))
>>>>>>> 2016.11
if not _check_pillar(kwargs, st_.opts['pillar']):
__context__['retcode'] = 5

View File

@ -89,23 +89,10 @@ class AsyncRemotePillar(object):
self.channel = salt.transport.client.AsyncReqChannel.factory(opts)
if pillarenv is not None:
self.opts['pillarenv'] = pillarenv
<<<<<<< HEAD
elif self.opts.get('pillarenv_from_saltenv', False):
self.opts['pillarenv'] = saltenv
elif 'pillarenv' not in self.opts:
self.opts['pillarenv'] = None
self.pillar_override = {}
if pillar is not None:
if isinstance(pillar, dict):
self.pillar_override = pillar
else:
log.error('Pillar data must be a dictionary')
=======
self.pillar_override = pillar_override or {}
if not isinstance(self.pillar_override, dict):
self.pillar_override = {}
log.error('Pillar data must be a dictionary')
>>>>>>> 2016.11
@tornado.gen.coroutine
def compile_pillar(self):
@ -153,23 +140,10 @@ class RemotePillar(object):
self.channel = salt.transport.Channel.factory(opts)
if pillarenv is not None:
self.opts['pillarenv'] = pillarenv
<<<<<<< HEAD
elif self.opts.get('pillarenv_from_saltenv', False):
self.opts['pillarenv'] = saltenv
elif 'pillarenv' not in self.opts:
self.opts['pillarenv'] = None
self.pillar_override = {}
if pillar is not None:
if isinstance(pillar, dict):
self.pillar_override = pillar
else:
log.error('Pillar data must be a dictionary')
=======
self.pillar_override = pillar_override or {}
if not isinstance(self.pillar_override, dict):
self.pillar_override = {}
log.error('Pillar data must be a dictionary')
>>>>>>> 2016.11
def compile_pillar(self):
'''

View File

@ -76,20 +76,6 @@ class RunnerClient(mixins.SyncClientMixin, mixins.AsyncClientMixin, object):
'username', 'password', 'eauth', 'token', 'client', 'user', 'key',
] if i in low])
<<<<<<< HEAD
# Run name=value args through parse_input. We don't need to run kwargs
# through because there is no way to send name=value strings in the low
# dict other than by including an `arg` array.
arg, kwarg = salt.utils.args.parse_input(
low.pop('arg', []),
condition=False,
no_parse=self.opts.get('no_parse', []))
kwarg.update(low.pop('kwarg', {}))
# If anything hasn't been pop()'ed out of low by this point it must be
# an old-style kwarg.
kwarg.update(low)
=======
# Separate the new-style args/kwargs.
pre_arg = low.pop('arg', [])
pre_kwarg = low.pop('kwarg', {})
@ -108,7 +94,6 @@ class RunnerClient(mixins.SyncClientMixin, mixins.AsyncClientMixin, object):
old_new_normalized_input,
self.opts,
ignore_invalid=True)
>>>>>>> 2016.11
return dict(fun=fun, kwarg={'kwarg': kwarg, 'arg': arg},
**eauth_creds)

View File

@ -729,11 +729,6 @@ class State(object):
self.opts['grains'],
self.opts['id'],
self.opts['environment'],
<<<<<<< HEAD
pillar=self._pillar_override,
pillarenv=self.opts.get('pillarenv'))
return pillar.compile_pillar()
=======
pillar_override=self._pillar_override,
pillarenv=self.opts.get('pillarenv')
)
@ -771,7 +766,6 @@ class State(object):
merge_lists=merge_lists
)
return ret
>>>>>>> 2016.11
def _mod_init(self, low):
'''
@ -3815,11 +3809,7 @@ class HighState(BaseHighState):
self.client = salt.fileclient.get_file_client(self.opts)
BaseHighState.__init__(self, opts)
self.state = State(self.opts,
<<<<<<< HEAD
pillar,
=======
pillar_override,
>>>>>>> 2016.11
jid,
pillar_enc,
proxy=proxy,

View File

@ -147,6 +147,17 @@ class RunnerModuleTest(TestCase, AdaptedConfigurationTestCaseMixin):
ret = self.runner.cmd_sync(low)
self.assertEqual(ret[0], 'foo')
def test_invalid_kwargs_are_ignored(self):
low = {
'client': 'runner',
'fun': 'test.metasyntactic',
'thiskwargisbad': 'justpretendimnothere',
}
low.update(self.eauth_creds)
ret = self.runner.cmd_sync(low)
self.assertEqual(ret[0], 'foo')
if __name__ == '__main__':
from integration import run_tests

View File

@ -20,10 +20,8 @@ from tests.support.mock import (
# Import Salt Libs
import salt.utils
<<<<<<< HEAD:tests/unit/modules/test_state.py
import salt.modules.state as state
from salt.exceptions import SaltInvocationError
=======
from salt.modules import state
# Globals
@ -33,7 +31,6 @@ state.__opts__ = {'cachedir': '/D',
'environment': None,
'__cli': 'salt'}
state.__pillar__ = {}
>>>>>>> 2016.11:tests/unit/modules/state_test.py
class MockState(object):
@ -151,12 +148,7 @@ class MockState(object):
opts = {'state_top': '',
'pillar': {}}
<<<<<<< HEAD:tests/unit/modules/test_state.py
def __init__(self, opts, pillar=None, *args, **kwargs):
self.building_highstate = {}
=======
def __init__(self, opts, pillar_override=None, *args, **kwargs):
>>>>>>> 2016.11:tests/unit/modules/state_test.py
self.state = MockState.State(opts,
pillar_override=pillar_override)