%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python2.7/site-packages/salt/runners/
Upload File :
Create Path :
Current File : //lib/python2.7/site-packages/salt/runners/survey.pyo

�
���^c@@s}dZddlmZmZmZddlZddlmZddl	m
Z
ddlmZd�Z
d�Zd	�ZdS(
u
A general map/reduce style salt runner for aggregating results
returned by several different minions.

.. versionadded:: 2014.7.0

Aggregated results are sorted by the size of the minion pools which returned
matching results.

Useful for playing the game: *"some of these things are not like the others..."*
when identifying discrepancies in a large infrastructure managed by salt.
i(tabsolute_importtprint_functiontunicode_literalsN(tSaltClientError(tsix(trangecO@s
t||�S(u�
    Return the MATCHING minion pools from the aggregated and sorted results of
    a salt command

    .. versionadded:: 2014.7.0

    This command is submitted via a salt runner using the
    general form::

        salt-run survey.hash [survey_sort=up/down] <target>
                  <salt-execution-module> <salt-execution-module parameters>

    Optionally accept a ``survey_sort=`` parameter. Default: ``survey_sort=down``

    CLI Example #1: (functionally equivalent to ``salt-run manage.up``)

    .. code-block:: bash

        salt-run survey.hash "*" test.ping

    CLI Example #2: (find an "outlier" minion config file)

    .. code-block:: bash

        salt-run survey.hash "*" file.get_hash /etc/salt/minion survey_sort=up
    (t_get_pool_results(targstkwargs((s7/usr/lib/python2.7/site-packages/salt/runners/survey.pythashsc
O@s�ddl}t||�}t}x�|D]�}td�t|d�td�tdtjt|d���|r�t}td�td|dd�t�q(nd	j|ddd�}t|�td
t|�d�|ddj	�}x-t
dt|��D]}||cd7<qW|dj	�}	x-t
dt|	��D]}|	|cd7<qQWd
}|d
j|j||	d|dddd|dddd��7}t|�t�q(W|S(u&
    Return the DIFFERENCE of the result sets returned by each matching minion
    pool

    .. versionadded:: 2014.7.0

    These pools are determined from the aggregated and sorted results of
    a salt command.

    This command displays the "diffs" as a series of 2-way differences --
    namely the difference between the FIRST displayed minion pool
    (according to sort order) and EACH SUBSEQUENT minion pool result set.

    Differences are displayed according to the Python ``difflib.unified_diff()``
    as in the case of the salt execution module ``file.get_diff``.

    This command is submitted via a salt runner using the general form::

        salt-run survey.diff [survey_sort=up/down] <target>
                     <salt-execution-module> <salt-execution-module parameters>

    Optionally accept a ``survey_sort=`` parameter. Default:
    ``survey_sort=down``

    CLI Example #1: (Example to display the "differences of files")

    .. code-block:: bash

        salt-run survey.diff survey_sort=up "*" cp.get_file_str file:///etc/hosts
    iNuminion pool :
------------upoolupool size :
----------u    upool result :
------------uresultu differences from "{0}" results :u-iu
utfromfilettofiletn(
tdifflibRtTruetprintRt	text_typetlentFalsetformatt
splitlinesRtjointunified_diff(
RRR
tbulk_rett
is_first_timetktoutstfrom_resulttit	to_result((s7/usr/lib/python2.7/site-packages/salt/runners/survey.pytdiff:sB#


!



c
@s�ddl}|d}|d}i��jdd�}|dk}�jdd�}|dkrkd}nt�fd
�tj��D��}tjjtd�}	y3|	j	|||dd
tdd|d|�}
Wnt
k
r�}t|��SXx�t|
�D]�}|j
tj|
|�jt��j�}
|
�krzi�|
<g�|
d<tj|
|��|
d<n�|
dj|�qWg}x:t�d�fd�d|�D]}|j�|�q�W|S(u�
    A helper function which returns a dictionary of minion pools along with
    their matching result sets.
    Useful for developing other "survey style" functions.
    Optionally accepts a "survey_sort=up" or "survey_sort=down" kwargs for
    specifying sort order.
    Because the kwargs namespace of the "salt" and "survey" command are shared,
    the name "survey_sort" was chosen to help avoid option conflicts.
    iNiusurvey_sortudownuuputgt_typeucompoundupcrec3@s.|]$}|jd�s|�|fVqdS(u_N(t
startswith(t.0R(R(s7/usr/lib/python2.7/site-packages/salt/runners/survey.pys	<genexpr>�su	conf_fileittimeoututimeoutttgt_typetkwargupooluresulttkeyc@st�|d�S(Nupool(R(R(tret(s7/usr/lib/python2.7/site-packages/salt/runners/survey.pyt<lambda>�streverse(ucompoundupcre(thashlibtpoptdictRtiterkeystsalttclienttget_local_clientt__opts__tcmdRRtsortedtsha256Rtencodet__salt_system_encoding__t	hexdigesttappend(RRR(ttgtR0tsortt	directionR"tkwargs_passthruR-tminionstclient_errortminiontdigestt
sorted_retR((RR%s7/usr/lib/python2.7/site-packages/salt/runners/survey.pyR�s6

	%3
+
((t__doc__t
__future__RRRtsalt.clientR,tsalt.exceptionsRtsalt.extRtsalt.ext.six.movesRR	RR(((s7/usr/lib/python2.7/site-packages/salt/runners/survey.pyt<module>
s		M

Zerion Mini Shell 1.0