%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python2.7/site-packages/salt/output/
Upload File :
Create Path :
Current File : //usr/lib/python2.7/site-packages/salt/output/highstate.pyc

�
���^c@@s�dZddlmZmZmZddlZddlZddlZddlZ	ddl
Z	ddlZ	ddlZ	ddl
mZddlZeje�Zd�Zdd�Zd�Zed	�Zd
�ZdS(u�
Outputter for displaying results of state runs
==============================================

The return data from the Highstate command is a standard data structure
which is parsed by the highstate outputter to deliver a clean and readable
set of information about the HighState run on minions.

Two configurations can be set to modify the highstate outputter. These values
can be set in the master config to change the output of the ``salt`` command or
set in the minion config to change the output of the ``salt-call`` command.

state_verbose
    By default `state_verbose` is set to `True`, setting this to `False` will
    instruct the highstate outputter to omit displaying anything in green, this
    means that nothing with a result of True and no changes will not be printed
state_output:
    The highstate outputter has six output modes,
    ``full``, ``terse``, ``mixed``, ``changes`` and ``filter``

    * The default is set to ``full``, which will display many lines of detailed
      information for each executed chunk.

    * If ``terse`` is used, then the output is greatly simplified and shown in
      only one line.

    * If ``mixed`` is used, then terse output will be used unless a state
      failed, in which case full output will be used.

    * If ``changes`` is used, then terse output will be used if there was no
      error and no changes, otherwise full output will be used.

    * If ``filter`` is used, then either or both of two different filters can be
      used: ``exclude`` or ``terse``.

        * for ``exclude``, state.highstate expects a list of states to be excluded (or ``None``)
          followed by ``True`` for terse output or ``False`` for regular output.
          Because of parsing nuances, if only one of these is used, it must still
          contain a comma. For instance: `exclude=True,`.

        * for ``terse``, state.highstate expects simply ``True`` or ``False``.

      These can be set as such from the command line, or in the Salt config as
      `state_output_exclude` or `state_output_terse`, respectively.

    The output modes have one modifier:

    ``full_id``, ``terse_id``, ``mixed_id``, ``changes_id`` and ``filter_id``
    If ``_id`` is used, then the corresponding form will be used, but the value for ``name``
    will be drawn from the state ID. This is useful for cases where the name
    value might be very long and hard to read.

state_tabular:
    If `state_output` uses the terse output, set this to `True` for an aligned
    output format.  If you wish to use a custom format, this can be set to a
    string.

Example usage:

If ``state_output: filter`` is set in the configuration file:

.. code-block:: bash

    salt '*' state.highstate exclude=None,True


means to exclude no states from the highstate and turn on terse output.

.. code-block:: bash

    salt twd state.highstate exclude=problemstate1,problemstate2,False


means to exclude states ``problemstate1`` and ``problemstate2``
from the highstate, and use regular output.

Example output for the above highstate call when ``top.sls`` defines only
one other state to apply to minion ``twd``:

.. code-block:: text

    twd:

    Summary for twd
    ------------
    Succeeded: 1 (changed=1)
    Failed:    0
    ------------
    Total states run:     1


Example output with no special settings in configuration files:

.. code-block:: text

    myminion:
    ----------
              ID: test.ping
        Function: module.run
          Result: True
         Comment: Module function test.ping executed
         Changes:
                  ----------
                  ret:
                      True

    Summary for myminion
    ------------
    Succeeded: 1
    Failed:    0
    ------------
    Total:     0
i(tabsolute_importtprint_functiontunicode_literalsN(tsixc	K@s�g|j�D]}|jd�r
|^q
}d|j�koOt|�dk}|rb|d=nd|kr�|jd�}n|jdd�}gtj|�D]%\}}t||d|�d^q�}|r�dj|�St	j
d	|�d
S(u�
    The HighState Outputter is only meant to be used with the state.highstate
    function, or a function that returns highstate return data.
    u
.local_masteruretcodeiudatauindent_leveltindent_leveliu
uFData passed to highstate outputter is not a valid highstate return: %su(tkeystendswithtlentpoptgetRt	iteritemst_format_hosttjointlogterror(	tdatatkwargstkeyt
local_masterstorchestrator_outputRthostthostdatatret((s9/usr/lib/python2.7/site-packages/salt/output/highstate.pytoutput�s.$
8
ic4@s�
tjjj|�}tjjjtjd�tjd��}tjdt�}i}g}|d}g}d}	tjdt	�}
t
�t�s�t
�tj
�r�d}	|jdj|�|��|d	}nt
�t�ra|d
}|jdj||��xW�D]L}|
r>tjjtjjj|��}n|jdj|||��qWnt
�t�r�
i}x�tj��D]�\}
}t
|t�r�|
d
k	r�|r�d|kr�d}|jdtj|��|jd|�nt
|t�r�d|kr�|||
<q�q�W|�x�t�d�fd��D]�}
�|
}|j|dd�||dcd7<|jdd�}y|jt|��Wnptk
r|jd�\}}}y|jt|��Wqtk
rtjd|jdd��qXnX|d}|jd�dgkr�t|d
dd|d�}tj ddh|d|d tj!�}t	}|	d7}	n,t"|d
�\}}|	|r�dnd7}	tjd!t�r�|dr�|r�q?ntjd"t�r|dr|rq?n|r|d	}n|dtkrB|d#}|d#}n|ddikri|d$}|d$}ntjd%d&�j$�}|
j%d'�}|j&d(�r�|d|d)<n|j'd*�rtjd+g�}i}x8|D]0}t
|t�r�d,|kr�|j(�}q�q�W|jd-tjd.g��}t
|tj
�r]tj)|�j%d/�}n|jd0tjd1g��}t
|tj
�r�tj)|�j%d/�}ntj)|d�|kr�t*|||||�}|j|�q?ntj)|d�|kr�q?q�n|t+|j'd0�|j'd2�o9|dtk	|j'd
�oV|doV|f�r�t*|||||�}|j|�q?nd3d4d5d6d7g}tjd8t	�r�d9|kr�|j,d:d;g�n|d|d)kr�|jd<d=�ny4t
|d>tj)�s-tj)|d>�|d><nWn.t-k
r^tjj.j/|d>�|d><nXy9tjjj|d>�}|j0�j1dddj�}Wn{t2k
ry'|d>j3d�j1dddk�}Wqt2k
rtj)|d>�}|j0�j1dddl�}qXnXd@|kr�t
|d@t�r_x�|d@D]}dAj||�}q@Wq�t
|d@t�r�xL|d@j4�D]!\} }!dBj|| |!�}q�Wq�dAj||d@�}nx$d9dgD]}"|j|"dC�q�W|ddCkr	dDj|d�|d<ni|dE6|dF6|dG6tjjj|�d>6|dH6}#|j,g|D]}$|$j|#�^qZ	�dI|}%|jdJj||%|��dK|kr?|jdKd�|dKcd7<t5j6dLdMdNdmdOdn�}&|jdPj|&j7dj3|dK��j8�dQ|��q?q?WdJ}'idRt	6dSt6dTdi6dUdK6}(t9gtj:|�D]})t;tj)|)��^q`
p�
dg�}*t9gtj:|(�D]})t;|)�^q�
p�
dg�}+|+|*d)�|j|'j|d	dVj|dW��|���fdX�},g}-di|krs|jdid�dkrs|-j|'j|d$dYj|jdid��|��n|	dkr�|-j|'j|ddZj|	�|��n|-r�d[jd\j3|-��}-ndC}-|j|'j|d|,|(t	|jt	d�|jdid��|�|-�|jtd�}.|j|'j|.rM|d#n|d	|,|(t|.�|��|jdKd�}/|/r�|j|'j|d
|,|(dK|/�|��nd]jdW�t<tj:|��|jdKd��d^�}0|j|'j|d	|0|��tjd8t	�r�
t<|�}1d_}2|1d`krU
|1da:}1db}2ndcjddj|1�j=�de�|2�}3|j|'j|d	|3|��q�
n|
r�
tjj|�}n|jddfj|||��dj3|�|	dkfS(ou�
    Main highstate formatter. can be called recursively if a nested highstate
    contains other highstates (ie in an orchestration)
    ucolorucolor_themeu
state_tabularuGREENiustrip_colorsiu{0}    {1}{2[ENDC]}uCYANu	LIGHT_REDu'    {0}Data failed to compile:{1[ENDC]}u{0}----------
    {1}{2[ENDC]}uchangesu__run_num__usThe State execution failed to record the order in which all states were executed. The state return missing data is:uresultRc@s�|jdd�S(Nu__run_num__i(R	(tk(R(s9/usr/lib/python2.7/site-packages/salt/output/highstate.pyt<lambda>�sudurationu msu%Cannot parse a float from duration %sunameu
state.orchustate.orchestrateu	state.slsureturnRu^u iu
tflagsustate_output_diffu
state_verboseuREDuLIGHT_YELLOWustate_outputufullu_|-u_idiufilteruargu	__kwarg__uexcludeustate_output_excludeu,uterseustate_output_terseumixedu {tcolor}----------{colors[ENDC]}u.    {tcolor}      ID: {comps[1]}{colors[ENDC]}u9    {tcolor}Function: {comps[0]}.{comps[3]}{colors[ENDC]}u3    {tcolor}  Result: {ret[result]!s}{colors[ENDC]}u-    {tcolor} Comment: {comment}{colors[ENDC]}ustate_output_profileu
start_timeu7    {tcolor} Started: {ret[start_time]!s}{colors[ENDC]}u5    {tcolor}Duration: {ret[duration]!s}{colors[ENDC]}iu.    {tcolor}    Name: {comps[2]}{colors[ENDC]}ucommenti
udatau{0} {1}u{0}
		{1}: {2}uu{0} msutcolorucompsuretucolorsu     Changes:   u{0}{1}{2[ENDC]}uwarningstwidthiPtinitial_indenttsubsequent_indentu2   {colors[LIGHT_RED]} Warnings: {0}{colors[ENDC]}tcolorsu	SucceededuFaileduNot RunuWarningsu
Summary for {0}
{1}u-c@s!dj||�t|�d�S(Nu
{0}: {1:>{2}}i(tformatR(tlabeltcount(tline_max_len(s9/usr/lib/python2.7/site-packages/salt/output/highstate.pyt_counts�su
unchanged={0}uchanged={0}u ({0})u, u{0}
Total states run: {1:>{2}}iumsi�i�usuTotal run time: {0} {1}u{0:.3f}iu{0}{1}:{2[ENDC]}(u
state.orchustate.orchestrateu	state.slsu              Nu              u
             u              u              u              (>tsalttutilsRtdecodetcolort
get_colorst__opts__R	tFalsetTruet
isinstancetintRtstring_typestappendRtlistRtstrip_esc_sequencetdictR
tinserttpprinttpformattsortedt
setdefaulttfloatt
ValueErrort	partitionR
Rtretsubt	MULTILINEt_format_changestNonetlowertsplitRt
startswithtcopyt	text_typet
_format_tersetanytextendtUnicodeDecodeErrortstringutilst
to_unicodetstriptreplacetAttributeErrorRtitemsttextwraptTextWrappertfilltlstriptmaxt
itervaluesRtsumtrjust(4RRRRttabulartrcountst
rdurationsthcolorthstrstnchangeststrip_colorsterrtdata_tmpttnametinfoRt	rdurationt_ttcolortnestedtctexttschangedtstate_outputtcompstcliargst	clikwargstitemtexcludettersetmsgtstate_linestcommentRtvaluetdetailtsvarstslinetchangestwrappertcolorfmttrlabeltxt
count_max_lent
label_max_lenR#tchangestatst
num_failedtnum_warningsttotalstsum_durationt
duration_unitttotal_duration((RR"s9/usr/lib/python2.7/site-packages/salt/output/highstate.pyR�s�
!



	-


$
&





	

	&
	


!


)
		""@7
$

"


"
 
		&cC@s,d}|tjj|dtdd�7}|S(u;
    Print the changes data using the nested outputter
    u
unestedt
nested_indenti(R$Rt
out_formatR)(RvR((s9/usr/lib/python2.7/site-packages/salt/output/highstate.pyt_nested_changes�s
c	C@s|stdfS|r&tt|�fSt|t�sHtdj|�fS|jd�}|dk	r�|jd�dkr�d}t}xztj	|�D]T\}}t
||�\}}|ddjd�|j�D��7}|p�|}q�Wnt}t|�}||fS(	u;
    Format the changes dict based on what the data is
    uuInvalid Changes data: {0}uretuoutu	highstateu
cs@s|]}d|VqdS(u iNu              ((t.0tl((s9/usr/lib/python2.7/site-packages/salt/output/highstate.pys	<genexpr>sN(
R*R+R�R,R2RR	R?RR
RRt
splitlines(	Rvt
orchestrationRRftchangedRRtstc((s9/usr/lib/python2.7/site-packages/salt/output/highstate.pyR>s"
!'c	C@s�d}|drd}n|dtkr2d}n|ddkrKd}n|tkr�d}d|kr�|d	jd
|ddj|d��7}n|d
7}tjdt�r�d|kr�|d7}n|d7}n�t|tj	�r�|}n}d}d|kr0|djd
|ddj|d��7}n|d7}tjdt�red|kre|d7}n|d7}|j||d|d|d||d|�}|S(u(
    Terse formatting of a message.
    uCleanuchangesuChangeduresultuFaileduDiffersuuwarningsu%{c[LIGHT_RED]}Warnings:
{w}{c[ENDC]}
R�twu
u{0}ustate_output_profileu
start_timeu*{6[start_time]!s} [{6[duration]!s:>7} ms] u${2:>10}.{3:<10} {4:7}   Name: {1}{5}u${c[LIGHT_RED]}Warnings:
{w}{c[ENDC]}u0 {0} Name: {1} - Function: {2}.{3} - Result: {4}u: Started: - {6[start_time]!s} Duration: {6[duration]!s} msu{5}iii����uENDCN(
R*R?R+RRR)R	R,RR.(RdRiRRRWtresultt
fmt_stringRo((s9/usr/lib/python2.7/site-packages/salt/output/highstate.pyREsD
			 


	 


		(t__doc__t
__future__RRRR4R;ROtsalt.utils.colorR$tsalt.utils.datatsalt.utils.stringutilstsalt.outputtsalt.extRtloggingt	getLoggert__name__R
RRR�R*R>RE(((s9/usr/lib/python2.7/site-packages/salt/output/highstate.pyt<module>rs"	#�I	


Zerion Mini Shell 1.0