%PDF- %PDF-
Direktori : /usr/lib/python2.7/site-packages/salt/thorium/ |
Current File : //usr/lib/python2.7/site-packages/salt/thorium/reg.pyc |
� ���^c @` s d Z d d l m Z m Z m Z m Z d d l Z i d d 6d d 6Z d � Z e d d � Z d � Z d � Z d � Z d S( u� Used to manage the thorium register. The thorium register is where compound values are stored and computed, such as averages etc. i ( t absolute_importt divisiont print_functiont unicode_literalsNu setu set_u listu list_c C` s� i | d 6i d 6d d 6t d 6} | t k rL i t | <t � t | d <n x� t D]� } t j j j | d | � rS y | d d j | � } Wn$ t k r� | d j | � } n X| d k r� d } n | | d | <t | d j | � qS qS W| S( u� Add a value to the named set USAGE: .. code-block:: yaml foo: reg.set: - add: bar - match: my/custom/event u nameu changesu u commentu resultu valu tagu datau NoneN( t Truet __reg__t sett __events__t saltt utilst stringutilst expr_matcht gett KeyErrort Nonet add( t nameR t matcht rett eventt val( ( s4 /usr/lib/python2.7/site-packages/salt/thorium/reg.pyt set_ s$ c C` sa i | d 6i d 6d d 6t d 6} t | t � sC | j d � } n | t k rj i t | <g t | d <n x� t D]� } y | d d } Wn t k r� | d } n Xt j j j | d | � rq i } xL | D]D } | | k r� | | | | <| t k r| d d | d <qq� q� Wt | d j | � qq qq W| d k r]t | d | t | d <n | S( u� Add the specified values to the named list If ``stamp`` is True, then the timestamp from the event will also be added if ``prune`` is set to an integer higher than ``0``, then only the last ``prune`` values will be kept in the list. USAGE: .. code-block:: yaml foo: reg.list: - add: bar - match: my/custom/event - stamp: True u nameu changesu u commentu resultu ,u valu datau tagu _stampu timei ( R t isinstancet listt splitR R R R R R R t append( R R R t stampt pruneR R t event_datat itemt key( ( s4 /usr/lib/python2.7/site-packages/salt/thorium/reg.pyt list_2 s2 c C` sI i | d 6i d 6d d 6t d 6} | t k re i t | <d t | d <d t | d <d t | d <n x� t D]� } y | d d } Wn t k r� | d } n Xt j j j | d | � rl | | k r� y t | � } Wq� t k r� ql q� Xn t | d c | 7<t | d c d 7<t | d t | d t | d <ql ql W| S( uE Accept a numeric value from the matched events and store a running average of the values in the given register. If the specified value is not numeric it will be skipped USAGE: .. code-block:: yaml foo: reg.mean: - add: data_field - match: my/custom/event u nameu changesu u commentu resulti u valu totalu countu datau tagi ( R R R R R R R R t intt ValueError( R R R R R R t comp( ( s4 /usr/lib/python2.7/site-packages/salt/thorium/reg.pyt mean_ s0 )c C` sC i | d 6i d 6d d 6t d 6} | t k r? t | j � n | S( u� Clear the namespace from the register USAGE: .. code-block:: yaml clearns: reg.clear: - name: myregister u nameu changesu u commentu result( R R t clear( R R ( ( s4 /usr/lib/python2.7/site-packages/salt/thorium/reg.pyR$ � s c C` s<