%PDF- %PDF-
Mini Shell

Mini Shell

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

�
���^c@@s�dZddlmZmZmZddlZddlZddlZddlZddl	m
Z
ddlZddl
ZddlZddlZddlZddlZddlZddlmZddlmZdgZeje�Zeededdd�Zd	�Zej j!j"ed
�Z#d�Z$d�Z%d
�Z&d�Z'dd�Z(dd�Z)ed�Z*dd�Z+eZ,dddd�Z-dS(u)
Extract the pillar data for this minion
i(tabsolute_importtprint_functiontunicode_literalsN(tsix(tDEFAULT_TARGET_DELIM(tCommandExecutionErroru*cC@stjd�s'|tkr'd}q'n|dkrEtjdt�n|}td�||fD��rmtntd|d|�}|r�t|t	�rt
jjj
||i|�}	t|	tj�r�tj|�}t
jjj||	d|�Stjd||	t|	�j�q�t|t�r�t
jjj
||g|�}	t|	t�r�tj|�}|jg|	D]}
|
|krl|
^ql�|Stjd	||	t|	�j�q�tjd
|t|�j�nt
jjj
||||�}	|	tkrtdj|���n|	S(
u�

    .. versionadded:: 0.14

    Attempt to retrieve the named value from :ref:`in-memory pillar data
    <pillar-in-memory>`. If the pillar key is not present in the in-memory
    pillar, then the value specified in the ``default`` option (described
    below) will be returned.

    If the merge parameter is set to ``True``, the default will be recursively
    merged into the returned pillar data.

    The value can also represent a value in a nested dict using a ":" delimiter
    for the dict. This means that if a dict in pillar looks like this::

        {'pkg': {'apache': 'httpd'}}

    To retrieve the value associated with the ``apache`` key in the ``pkg``
    dict this key can be passed as::

        pkg:apache

    key
        The pillar key to get value from

    default
        The value specified by this option will be returned if the desired
        pillar key does not exist.

        If a default value is specified, then it will be an empty string,
        unless :conf_minion:`pillar_raise_on_missing` is set to ``True``, in
        which case an error will be raised.

    merge : ``False``
        If ``True``, the retrieved values will be merged into the passed
        default. When the default and the retrieved value are both
        dictionaries, the dictionaries will be recursively merged.

        .. versionadded:: 2014.7.0
        .. versionchanged:: 2016.3.7,2016.11.4,2017.7.0
            If the default and the retrieved value are not of the same type,
            then merging will be skipped and the retrieved value will be
            returned. Earlier releases raised an error in these cases.

    merge_nested_lists
        If set to ``False``, lists nested within the retrieved pillar
        dictionary will *overwrite* lists in ``default``. If set to ``True``,
        nested lists will be *merged* into lists in ``default``. If unspecified
        (the default), this option is inherited from the
        :conf_minion:`pillar_merge_lists` minion config option.

        .. note::
            This option is ignored when ``merge`` is set to ``False``.

        .. versionadded:: 2016.11.6

    delimiter
        Specify an alternate delimiter to use when traversing a nested dict.
        This is useful for when the desired key contains a colon. See CLI
        example below for usage.

        .. versionadded:: 2014.7.0

    pillarenv
        If specified, this function will query the master to generate fresh
        pillar data on the fly, specifically from the requested pillar
        environment. Note that this can produce different pillar data than
        executing this function without an environment, as its normal behavior
        is just to return a value from minion's pillar data in memory (which
        can be sourced from more than one pillar environment).

        Using this argument will not affect the pillar data in memory. It will
        however be slightly slower and use more resources on the master due to
        the need for the master to generate and send the minion fresh pillar
        data. This tradeoff in performance however allows for the use case
        where pillar data is desired only from a single environment.

        .. versionadded:: 2017.7.0

    saltenv
        Included only for compatibility with
        :conf_minion:`pillarenv_from_saltenv`, and is otherwise ignored.

        .. versionadded:: 2017.7.0

    CLI Example:

    .. code-block:: bash

        salt '*' pillar.get pkg:apache
        salt '*' pillar.get abc::def|ghi delimiter='|'
    upillar_raise_on_missinguupillar_merge_listscs@s|]}|dkVqdS(N(tNone(t.0tx((s7/usr/lib/python2.7/site-packages/salt/modules/pillar.pys	<genexpr>�stsaltenvt	pillarenvtmerge_listsunpillar.get: Default (%s) is a dict, but the returned pillar value (%s) is of type '%s'. Merge will be skipped.unpillar.get: Default (%s) is a list, but the returned pillar value (%s) is of type '%s'. Merge will be skipped.uapillar.get: Default (%s) is of type '%s', must be a dict or list to merge. Merge will be skipped.uPillar key not found: {0}N(t__opts__tgettKeyErrorRtFalsetallt
__pillar__titemst
isinstancetdicttsalttutilstdatattraverse_dict_and_listtcollectionstMappingtcopytdeepcopyt
dictupdatetupdatetlogterrorttypet__name__tlisttextendtformat(tkeytdefaulttmergetmerge_nested_listst	delimiterR
R	topt_merge_liststpillar_dicttretR((s7/usr/lib/python2.7/site-packages/salt/modules/pillar.pyR
 s\b$"		,	cO@s"|rt|�S|jd�}|dkrftjdt�rY|jd�pStd}qftd}n|jd�}|jd�}|r�|r�y2tjjj||dt	dtdtd	�}Wq�t
k
r�}td
j|���q�Xntj
jtttdd|d
|�}|j�S(uQ
    Calls the master for a fresh pillar and generates the pillar data on the
    fly

    Contrast with :py:func:`raw` which returns the pillar data that is
    currently loaded into the minion.

    pillar
        If specified, allows for a dictionary of pillar data to be made
        available to pillar and ext_pillar rendering. these pillar variables
        will also override any variables of the same name in pillar or
        ext_pillar.

        .. versionadded:: 2015.5.0

    pillar_enc
        If specified, the data passed in the ``pillar`` argument will be passed
        through this renderer to decrypt it.

        .. note::
            This will decrypt on the minion side, so the specified renderer
            must be set up on the minion for this to work. Alternatively,
            pillar data can be decrypted master-side. For more information, see
            the :ref:`Pillar Encryption <pillar-encryption>` documentation.
            Pillar data that is decrypted master-side, is not decrypted until
            the end of pillar compilation though, so minion-side decryption
            will be necessary if the encrypted pillar data must be made
            available in an decrypted state pillar/ext_pillar rendering.

        .. versionadded:: 2017.7.0

    pillarenv
        Pass a specific pillar environment from which to compile pillar data.
        If not specified, then the minion's :conf_minion:`pillarenv` option is
        not used, and if that also is not specified then all configured pillar
        environments will be merged into a single pillar dictionary and
        returned.

        .. versionadded:: 2016.11.2

    saltenv
        Included only for compatibility with
        :conf_minion:`pillarenv_from_saltenv`, and is otherwise ignored.

    CLI Example:

    .. code-block:: bash

        salt '*' pillar.items
    u	pillarenvupillarenv_from_saltenvusaltenvupillaru
pillar_encttranslate_newlinestoptst
valid_rendudecrypt_pillar_renderersu&Failed to decrypt pillar override: {0}uidtpillar_overrideR
N(titemR
RRRRRtcrypttdecrypttTruet	ExceptionRR%tpillart
get_pillart
__grains__tcompile_pillar(targstkwargsR
R1t
pillar_enctexcR7((s7/usr/lib/python2.7/site-packages/salt/modules/pillar.pyR�s64

	
	udatacC@s�t|ttjjjf�r>|jd�tj|�D��St|t	t
tf�rpt|�d�|D��Sdj
|jj�SdS(u�
    Recursive obfuscation of collection types.

    Leaf or unknown Python types get replaced by the type name
    Known collection types trigger recursion.
    In the special case of mapping types, keys are not obfuscated
    cs@s'|]\}}|t|�fVqdS(N(t_obfuscate_inner(RR&tval((s7/usr/lib/python2.7/site-packages/salt/modules/pillar.pys	<genexpr>%scs@s|]}t|�VqdS(N(R?(Rtv((s7/usr/lib/python2.7/site-packages/salt/modules/pillar.pys	<genexpr>(su<{0}>N(RRRRtodicttOrderedDictt	__class__Rt	iteritemsR#tsetttupleR!R%R"(tvar((s7/usr/lib/python2.7/site-packages/salt/modules/pillar.pyR?scG@stt|��S(u4
    .. versionadded:: 2015.8.0

    Same as :py:func:`items`, but replace pillar values with a simple type indication.

    This is useful to avoid displaying sensitive information on console or
    flooding the console with long output, such as certificates.
    For many debug or control purposes, the stakes lie more in dispatching than in
    actual values.

    In case the value is itself a collection type, obfuscation occurs within the value.
    For mapping types, keys are not obfuscated.
    Here are some examples:

    * ``'secret password'`` becomes ``'<str>'``
    * ``['secret', 1]`` becomes ``['<str>', '<int>']``
    * ``{'login': 'somelogin', 'pwd': 'secret'}`` becomes
      ``{'login': '<str>', 'pwd': '<str>'}``

    CLI Examples:

    .. code-block:: bash

        salt '*' pillar.obfuscate

    (R?R(R;((s7/usr/lib/python2.7/site-packages/salt/modules/pillar.pyt	obfuscate-scG@stt|��S(u
    .. versionadded:: 2015.8.0

    Calls the master for a fresh pillar, generates the pillar data on the
    fly (same as :py:func:`items`), but only shows the available main keys.

    CLI Examples:

    .. code-block:: bash

        salt '*' pillar.ls
    (R#R(R;((s7/usr/lib/python2.7/site-packages/salt/modules/pillar.pytlsMsc	O@s�i}|jdd�}|jdt�}|jdd	�}|jdd	�}td�||fD��rptntd|d|�}y7x0|D](}tjjj	||||�||<q�WWnt
k
r�nX|S(
u@
    .. versionadded:: 0.16.2

    Return one or more pillar entries from the :ref:`in-memory pillar data
    <pillar-in-memory>`.

    delimiter
        Delimiter used to traverse nested dictionaries.

        .. note::
            This is different from :py:func:`pillar.get
            <salt.modules.pillar.get>` in that no default value can be
            specified. :py:func:`pillar.get <salt.modules.pillar.get>` should
            probably still be used in most cases to retrieve nested pillar
            values, as it is a bit more flexible. One reason to use this
            function instead of :py:func:`pillar.get <salt.modules.pillar.get>`
            however is when it is desirable to retrieve the values of more than
            one key, since :py:func:`pillar.get <salt.modules.pillar.get>` can
            only retrieve one key at a time.

        .. versionadded:: 2015.8.0

    pillarenv
        If specified, this function will query the master to generate fresh
        pillar data on the fly, specifically from the requested pillar
        environment. Note that this can produce different pillar data than
        executing this function without an environment, as its normal behavior
        is just to return a value from minion's pillar data in memory (which
        can be sourced from more than one pillar environment).

        Using this argument will not affect the pillar data in memory. It will
        however be slightly slower and use more resources on the master due to
        the need for the master to generate and send the minion fresh pillar
        data. This tradeoff in performance however allows for the use case
        where pillar data is desired only from a single environment.

        .. versionadded:: 2017.7.6,2018.3.1

    saltenv
        Included only for compatibility with
        :conf_minion:`pillarenv_from_saltenv`, and is otherwise ignored.

        .. versionadded:: 2017.7.6,2018.3.1

    CLI Examples:

    .. code-block:: bash

        salt '*' pillar.item foo
        salt '*' pillar.item foo:bar
        salt '*' pillar.item foo bar baz
    udefaultuu	delimiteru	pillarenvusaltenvcs@s|]}|dkVqdS(N(R(RR((s7/usr/lib/python2.7/site-packages/salt/modules/pillar.pys	<genexpr>�sR	R
N(R
RRRRRRRRRR(	R;R<R-R'R*R
R	R,targ((s7/usr/lib/python2.7/site-packages/salt/modules/pillar.pyR2^s"5"

cC@s%|rtj|i�}nt}|S(u�
    Return the raw pillar data that is currently loaded into the minion.

    Contrast with :py:func:`items` which calls the master to fetch the most
    up-to-date Pillar.

    CLI Example:

    .. code-block:: bash

        salt '*' pillar.raw

    With the optional key argument, you can select a subtree of the
    pillar raw data.::

        salt '*' pillar.raw key='roles'
    (RR
(R&R-((s7/usr/lib/python2.7/site-packages/salt/modules/pillar.pytraw�sc	C@sit|tj�r*tjjj|�}ntjjt	t
t	dt	dd|d|�}|j�}|S(u
    .. versionchanged:: 2016.3.6,2016.11.3,2017.7.0
        The supported ext_pillar types are now tunable using the
        :conf_master:`on_demand_ext_pillar` config option. Earlier releases
        used a hard-coded default.

    Generate the pillar and apply an explicit external pillar


    external
        A single ext_pillar to add to the ext_pillar configuration. This must
        be passed as a single section from the ext_pillar configuration (see
        CLI examples below). For more complicated ``ext_pillar``
        configurations, it can be helpful to use the Python shell to load YAML
        configuration into a dictionary, and figure out

        .. code-block:: python

            >>> import salt.utils.yaml
            >>> ext_pillar = salt.utils.yaml.safe_load("""
            ... ext_pillar:
            ...   - git:
            ...     - issue38440 https://github.com/terminalmage/git_pillar:
            ...       - env: base
            ... """)
            >>> ext_pillar
            {'ext_pillar': [{'git': [{'mybranch https://github.com/myuser/myrepo': [{'env': 'base'}]}]}]}
            >>> ext_pillar['ext_pillar'][0]
            {'git': [{'mybranch https://github.com/myuser/myrepo': [{'env': 'base'}]}]}

        In the above example, the value to pass would be
        ``{'git': [{'mybranch https://github.com/myuser/myrepo': [{'env': 'base'}]}]}``.
        Note that this would need to be quoted when passing on the CLI (as in
        the CLI examples below).

    pillar : None
        If specified, allows for a dictionary of pillar data to be made
        available to pillar and ext_pillar rendering. These pillar variables
        will also override any variables of the same name in pillar or
        ext_pillar.

        .. versionadded:: 2015.5.0

    CLI Examples:

    .. code-block:: bash

        salt '*' pillar.ext '{libvirt: _}'
        salt '*' pillar.ext "{'git': ['master https://github.com/myuser/myrepo']}"
        salt '*' pillar.ext "{'git': [{'mybranch https://github.com/myuser/myrepo': [{'env': 'base'}]}]}"
    uidusaltenvtextR1(RRtstring_typesRRtyamlt	safe_loadR7R8RR9R:(texternalR7t
pillar_objR-((s7/usr/lib/python2.7/site-packages/salt/modules/pillar.pyRM�s4	
	cC@sstjjjt|t|�}|tkrBtdj|���nt|t�sit	dj|���nt
|�S(u�
    .. versionadded:: 2015.8.0

    Attempt to retrieve a list of keys from the named value from the pillar.

    The value can also represent a value in a nested dict using a ":" delimiter
    for the dict, similar to how pillar.get works.

    delimiter
        Specify an alternate delimiter to use when traversing a nested dict

    CLI Example:

    .. code-block:: bash

        salt '*' pillar.keys web:sites
    uPillar key not found: {0}u%Pillar value in key {0} is not a dict(RRRRRRR%RRt
ValueErrorR#(R&R*R-((s7/usr/lib/python2.7/site-packages/salt/modules/pillar.pytkeysscC@s�tjd�}|s$td��n|rQ||krJi|||6}qQtSnxL|D]D}x;||D]/}tjj||�}td|�ritSqiWqXWtS(u�
    .. versionadded:: 2016.3.0

    This is a master-only function. Calling from the minion is not supported.

    Use the given path and search relative to the pillar environments to see if
    a file exists at that path.

    If the ``saltenv`` argument is given, restrict search to that environment
    only.

    Will only work with ``pillar_roots``, not external pillars.

    Returns True if the file is found, and False otherwise.

    path
        The path to the file in question. Will be treated as a relative path

    saltenv
        Optional argument to restrict the search to a specific saltenv

    CLI Example:

    .. code-block:: bash

        salt '*' pillar.file_exists foo/bar.sls
    upillar_rootsu:No pillar_roots found. Are you running this on the master?ufile.file_exists(	RR
RRtostpathtjoint__salt__R5(RVR	tpillar_rootstenvt
pillar_dirt	full_path((s7/usr/lib/python2.7/site-packages/salt/modules/pillar.pytfile_exists%s
udefaultc
C@s4tjjjd|d|dtd|d|d|�S(u
    .. versionadded:: 2017.7.0

    Look up the given pillar in a given dictionary and return the result

    :param lookup_dict: A dictionary, keyed by a pillar, containing a value or
        values relevant to systems matching that pillar. For example, a key
        could be a pillar for a role and the value could the name of a package
        on that particular OS.

        The dictionary key can be a globbing pattern. The function will return
        the corresponding ``lookup_dict`` value where the pilalr value matches
        the  pattern. For example:

        .. code-block:: bash

            # this will render 'got some salt' if ``role`` begins with 'salt'
            salt '*' pillar.filter_by '{salt*: got some salt, default: salt is not here}' role

    :param pillar: The name of a pillar to match with the system's pillar. For
        example, the value of the "role" pillar could be used to pull values
        from the ``lookup_dict`` dictionary.

        The pillar value can be a list. The function will return the
        ``lookup_dict`` value for a first found item in the list matching
        one of the ``lookup_dict`` keys.

    :param merge: A dictionary to merge with the results of the pillar
        selection from ``lookup_dict``. This allows another dictionary to
        override the values in the ``lookup_dict``.

    :param default: default lookup_dict's key used if the pillar does not exist
        or if the pillar value has no match on lookup_dict.  If unspecified
        the value is "default".

    :param base: A lookup_dict key to use for a base dictionary.  The
        pillar-selected ``lookup_dict`` is merged over this and then finally
        the ``merge`` dictionary is merged.  This allows common values for
        each case to be collected in the base and overridden by the pillar
        selection dictionary and the merge dictionary.  Default is unset.

    CLI Example:

    .. code-block:: bash

        salt '*' pillar.filter_by '{web: Serve it up, db: I query, default: x_x}' role
    tlookup_dicttlookupttraverseR(R'tbase(RRRt	filter_byR(R^R7R(R'Ra((s7/usr/lib/python2.7/site-packages/salt/modules/pillar.pyRbYs4(.t__doc__t
__future__RRRRRRUtloggingtsalt.extRtsalt.pillarRtsalt.utils.crypttsalt.utils.datatsalt.utils.dictupdatetsalt.utils.functoolstsalt.utils.odicttsalt.utils.yamlt
salt.defaultsRtsalt.exceptionsRt__proxyenabled__t	getLoggerR"RRRRR
RRt	functoolstalias_functionRR?RIRJR2RLRMRTR]tfetchRb(((s7/usr/lib/python2.7/site-packages/salt/modules/pillar.pyt<module>sJ	�	Y		 		LC1

Zerion Mini Shell 1.0