%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/defaults.pyc

�
���^c@@s�dZddlmZmZmZddlZddlZddlZddlZ	ddl
Z	ddljj
Z
ddlZ	ddlZ	ddlZ	ddlZ	dZeje�Zd�Zd�Zdd�Zeed	�Zd
�Zeed�ZdS(u2
Module to work with salt formula defaults files

i(tabsolute_importtprint_functiontunicode_literalsNudefaultscC@s)dtkr%tjjt�td<ndS(u8
    Create a file client and add it to the context
    u
cp.fileclientN(t__context__tsaltt
fileclienttget_file_clientt__opts__(((s9/usr/lib/python2.7/site-packages/salt/modules/defaults.pyt
_mk_clientsc
C@sGt�g}x8dD]0}tjjj|d|�}|j|�qWtdj|�}x�|D]�}|stqbn|jdd�d}|dkr�tjj	j
}n1|dkr�tjjj}nt
jd|�qbtjj|�rbt
jd	|�tjjj|��#}||�}	t
jd
|	�WdQX|	p>iSqbWdS(
u�
    Generates a list of salt://<formula>/defaults.(json|yaml) files
    and fetches them from the Salt master.

    Returns first defaults file as python dict.
    uyamlujsonu
/defaults.u
cp.fileclientu.ii����u!Failed to determine loader for %ruReading defaults from %ruRead defaults %rN(uyamlujson(RRtutilsturltcreatetappendRtcache_filestrsplittyamlt	safe_loadtjsontloadtlogtdebugtostpathtexiststfilestfopen(
tformulatpathstextt
source_urltdefaults_filestfile_tsuffixtloadertfhrtdefaults((s9/usr/lib/python2.7/site-packages/salt/modules/defaults.pyt_load"s,	

ucC@sgd|kr'|jdd�\}}n
|d}}t|�}|r_tjjj|||�S|SdS(u
    defaults.get is used much like pillar.get except that it will read
    a default value for a pillar from defaults.json or defaults.yaml
    files that are stored in the root of a salt formula.

    CLI Example:

    .. code-block:: bash

        salt '*' defaults.get core:users:root

    The defaults is computed from pillar key. The first entry is considered as
    the formula namespace.

    For example, querying ``core:users:root`` will try to load
    ``salt://core/defaults.yaml`` and ``salt://core/defaults.json``.
    u:iN(tsplittNoneR$RR	tdatattraverse_dict_and_list(tkeytdefaultt	namespaceR#((s9/usr/lib/python2.7/site-packages/salt/modules/defaults.pytgetJs
cC@s4|r|}ntj|�}tj||d|�S(u
    defaults.merge
        Allows deep merging of dicts in formulas.

    merge_lists : False
        If True, it will also merge lists instead of replace their items.

    in_place : True
        If True, it will merge into dest dict,
        if not it will make a new copy from that dict and return it.

        CLI Example:
        .. code-block:: bash

        salt '*' default.merge a=b d=e

    It is more typical to use this in a templating language in formulas,
    instead of directly on the command-line.
    tmerge_lists(tcopytdeepcopyt
dictupdatetupdate(tdesttsrcR-tin_placetmerged((s9/usr/lib/python2.7/site-packages/salt/modules/defaults.pytmergems	cC@s
tj|�S(u2
    defaults.deepcopy
        Allows deep copy of objects in formulas.

        By default, Python does not copy objects,
        it creates bindings between a target and an object.

    It is more typical to use this in a templating language in formulas,
    instead of directly on the command-line.
    (R.R/(tsource((s9/usr/lib/python2.7/site-packages/salt/modules/defaults.pyR/�scC@sg|r|}nt|�}xE|j�D]7\}}t|�}t||d|�}|||<q(W|S(u)
    defaults.update
        Allows to set defaults for group of data set e.g. group for nodes.

        This function is a combination of defaults.merge
        and defaults.deepcopy to avoid redundant in jinja.

        Example:

        .. code-block:: yaml

            group01:
              defaults:
                enabled: True
                extra:
                  - test
                  - stage
              nodes:
                host01:
                  index: foo
                  upstream: bar
                host02:
                  index: foo2
                  upstream: bar2

        .. code-block:: jinja

            {% do salt['defaults.update'](group01.nodes, group01.defaults) %}

        Each node will look like the following:

        .. code-block:: yaml

            host01:
              enabled: True
              index: foo
              upstream: bar
              extra:
                - test
                - stage

    merge_lists : True
        If True, it will also merge lists instead of replace their items.

    in_place : True
        If True, it will merge into dest dict.
        if not it will make a new copy from that dict and return it.

    It is more typical to use this in a templating language in formulas,
    instead of directly on the command-line.
    R-(R/titemsR6(R2R#R-R4tnodest	node_namet	node_varst
defaults_vars((s9/usr/lib/python2.7/site-packages/salt/modules/defaults.pyR1�s5	(t__doc__t
__future__RRRR.tloggingRtsalt.fileclientRtsalt.utils.datatsalt.utils.dictupdateR	R0tsalt.utils.filestsalt.utils.jsontsalt.utils.urltsalt.utils.yamlt__virtualname__t	getLoggert__name__RRR$R,tFalsetTrueR6R/R1(((s9/usr/lib/python2.7/site-packages/salt/modules/defaults.pyt<module>s&			(#	

Zerion Mini Shell 1.0