Merge branch '2016.3' into '2016.11'

No conflicts.
This commit is contained in:
rallytime 2017-01-27 11:52:03 -07:00
commit 76e95087fd
5 changed files with 33 additions and 39 deletions

View file

@ -96,9 +96,9 @@ variable in a Salt state.
.. code-block:: yaml
Create a file with contents from an environment variable:
file.managed:
- name: /tmp/hello
- contents: {{ salt['environ.get']('MYENVVAR') }}
file.managed:
- name: /tmp/hello
- contents: {{ salt['environ.get']('MYENVVAR') }}
Error checking:
@ -115,8 +115,7 @@ Error checking:
{% else %}
Fail - no environment passed in:
test:
A. fail_without_changes
test.fail_without_changes
{% endif %}

View file

@ -226,15 +226,8 @@ def item(*args, **kwargs):
'''
.. versionadded:: 0.16.2
Return one or more pillar entries
pillar
If specified, allows for a dictionary of pillar data to be made
available to pillar and ext_pillar rendering. these pillar variables
will also override any variables of the same name in pillar or
ext_pillar.
.. versionadded:: 2015.5.0
Return one or more pillar entries from the :ref:`in-memory pillar data
<pillar-in-memory>`.
delimiter
Delimiter used to traverse nested dictionaries.
@ -262,14 +255,14 @@ def item(*args, **kwargs):
'''
ret = {}
default = kwargs.get('default', '')
delimiter = kwargs.get('delimiter', ':')
delimiter = kwargs.get('delimiter', DEFAULT_TARGET_DELIM)
try:
for arg in args:
ret[arg] = salt.utils.traverse_dict_and_list(__pillar__,
arg,
default,
delimiter)
arg,
default,
delimiter)
except KeyError:
pass

View file

@ -31,7 +31,7 @@ class Depends(object):
cause the function to be unloaded (or replaced)
'''
# kind -> Dependency -> list of things that depend on it
dependency_dict = defaultdict(lambda: defaultdict(set))
dependency_dict = defaultdict(lambda: defaultdict(dict))
def __init__(self, *dependencies, **kwargs):
'''
@ -72,11 +72,11 @@ class Depends(object):
frame = inspect.stack()[1][0]
# due to missing *.py files under esky we cannot use inspect.getmodule
# module name is something like salt.loaded.int.modules.test
kind = frame.f_globals['__name__'].rsplit('.', 2)[1]
_, kind, mod_name = frame.f_globals['__name__'].rsplit('.', 2)
fun_name = function.__name__
for dep in self.dependencies:
self.dependency_dict[kind][dep].add(
(frame, function, self.fallback_function)
)
self.dependency_dict[kind][dep][(mod_name, fun_name)] = \
(frame, self.fallback_function)
except Exception as exc:
log.error('Exception encountered when attempting to inspect frame in '
'dependency decorator: {0}'.format(exc))
@ -90,46 +90,44 @@ class Depends(object):
It will modify the "functions" dict and remove/replace modules that
are missing dependencies.
'''
for dependency, dependent_set in six.iteritems(cls.dependency_dict[kind]):
# check if dependency is loaded
for frame, func, fallback_function in dependent_set:
# check if you have the dependency
for dependency, dependent_dict in six.iteritems(cls.dependency_dict[kind]):
for (mod_name, func_name), (frame, fallback_function) in six.iteritems(dependent_dict):
# check if dependency is loaded
if dependency is True:
log.trace(
'Dependency for {0}.{1} exists, not unloading'.format(
frame.f_globals['__name__'].split('.')[-1],
func.__name__,
mod_name,
func_name
)
)
continue
# check if you have the dependency
if dependency in frame.f_globals \
or dependency in frame.f_locals:
log.trace(
'Dependency ({0}) already loaded inside {1}, '
'skipping'.format(
dependency,
frame.f_globals['__name__'].split('.')[-1]
mod_name
)
)
continue
log.trace(
'Unloading {0}.{1} because dependency ({2}) is not '
'imported'.format(
frame.f_globals['__name__'],
func,
mod_name,
func_name,
dependency
)
)
# if not, unload dependent_set
# if not, unload the function
if frame:
try:
func_name = frame.f_globals['__func_alias__'][func.__name__]
func_name = frame.f_globals['__func_alias__'][func_name]
except (AttributeError, KeyError):
func_name = func.__name__
pass
mod_key = '{0}.{1}'.format(frame.f_globals['__name__'].split('.')[-1],
func_name)
mod_key = '{0}.{1}'.format(mod_name, func_name)
# if we don't have this module loaded, skip it!
if mod_key not in functions:

View file

@ -130,7 +130,6 @@ def query(key, keyid, method='GET', params=None, headers=None,
if not data:
data = None
response = None
if method == 'PUT':
if local_file:
with salt.utils.fopen(local_file, 'r') as data:
@ -148,6 +147,7 @@ def query(key, keyid, method='GET', params=None, headers=None,
data=data,
verify=verify_ssl,
stream=True)
response = result.content
else:
result = requests.request(method,
requesturl,

View file

@ -117,6 +117,7 @@ class ClearReqTestCases(BaseZMQReqCase, ReqChannelMixin):
raise tornado.gen.Return((payload, {'fun': 'send_clear'}))
@skipIf(True, 'Skipping flaky test until Jenkins is moved to C7.')
@skipIf(ON_SUSE, 'Skipping until https://github.com/saltstack/salt/issues/32902 gets fixed')
class AESReqTestCases(BaseZMQReqCase, ReqChannelMixin):
def setUp(self):
@ -142,6 +143,9 @@ class AESReqTestCases(BaseZMQReqCase, ReqChannelMixin):
'''
Test a variety of bad requests, make sure that we get some sort of error
'''
# TODO: This test should be re-enabled when Jenkins moves to C7.
# Once the version of salt-testing is increased to something newer than the September
# release of salt-testing, the @flaky decorator should be applied to this test.
msgs = ['', [], tuple()]
for msg in msgs:
with self.assertRaises(salt.exceptions.AuthenticationError):