%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python2.7/site-packages/salt/utils/
Upload File :
Create Path :
Current File : //lib/python2.7/site-packages/salt/utils/state.pyc

�
���^c@@s�dZddlmZmZmZddlZddlmZddlm	Z	ddl
Ze�Z
d�Zd�Zd�Zedd	�Zdd
�Zd�ZdS(uC
Utility functions for state functions

.. versionadded:: 2018.3.0
i(tabsolute_importtprint_functiontunicode_literalsN(tsix(tCommandExecutionErrorcC@s
dj|�S(uJ
    Generate the running dict tag string from the low data structure
    u/{0[state]}_|-{0[__id__]}_|-{0[name]}_|-{0[fun]}(tformat(tlow((s4/usr/lib/python2.7/site-packages/salt/utils/state.pytgen_tagscC@s�g}d|kr'tjj|�}n
i|d6}x�tj|�D]�\}}||dkrfqDqDx�tj|�D]p\}}t|tj�sv|jd�r�qvqvt|t�s�qvqvt	}xE|D]=}	t|	t
�s�q�n|	jdt�t	k}|r�Pq�q�W|sqvnx�|D]�}	t|	t
�s;q nx�tj|	�D]�\}
}|
dkriqKnxr|D]j}xatj|�D]P\}
}||dko�|
|jd|
�ks�q�n|j
|||f�q�WqpWqKWq WqvWqDW|S(uK
    For a particular low chunk, search relevant onfail related states
    u_|-u__id__u__uonfail_stopuonfailustate(tsalttstatet
split_low_tagRt	iteritemst
isinstancetstring_typest
startswithtlisttFalsetdicttgettTruetappend(tsidt	highstatetonfailststtfstatetfchunkstmod_tfchunktonfail_handledtfdatatknobtfvaluetfreqstfmodtfid((s4/usr/lib/python2.7/site-packages/salt/utils/state.pytsearch_onfail_requisitessH

	

.c	C@sWd}|rS|rS|rSt|t�rSt||�}|rSx|D]}|\}}}	x�tj|�D]�\}
}d|
kr�tjj|
�}n;|j	d|
�}
|
s�t
d��ni|
d6|d6}||dkrh||dkrh|j	dt�}|tt
gkr|}n|tkr0Pq0qhqhW|dkrCt}qCqCWqSn|S(u�
    When a state fail and is part of a highstate, check
    if there is onfail requisites.
    When we find onfail requisites, we will consider the state failed
    only if at least one of those onfail requisites also failed

    Returns:

        True: if onfail handlers suceeded
        False: if one on those handler failed
        None: if the state does not have onfail requisites

    u_|-u__id__uno state idustateuresultN(tNoneRRR$RRRR	R
Rt
ValueErrort_emptyRR(tstate_idtstate_resulttrunningRtnretRthandlerRRRtrstateidtrstateRtid_tofresult((s4/usr/lib/python2.7/site-packages/salt/utils/state.pytcheck_onfail_requisitesPs.
 	cC@s+t|t�stS|stSt}xtj|�D]�\}}t}d|krZt}n|rzt||�rzt}n|r�t|t�r�|jdt�}|tkr�t}q�|tkr�t|t�r�|r�t	|dtd|�}q�n|st
t||||��}n|s3Pq3q3W|S(uf
    Check the total return value of the run and determine if the running
    dict has any issues
    u
__extend__uresulttrecurseR(RRRRRRRRR'tcheck_resulttboolR1(R*R2RtretR(R)t
expected_typetresult((s4/usr/lib/python2.7/site-packages/salt/utils/state.pyR3~s0			!cC@s�|s|d}n|dtkr4|d|d<n|d}t|t�sY|g}n|jdg�t|dt�r�|dj|�n6|dr�|dcd7<n|dcdj|�7<|dr�|jdi�|d|d|<n|S(u
    Update an existing state return (`original_return`) in place
    with another state return (`sub_return`), i.e. for a subresource.

    Returns:
        dict: The updated state return.

    The existing state return does not need to have all the required fields,
    as this is meant to be called from the internals of a state function,
    but any existing data will be kept and respected.

    It is important after using this function to check the return value
    to see if it is False, in which case the main state should return.
    Prefer to check `_ret['result']` instead of `ret['result']`,
    as the latter field may not yet be populated.

    Code Example:

    .. code-block:: python
        def state_func(name, config, alarm=None):
            ret = {'name': name, 'comment': '', 'changes': {}}
            if alarm:
                _ret = __states__['subresource.managed'](alarm)
                __utils__['state.merge_subreturn'](ret, _ret)
                if _ret['result'] is False:
                    return ret
    unameuresultucommentu
uchanges(RRRt
setdefaulttextendtjoin(toriginal_returnt
sub_returntsubkeytsub_comment((s4/usr/lib/python2.7/site-packages/salt/utils/state.pytmerge_subreturn�s"



cK@s:tj|�}d|kr5tjj|dd|�Sd|kr�|d}|dk	r�t|tj�s{tj	|�}n|dr�||dkr�t
d��n|d|d<q�nd|ks�|jdt�r6|jd�p�|jd�}|dk	r)t|tj�r)tj	|�|d<q6||d<n|S(	uR
    Return a copy of the opts for use, optionally load a local config on top
    ulocalconfigtdefaultsusaltenvulock_saltenvu2lock_saltenv is enabled, saltenv cannot be changedu	pillarenvupillarenv_from_saltenvN(
tcopytdeepcopyRtconfigt
minion_configR%RRR
t	text_typeRRR(toptstkwargstsaltenvt	pillarenv((s4/usr/lib/python2.7/site-packages/salt/utils/state.pytget_sls_opts�s$

(t__doc__t
__future__RRRRAtsalt.extRtsalt.exceptionsRt
salt.stateRtobjectR'RR$R1RR%R3R?RJ(((s4/usr/lib/python2.7/site-packages/salt/utils/state.pyt<module>s			5	.&6

Zerion Mini Shell 1.0