%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /proc/thread-self/root/lib/python2.7/site-packages/salt/client/ssh/wrapper/
Upload File :
Create Path :
Current File : //proc/thread-self/root/lib/python2.7/site-packages/salt/client/ssh/wrapper/grains.pyc

�
���^c@@sGdZddlmZmZddlZddlZddlZddlZddl	Zddl
ZddlmZddl
mZddlmZiZd�Zd�Zd	�Zd
�Zied6ed6ed
6ed6ed6ed6ed6Zdeed�Zd�Zed�Zd�Zd�Zddddd�ZdS(s+
Return/control aspects of the grains data
i(tabsolute_importtprint_functionN(tDEFAULT_TARGET_DELIM(t
SaltException(tsixcC@sAt|�}ttj|d��}dj|| d||�S(s4
    Replaces the last 1/4 of a string with X's
    g�?s{0}{1}tX(tlentinttmathtfloortformat(tinstrtlengthtindex((sB/usr/lib/python2.7/site-packages/salt/client/ssh/wrapper/grains.pyt_serial_sanitizerscC@sdS(NsMINION.DOMAINNAME((tx((sB/usr/lib/python2.7/site-packages/salt/client/ssh/wrapper/grains.pyt<lambda>#scC@sdS(NtMINION((R((sB/usr/lib/python2.7/site-packages/salt/client/ssh/wrapper/grains.pyR$scC@sdS(Nt
DOMAINNAME((R((sB/usr/lib/python2.7/site-packages/salt/client/ssh/wrapper/grains.pyR%stserialnumbertdomaintfqdntidthostt	localhosttnodenametcC@sU|tkrt}n$tjjjtjjjt��}tjjjt|||�S(s2
    Attempt to retrieve the named value from grains, if the named value is not
    available return the passed default. The default return is an empty string.

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

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

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

        pkg:apache

    CLI Example:

    .. code-block:: bash

        salt '*' grains.get pkg:apache
    (	tTruet
__grains__tsalttutilstjsontloadstdumpstdatattraverse_dict_and_list(tkeytdefaultt	delimitertorderedtgrains((sB/usr/lib/python2.7/site-packages/salt/client/ssh/wrapper/grains.pytget5s	$cC@s#tjjjt|t�rtStS(sl
    Determine whether a named value exists in the grains dictionary.

    Given a grains dictionary that contains the following structure::

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

    One would determine if the apache key in the pkg dict exists by::

        pkg:apache

    CLI Example:

    .. code-block:: bash

        salt '*' grains.has_value pkg:apache
    (RRR"R#RtFalseR(R$((sB/usr/lib/python2.7/site-packages/salt/client/ssh/wrapper/grains.pyt	has_valueUscC@sptjjj|�rhtt�}x@tjt�D]/\}}||kr1|||�||<q1q1W|StSdS(s�
    Return all of the minion's grains

    CLI Example:

    .. code-block:: bash

        salt '*' grains.items

    Sanitized CLI Example:

    .. code-block:: bash

        salt '*' grains.items sanitize=True
    N(	RRR"tis_truetdictRRt	iteritemst_SANITIZERS(tsanitizetoutR$tfunc((sB/usr/lib/python2.7/site-packages/salt/client/ssh/wrapper/grains.pytitemslscO@s�i}x4|D],}yt|||<Wq
tk
r8q
Xq
Wtjjj|jd��r�xCtjt	�D]/\}}||krk|||�||<qkqkWn|S(s
    Return one or more grains

    CLI Example:

    .. code-block:: bash

        salt '*' grains.item os
        salt '*' grains.item os osrelease oscodename

    Sanitized CLI Example:

    .. code-block:: bash

        salt '*' grains.item host sanitize=True
    R0(
RtKeyErrorRRR"R,R)RR.R/(targstkwargstrettargR2((sB/usr/lib/python2.7/site-packages/salt/client/ssh/wrapper/grains.pytitem�s

cC@s
tt�S(sw
    Return a list of all available grains

    CLI Example:

    .. code-block:: bash

        salt '*' grains.ls
    (tsortedR(((sB/usr/lib/python2.7/site-packages/salt/client/ssh/wrapper/grains.pytls�s
t	os_familyR%cC@s|jtj||�|j|d��}|r�||kr�||}|dkr[|}q�t|tj�r�t|tj�s�td��ntjj	j
tj|�|�}q�n|r
t|tj�s�td��q
|dkr�|}q
tjj	j
||�n|S(s�
    .. versionadded:: 0.17.0

    Look up the given grain in a given dictionary for the current OS and return
    the result

    Although this may occasionally be useful at the CLI, the primary intent of
    this function is for use in Jinja to make short work of creating lookup
    tables for OS-specific data. For example:

    .. code-block:: jinja

        {% set apache = salt['grains.filter_by']({
            'Debian': {'pkg': 'apache2', 'srv': 'apache2'},
            'RedHat': {'pkg': 'httpd', 'srv': 'httpd'},
        }), default='Debian' %}

        myapache:
          pkg.installed:
            - name: {{ apache.pkg }}
          service.running:
            - name: {{ apache.srv }}

    Values in the lookup table may be overridden by values in Pillar. An
    example Pillar to override values in the example above could be as follows:

    .. code-block:: yaml

        apache:
          lookup:
            pkg: apache_13
            srv: apache

    The call to ``filter_by()`` would be modified as follows to reference those
    Pillar values:

    .. code-block:: jinja

        {% set apache = salt['grains.filter_by']({
            ...
        }, merge=salt['pillar.get']('apache:lookup')) %}


    :param lookup_dict: A dictionary, keyed by a grain, containing a value or
        values relevant to systems matching that grain. For example, a key
        could be the grain for an OS and the value could the name of a package
        on that particular OS.
    :param grain: The name of a grain to match with the current system's
        grains. For example, the value of the "os_family" grain for the current
        system could be used to pull values from the ``lookup_dict``
        dictionary.
    :param merge: A dictionary to merge with the ``lookup_dict`` before doing
        the lookup. This allows Pillar to override the values in the
        ``lookup_dict``. This could be useful, for example, to override the
        values for non-standard package names such as when using a different
        Python version from the default Python version provided by the OS
        (e.g., ``python26-mysql`` instead of ``python-mysql``).
    :param default: default lookup_dict's key used if the grain does not exists
         or if the grain value has no match on lookup_dict.

         .. versionadded:: 2014.1.0

    :param base: A lookup_dict key to use for a base dictionary. The
        grain-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 grain
        selection dictionary and the merge dictionary. Default is None.

        .. versionadded:: 2015.8.11,2016.3.2

    CLI Example:

    .. code-block:: bash

        salt '*' grains.filter_by '{Debian: Debheads rule, RedHat: I love my hat}'
        # this one will render {D: {E: I, G: H}, J: K}
        salt '*' grains.filter_by '{A: B, C: {D: {E: F,G: H}}}' 'xxx' '{D: {E: I},J: K}' 'C'
    s?filter_by default and look-up values must both be dictionaries.s.filter_by merge argument must be a dictionary.N(
R)RtNonet
isinstancetcollectionstMappingRRRt
dictupdatetupdatetcopytdeepcopy(tlookup_dicttgraintmergeR%tbaseR7tbase_values((sB/usr/lib/python2.7/site-packages/salt/client/ssh/wrapper/grains.pyt	filter_by�s(S	
	'	( t__doc__t
__future__RRR?RCRtsalt.utils.dataRtsalt.utils.dictupdatetsalt.utils.jsont
salt.defaultsRtsalt.exceptionsRtsalt.extRRRt_FQDN_SANITIZERt_HOSTNAME_SANITIZERt_DOMAINNAME_SANITIZERR/RR)R+R*R3R9R;R=RJ(((sB/usr/lib/python2.7/site-packages/salt/client/ssh/wrapper/grains.pyt<module>s@					
 			

Zerion Mini Shell 1.0