mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 17:09:03 +00:00
Merge pull request #35908 from rallytime/merge-develop
[develop] Merge forward from 2016.3 into develop
This commit is contained in:
commit
fb061a1619
@ -489,6 +489,26 @@ logs. The following code snippet demonstrates writing log messages:
|
||||
log.warning('You Should Not Do That')
|
||||
log.error('It Is Busted')
|
||||
|
||||
Aliasing Functions
|
||||
==================
|
||||
|
||||
Sometimes one wishes to use a function name that would shadow a python built-in.
|
||||
A common example would be ``set()``. To support this, append an underscore to
|
||||
the function defintion, ``def set_():``, and use the ``__func_alias__`` feature
|
||||
to provide an alias to the function.
|
||||
|
||||
``__func_alias__`` is a dictionary where each key is the name of a function in
|
||||
the module, and each value is a string representing the alias for that function.
|
||||
When calling an aliased function from a different execution module, state
|
||||
module, or from the cli, the alias name should be used.
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
__func_alias__ = {
|
||||
'set_': 'set',
|
||||
'list_': 'list',
|
||||
}
|
||||
|
||||
Private Functions
|
||||
=================
|
||||
|
||||
@ -514,12 +534,6 @@ Objects NOT Loaded into the Salt Minion
|
||||
|
||||
cheese = {} # Not a callable Python object
|
||||
|
||||
.. note::
|
||||
|
||||
Some callable names also end with an underscore ``_``, to avoid keyword clashes
|
||||
with Python keywords. When using execution modules, or state modules, with these
|
||||
in them the trailing underscore should be omitted.
|
||||
|
||||
Useful Decorators for Modules
|
||||
=============================
|
||||
|
||||
|
@ -97,14 +97,6 @@ def latest_version(*names, **kwargs):
|
||||
except (ValueError, IndexError):
|
||||
pass
|
||||
|
||||
pkgs = {}
|
||||
|
||||
for name in names:
|
||||
if not ret[name]:
|
||||
if not pkgs:
|
||||
pkgs = list_pkgs()
|
||||
if name in pkgs:
|
||||
ret[name] = pkgs[name]
|
||||
# Return a string if only one package name passed
|
||||
if len(names) == 1:
|
||||
return ret[names[0]]
|
||||
|
@ -598,7 +598,12 @@ def hypermedia_handler(*args, **kwargs):
|
||||
# Transform the output from the handler into the requested output format
|
||||
cherrypy.response.headers['Content-Type'] = best
|
||||
out = cherrypy.response.processors[best]
|
||||
return out(ret)
|
||||
try:
|
||||
return out(ret)
|
||||
except Exception:
|
||||
msg = 'Could not serialize the return data from Salt.'
|
||||
logger.debug(msg, exc_info=True)
|
||||
raise cherrypy.HTTPError(500, msg)
|
||||
|
||||
|
||||
def hypermedia_out():
|
||||
|
@ -1863,15 +1863,21 @@ def latest(
|
||||
problems = []
|
||||
for pkg in desired_pkgs:
|
||||
if not avail[pkg]:
|
||||
# Package either a) is up-to-date, or b) does not exist
|
||||
if not cur[pkg]:
|
||||
# Package does not exist
|
||||
msg = 'No information found for \'{0}\'.'.format(pkg)
|
||||
log.error(msg)
|
||||
problems.append(msg)
|
||||
elif watch_flags \
|
||||
and __grains__.get('os') == 'Gentoo' \
|
||||
and __salt__['portage_config.is_changed_uses'](pkg):
|
||||
targets[pkg] = avail[pkg]
|
||||
# Package is up-to-date, but Gentoo USE flags are changing so
|
||||
# we need to add it to the targets
|
||||
targets[pkg] = cur[pkg]
|
||||
else:
|
||||
# Package either a) is not installed, or b) is installed and has an
|
||||
# upgrade available
|
||||
targets[pkg] = avail[pkg]
|
||||
|
||||
if problems:
|
||||
|
@ -1733,12 +1733,14 @@ def fire_event(key, msg, tag, args=None, sock_dir=None, transport='zeromq'):
|
||||
'`salt.utils.cloud.fire_event` requires that the `sock_dir`'
|
||||
'parameter be passed in when calling the function.'
|
||||
)
|
||||
sock_dir = os.path.join(__opts__['sock_dir'], 'master')
|
||||
sock_dir = __opts__['sock_dir']
|
||||
|
||||
event = salt.utils.event.get_event(
|
||||
'master',
|
||||
sock_dir,
|
||||
transport,
|
||||
listen=False)
|
||||
|
||||
try:
|
||||
event.fire_event(msg, tag)
|
||||
except ValueError:
|
||||
|
Loading…
Reference in New Issue
Block a user