mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Change how state_verbose output is filtered
Previously, a successful state that made no changes would not be added to the count of successful states if `state_verbose` is set to `True`, because the successful states with no changes made are filtered out before they are being iterated over. By moving the logic that filters states into the loop, after the code that has incremented the number of successful/changed states, the count will be correct while the output is still suppressed. Fixes #24009
This commit is contained in:
parent
8b69b41a42
commit
7790408c3c
1 changed files with 6 additions and 20 deletions
|
@ -111,10 +111,6 @@ def _format_host(host, data):
|
|||
hstrs.append((u'{0}----------\n {1}{2[ENDC]}'
|
||||
.format(hcolor, err, colors)))
|
||||
if isinstance(data, dict):
|
||||
# Strip out the result: True, without changes returns if
|
||||
# state_verbose is False
|
||||
if not __opts__.get('state_verbose', False):
|
||||
data = _strip_clean(data)
|
||||
# Verify that the needed data is present
|
||||
for tname, info in data.items():
|
||||
if isinstance(info, dict) and '__run_num__' not in info:
|
||||
|
@ -141,6 +137,12 @@ def _format_host(host, data):
|
|||
ret['result'] and not schanged:
|
||||
continue
|
||||
|
||||
# Skip this state if state_verbose is False, the result is True and
|
||||
# there were no changes made
|
||||
if not __opts__.get('state_verbose', False) and \
|
||||
ret['result'] and not schanged:
|
||||
continue
|
||||
|
||||
if schanged:
|
||||
tcolor = colors['CYAN']
|
||||
if ret['result'] is False:
|
||||
|
@ -393,22 +395,6 @@ def _format_changes(changes):
|
|||
return changed, ctext
|
||||
|
||||
|
||||
def _strip_clean(returns):
|
||||
'''
|
||||
Check for the state_verbose option and strip out the result=True
|
||||
and changes={} members of the state return list.
|
||||
'''
|
||||
rm_tags = []
|
||||
for tag in returns:
|
||||
if isinstance(tag, dict):
|
||||
continue
|
||||
if returns[tag]['result'] and not returns[tag]['changes']:
|
||||
rm_tags.append(tag)
|
||||
for tag in rm_tags:
|
||||
returns.pop(tag)
|
||||
return returns
|
||||
|
||||
|
||||
def _format_terse(tcolor, comps, ret, colors, tabular):
|
||||
'''
|
||||
Terse formatting of a message.
|
||||
|
|
Loading…
Add table
Reference in a new issue