Set loglevel for cmds with a lot of output to TRACE

This commit also fixes the recently-added function pkg.owner. It did not
successfully handle file paths containing spaces, and it did not conform
to the way Salt handles other package information queries (i.e.
version(), latest_version(), etc.)
This commit is contained in:
Erik Johnson 2014-05-07 10:41:34 -05:00
parent f71e043fce
commit eea84cd15a

View File

@ -1534,16 +1534,30 @@ def expand_repo_def(repokwargs):
def owner(*paths):
'''
Return the name of the package that owns the specified file. Files may be
passed as a string (``path``) or as a list of strings (``paths``). If
``path`` contains a comma, it will be converted to ``paths``. If a file
name legitimately contains a comma, pass it in via ``paths``.
.. versionadded:: Helium
Return the name of the package that owns the file. Multiple file paths can
be passed. Like :mod:`pkg.version <salt.modules.yumpkg.version`, if a
single path is passed, a string will be returned, and if multiple paths are
passed, a dictionary of file/package name pairs will be returned.
If the file is not owned by a package, or is not present on the minion,
then an empty string will be returned for that path.
CLI Example:
salt '*' pkg.owner /usr/bin/apachectl
salt '*' pkg.owner /usr/bin/apachectl /etc/httpd/conf/httpd.conf
'''
cmd = "rpm -qf --queryformat '%{{NAME}}' {0}"
return salt.utils.pkg.find_owner(
__salt__['cmd.run'], cmd, *paths)
if not paths:
return ''
ret = {}
cmd = 'rpm -qf --queryformat "%{NAME}" {0!r}'
for path in paths:
ret[path] = __salt__['cmd.run_stdout'](cmd.format(path),
output_loglevel='debug')
if 'not owned' in ret[path].lower():
ret[path] = ''
if len(ret) == 1:
return ret.values()[0]
return ret