%PDF- %PDF-
| Direktori : /proc/self/root/proc/3522530/root/usr/lib/python2.7/site-packages/salt/modules/ |
| Current File : //proc/self/root/proc/3522530/root/usr/lib/python2.7/site-packages/salt/modules/match.pyc |
�
���^c @@ s= d Z d d l m Z m Z m Z d d l Z d d l Z d d l Z d d l Z d d l Z
d d l Z
d d l m
Z
d d l m Z i d d 6Z e j e � Z d d � Z d � Z e
d
� Z e
d � Z d � Z e
d
� Z e
d � Z d d � Z d d � Z d d � Z d d d d � Z d d d � Z d S( uQ
The match module allows for match routines to be run and determine target specs
i ( t absolute_importt print_functiont unicode_literalsN( t DEFAULT_TARGET_DELIM( t sixu listu list_c C@ s� | d k rL t j t � } t | t j � s? t j | � } n | | d <n t } t j j | � } y | d | d | �SWn! t
k
r� } t j | � t
SXd S( u"
Return True if the minion ID matches the given compound target
minion_id
Specify the minion ID to match against the target expression
.. versionadded:: 2014.7.0
CLI Example:
.. code-block:: bash
salt '*' match.compound 'L@cheese,foo and *'
u idu compound_match.matcht optsN( t Nonet copyt __opts__t
isinstanceR t string_typest text_typet saltt loadert matcherst Exceptiont logt exceptiont False( t tgtt minion_idR R t exc( ( s6 /usr/lib/python2.7/site-packages/salt/modules/match.pyt compound s
c C@ sR t j j t � } y | d | d t �SWn! t k
rM } t j | � t SXd S( u/
Return True if the minion matches the given ipcidr target
CLI Example:
.. code-block:: bash
salt '*' match.ipcidr '192.168.44.0/24'
delimiter
Pillar Example:
.. code-block:: yaml
'172.16.0.0/12':
- match: ipcidr
- nodeclass: internal
u ipcidr_match.matchR N( R R
R R R R R R ( R R R ( ( s6 /usr/lib/python2.7/site-packages/salt/modules/match.pyt ipcidr8 s
c C@ sX t j j t � } y | d | d | d t �SWn! t k
rS } t j | � t SXd S( ur
Return True if the minion matches the given pillar_pcre target. The
``delimiter`` argument can be used to specify a different delimiter.
CLI Example:
.. code-block:: bash
salt '*' match.pillar_pcre 'cheese:(swiss|american)'
salt '*' match.pillar_pcre 'clone_url|https://github\.com/.*\.git' delimiter='|'
delimiter
Specify an alternate delimiter to use when traversing a nested dict
.. versionadded:: 2014.7.0
delim
Specify an alternate delimiter to use when traversing a nested dict
.. versionadded:: 0.16.4
.. deprecated:: 2015.8.0
u pillar_pcre_match.matcht delimiterR N( R R
R R R R R R ( R R R R ( ( s6 /usr/lib/python2.7/site-packages/salt/modules/match.pyt pillar_pcreT s
c C@ sX t j j t � } y | d | d | d t �SWn! t k
rS } t j | � t SXd S( u`
Return True if the minion matches the given pillar target. The
``delimiter`` argument can be used to specify a different delimiter.
CLI Example:
.. code-block:: bash
salt '*' match.pillar 'cheese:foo'
salt '*' match.pillar 'clone_url|https://github.com/saltstack/salt.git' delimiter='|'
delimiter
Specify an alternate delimiter to use when traversing a nested dict
.. versionadded:: 2014.7.0
delim
Specify an alternate delimiter to use when traversing a nested dict
.. versionadded:: 0.16.4
.. deprecated:: 2015.8.0
u pillar_match.matchR R N( R R
R R R R R R ( R R R R ( ( s6 /usr/lib/python2.7/site-packages/salt/modules/match.pyt pillars s
c C@ sR t j j t � } y | d | d t �SWn! t k
rM } t j | � t SXd S( u�
Return True if the minion matches the given data target
CLI Example:
.. code-block:: bash
salt '*' match.data 'spam:eggs'
u data_match.matchR N( R R
R R R R R R ( R R R ( ( s6 /usr/lib/python2.7/site-packages/salt/modules/match.pyt data� s
c C@ sX t j j t � } y | d | d | d t �SWn! t k
rS } t j | � t SXd S( uH
Return True if the minion matches the given grain_pcre target. The
``delimiter`` argument can be used to specify a different delimiter.
CLI Example:
.. code-block:: bash
salt '*' match.grain_pcre 'os:Fedo.*'
salt '*' match.grain_pcre 'ipv6|2001:.*' delimiter='|'
delimiter
Specify an alternate delimiter to use when traversing a nested dict
.. versionadded:: 2014.7.0
delim
Specify an alternate delimiter to use when traversing a nested dict
.. versionadded:: 0.16.4
.. deprecated:: 2015.8.0
u grain_pcre_match.matchR R N( R R
R R R R R R ( R R R R ( ( s6 /usr/lib/python2.7/site-packages/salt/modules/match.pyt
grain_pcre� s
c C@ sX t j j t � } y | d | d | d t �SWn! t k
rS } t j | � t SXd S( uH
Return True if the minion matches the given grain target. The ``delimiter``
argument can be used to specify a different delimiter.
CLI Example:
.. code-block:: bash
salt '*' match.grain 'os:Ubuntu'
salt '*' match.grain 'ipv6|2001:db8::ff00:42:8329' delimiter='|'
delimiter
Specify an alternate delimiter to use when traversing a nested dict
.. versionadded:: 2014.7.0
delim
Specify an alternate delimiter to use when traversing a nested dict
.. versionadded:: 0.16.4
.. deprecated:: 2015.8.0
u grain_match.matchR R N( R R
R R R R R R ( R R R R ( ( s6 /usr/lib/python2.7/site-packages/salt/modules/match.pyt grain� s
c C@ s� | d k rL t j t � } t | t j � s? t j | � } n | | d <n t } t j j | � } y | d | d t �SWn! t
k
r� } t j | � t
SXd S( u
Return True if the minion ID matches the given list target
minion_id
Specify the minion ID to match against the target expression
.. versionadded:: 2014.7.0
CLI Example:
.. code-block:: bash
salt '*' match.list 'server1,server2'
u idu list_match.matchR N( R R R R R R
R R R
R R R R R ( R R R R R ( ( s6 /usr/lib/python2.7/site-packages/salt/modules/match.pyt list_� s
c C@ s� | d k rL t j t � } t | t j � s? t j | � } n | | d <n t } t j j | � } y | d | d t �SWn! t
k
r� } t j | � t
SXd S( u
Return True if the minion ID matches the given pcre target
minion_id
Specify the minion ID to match against the target expression
.. versionadded:: 2014.7.0
CLI Example:
.. code-block:: bash
salt '*' match.pcre '.*'
u idu pcre_match.matchR N( R R R R R R
R R R
R R R R R ( R R R R R ( ( s6 /usr/lib/python2.7/site-packages/salt/modules/match.pyt pcre s
c C@ s� | d k rL t j t � } t | t j � s? t j | � } n | | d <n t } t j j | � } y | d | d t �SWn! t
k
r� } t j | � t
SXd S( u
Return True if the minion ID matches the given glob target
minion_id
Specify the minion ID to match against the target expression
.. versionadded:: 2014.7.0
CLI Example:
.. code-block:: bash
salt '*' match.glob '*'
u idu glob_match.matchR N( R R R R R R
R R R
R R R R R ( R R R R R ( ( s6 /usr/lib/python2.7/site-packages/salt/modules/match.pyt glob s
u compoundu defaultc C@ sy t t j t j t d t j �� } xA | D]9 } | rD | | f n | f } | | | � r, | | Sq, W| j | d � S( u<
Return the first match in a dictionary of target patterns
.. versionadded:: 2014.7.0
CLI Example:
.. code-block:: bash
salt '*' match.filter_by '{foo*: Foo!, bar*: Bar!}' minion_id=bar03
Pillar Example:
.. code-block:: jinja
# Filter the data for the current minion into a variable:
{% set roles = salt['match.filter_by']({
'web*': ['app', 'caching'],
'db*': ['db'],
}, default='web*') %}
# Make the filtered data available to Pillar:
roles: {{ roles | yaml() }}
t predicateN( t dictt inspectt
getmemberst syst modulest __name__t
isfunctiont getR ( t lookupt tgt_typeR t defaultt
expr_funcst keyt params( ( s6 /usr/lib/python2.7/site-packages/salt/modules/match.pyt filter_by= s
c C@ s� t t j t j t d t j �� } g } xf | j � D]X \ } } xI | D]A } | rc | | f n | f } | | | � rK | j | � qK qK Wq8 W| p� d S( u
Search a dictionary of target strings for matching targets
This is the inverse of :py:func:`match.filter_by
<salt.modules.match.filter_by>` and allows matching values instead of
matching keys. A minion can be matched by multiple entries.
.. versionadded:: 2017.7.0
CLI Example:
.. code-block:: bash
salt '*' match.search_by '{web: [node1, node2], db: [node2, node]}'
Pillar Example:
.. code-block:: jinja
{% set roles = salt.match.search_by({
'web': ['G@os_family:Debian not nodeX'],
'db': ['L@node2,node3 and G@datacenter:west'],
'caching': ['node3', 'node4'],
}) %}
# Make the filtered data available to Pillar:
roles: {{ roles | yaml() }}
R! N(
R"