mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge pull request #43501 from The-Loeki/high-out-cleanup
highstate output minor cleanup and code duplication removal
This commit is contained in:
commit
a454065c74
1 changed files with 16 additions and 20 deletions
|
@ -242,8 +242,15 @@ def _format_host(host, data):
|
|||
if ret['result'] is None:
|
||||
hcolor = colors['LIGHT_YELLOW']
|
||||
tcolor = colors['LIGHT_YELLOW']
|
||||
|
||||
state_output = __opts__.get('state_output', 'full').lower()
|
||||
comps = [sdecode(comp) for comp in tname.split('_|-')]
|
||||
if __opts__.get('state_output', 'full').lower() == 'filter':
|
||||
|
||||
if state_output == 'mixed_id':
|
||||
# Swap in the ID for the name. Refs #35137
|
||||
comps[2] = comps[1]
|
||||
|
||||
if state_output.startswith('filter'):
|
||||
# By default, full data is shown for all types. However, return
|
||||
# data may be excluded by setting state_output_exclude to a
|
||||
# comma-separated list of True, False or None, or including the
|
||||
|
@ -276,28 +283,17 @@ def _format_host(host, data):
|
|||
continue
|
||||
if str(ret['result']) in exclude:
|
||||
continue
|
||||
elif __opts__.get('state_output', 'full').lower() == 'terse':
|
||||
# Print this chunk in a terse way and continue in the
|
||||
# loop
|
||||
|
||||
elif any((
|
||||
state_output.startswith('terse'),
|
||||
state_output.startswith('mixed') and ret['result'] is not False, # only non-error'd
|
||||
state_output.startswith('changes') and ret['result'] and not schanged # non-error'd non-changed
|
||||
)):
|
||||
# Print this chunk in a terse way and continue in the loop
|
||||
msg = _format_terse(tcolor, comps, ret, colors, tabular)
|
||||
hstrs.append(msg)
|
||||
continue
|
||||
elif __opts__.get('state_output', 'full').lower().startswith('mixed'):
|
||||
if __opts__['state_output'] == 'mixed_id':
|
||||
# Swap in the ID for the name. Refs #35137
|
||||
comps[2] = comps[1]
|
||||
# Print terse unless it failed
|
||||
if ret['result'] is not False:
|
||||
msg = _format_terse(tcolor, comps, ret, colors, tabular)
|
||||
hstrs.append(msg)
|
||||
continue
|
||||
elif __opts__.get('state_output', 'full').lower() == 'changes':
|
||||
# Print terse if no error and no changes, otherwise, be
|
||||
# verbose
|
||||
if ret['result'] and not schanged:
|
||||
msg = _format_terse(tcolor, comps, ret, colors, tabular)
|
||||
hstrs.append(msg)
|
||||
continue
|
||||
|
||||
state_lines = [
|
||||
u'{tcolor}----------{colors[ENDC]}',
|
||||
u' {tcolor} ID: {comps[1]}{colors[ENDC]}',
|
||||
|
|
Loading…
Add table
Reference in a new issue