Set state_output_profile as option and update docs

This commit is contained in:
ScriptAutomate 2020-12-17 21:45:36 -06:00 committed by Megan Wilhite
parent 7a994b4910
commit b997a74922
5 changed files with 40 additions and 7 deletions

View file

@ -635,6 +635,10 @@
# states is cluttering the logs. Set it to True to ignore them.
#state_output_diff: False
# The state_output_profile setting changes whether profile information
# will be shown for each state run.
#state_output_profile: True
# Automatically aggregate all states that have support for mod_aggregate by
# setting to 'True'. Or pass a list of state module names to automatically
# aggregate just those types.

View file

@ -2518,6 +2518,20 @@ states is cluttering the logs. Set it to True to ignore them.
state_output_diff: False
.. conf_master:: state_output_profile
``state_output_profile``
------------------------
Default: ``True``
The ``state_output_profile`` setting changes whether profile information
will be shown for each state run.
.. code-block:: yaml
state_output_profile: True
.. conf_master:: state_aggregate
``state_aggregate``

View file

@ -2277,6 +2277,20 @@ states is cluttering the logs. Set it to True to ignore them.
state_output_diff: False
.. conf_minion:: state_output_profile
``state_output_profile``
------------------------
Default: ``True``
The ``state_output_profile`` setting changes whether profile information
will be shown for each state run.
.. code-block:: yaml
state_output_profile: True
.. conf_minion:: autoload_dynamic_modules
``autoload_dynamic_modules``

View file

@ -372,6 +372,8 @@ VALID_OPTS = immutabletypes.freeze(
"state_output": str,
# Tells the highstate outputter to only report diffs of states that changed
"state_output_diff": bool,
# Tells the highstate outputter whether profile information will be shown for each state run
"state_output_profile": bool,
# When true, states run in the order defined in an SLS file, unless requisites re-order them
"state_auto_order": bool,
# Fire events as state chunks are processed by the state compiler
@ -1145,6 +1147,7 @@ DEFAULT_MINION_OPTS = immutabletypes.freeze(
"state_verbose": True,
"state_output": "full",
"state_output_diff": False,
"state_output_profile": True,
"state_auto_order": True,
"state_events": False,
"state_aggregate": False,
@ -1478,6 +1481,7 @@ DEFAULT_MASTER_OPTS = immutabletypes.freeze(
"state_verbose": True,
"state_output": "full",
"state_output_diff": False,
"state_output_profile": True,
"state_auto_order": True,
"state_events": False,
"state_aggregate": False,

View file

@ -112,7 +112,6 @@ Example output with no special settings in configuration files:
Total: 0
"""
# Import python libs
import logging
import pprint
@ -120,8 +119,6 @@ import re
import textwrap
import salt.output
# Import salt libs
import salt.utils.color
import salt.utils.data
import salt.utils.stringutils
@ -356,7 +353,7 @@ def _format_host(host, data, indent_level=1):
" {tcolor} Result: {ret[result]!s}{colors[ENDC]}",
" {tcolor} Comment: {comment}{colors[ENDC]}",
]
if __opts__.get("state_output_profile", True) and "start_time" in ret:
if __opts__.get("state_output_profile") and "start_time" in ret:
state_lines.extend(
[
" {tcolor} Started: {ret[start_time]!s}{colors[ENDC]}",
@ -498,7 +495,7 @@ def _format_host(host, data, indent_level=1):
)
hstrs.append(colorfmt.format(colors["CYAN"], totals, colors))
if __opts__.get("state_output_profile", True):
if __opts__.get("state_output_profile"):
sum_duration = sum(rdurations)
duration_unit = "ms"
# convert to seconds if duration is 1000ms or more
@ -570,7 +567,7 @@ def _format_terse(tcolor, comps, ret, colors, tabular):
c=colors, w="\n".join(ret["warnings"])
)
fmt_string += "{0}"
if __opts__.get("state_output_profile", True) and "start_time" in ret:
if __opts__.get("state_output_profile") and "start_time" in ret:
fmt_string += "{6[start_time]!s} [{6[duration]!s:>7} ms] "
fmt_string += "{2:>10}.{3:<10} {4:7} Name: {1}{5}"
elif isinstance(tabular, str):
@ -582,7 +579,7 @@ def _format_terse(tcolor, comps, ret, colors, tabular):
c=colors, w="\n".join(ret["warnings"])
)
fmt_string += " {0} Name: {1} - Function: {2}.{3} - Result: {4}"
if __opts__.get("state_output_profile", True) and "start_time" in ret:
if __opts__.get("state_output_profile") and "start_time" in ret:
fmt_string += " Started: - {6[start_time]!s} Duration: {6[duration]!s} ms"
fmt_string += "{5}"