%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python2.7/site-packages/salt/beacons/
Upload File :
Create Path :
Current File : //lib/python2.7/site-packages/salt/beacons/network_settings.pyc

�
���^c@@s@dZddlmZmZy#ddlmZe�ZeZWne	k
rXe
ZnXddlZddlZddl
ZddlZddlmZeje�ZdZddd	d
ddd
dddddddddddddddddgZiadefd ��YZd!�Zd"�Zd#�Zd$�ZdS(%uY
Beacon to monitor network adapter setting changes on Linux

.. versionadded:: 2016.3.0

i(tabsolute_importtunicode_literals(tIPDBN(tmapunetwork_settingsufamilyutxqlenu
ipdb_scopeuindexu	operstateugroupucarrier_changesuipaddru
neighboursuifnameupromiscuityulinkmodeu	broadcastuaddressu
num_tx_queuesu
ipdb_priorityukinduqdiscumtuu
num_rx_queuesucarrieruflagsuifi_typeuportstHashabledictcB@seZdZd�ZRS(uG
    Helper class that implements a hash function for a dictionary
    cC@sttt|j����S(N(thashttupletsortedtitems(tself((sA/usr/lib/python2.7/site-packages/salt/beacons/network_settings.pyt__hash__(s(t__name__t
__module__t__doc__R
(((sA/usr/lib/python2.7/site-packages/salt/beacons/network_settings.pyR$scC@str
tStS(N(tHAS_PYROUTE2t__virtual_name__tFalse(((sA/usr/lib/python2.7/site-packages/salt/beacons/network_settings.pyt__virtual__,scC@s�t|t�stdfSi}tt|j|��|jdi�}t|t�r`tdfSxW|D]O}t|d|t�s�tdfStd�|d|D��sgtdfSqgWtdfS(u+
    Validate the beacon configuration
    u9Configuration for network_settings beacon must be a list.u
interfacesuDinterfaces section for network_settings beacon must be a dictionary.uFInterface attributes for network_settings beacon must be a dictionary.cs@s|]}|tkVqdS(N(tATTRS(t.0tj((sA/usr/lib/python2.7/site-packages/salt/beacons/network_settings.pys	<genexpr>Gsu+Invalid attributes in beacon configuration.uValid beacon configuration(	t
isinstancetlistRRtupdatetgettdicttalltTrue(tconfigt_configt
interfacestitem((sA/usr/lib/python2.7/site-packages/salt/beacons/network_settings.pytvalidate2s



cC@s�i}xs|D]k}t�}xOtD]G}|||kr#t�}t|||�||<|j|�q#q#W|||<q
W|S(uO
    Return a dictionary with a copy of each interface attributes in ATTRS
    (tsetRRtreprtadd(Rtrett	interfacet_interface_attrs_cpytattrt	attr_dict((sA/usr/lib/python2.7/site-packages/salt/beacons/network_settings.pyt_copy_interfaces_infoLs
	
	cC@si}tt|j|��g}g}i}t}ttj�}tsR|and|krw|drwt}i}nt	j
d|�x�|jdi�D]�}||kr�|j|�q�|j
dd�}	xT|D]L}tj|	|�}
|
r�|j|
j��|d|||
j�<q�q�Wq�W|rU|j|�tt|j|��nt	j
d|�xM|D]E}t}||t|}i}
|d|}t	j
d|�|rli}||t|<x|D]}|j|�q�Wx�|D]}||kr�d}||r0d||kr0||d}ntj||�}|sV||krlt}||
|<qlq�q�W|r�|r�|
||<q�|ji|d	6|d
6|
d6�q�qlqlW|r|rtjjtt�}tj|�|jidd	6|d
6�n|S(u�
    Watch for changes on network settings

    By default, the beacon will emit when there is a value change on one of the
    settings on watch. The config also support the onvalue parameter for each
    setting, which instruct the beacon to only emit if the setting changed to
    the value defined.

    Example Config

    .. code-block:: yaml

        beacons:
          network_settings:
            - interfaces:
                eth0:
                  ipaddr:
                  promiscuity:
                    onvalue: 1
                eth1:
                  linkmode:

    The config above will check for value changes on eth0 ipaddr and eth1 linkmode. It will also
    emit if the promiscuity value changes to 1.

    Beacon items can use the * wildcard to make a definition apply to several interfaces. For
    example an eth* would apply to all ethernet interfaces.

    Setting the argument coalesce = True will combine all the beacon results on a single event.
    The example below shows how to trigger coalesced results:

    .. code-block:: yaml

        beacons:
          network_settings:
            - coalesce: True
            - interfaces:
                eth0:
                  ipaddr:
                  promiscuity:

    ucoalesceu	_stats %su
interfacesu*u[0-9]+u
interfaces %su_diff_stats %suonvalueutagu	interfaceuchangeuresultuchangesN(RRRRR)tIPtby_namet
LAST_STATSRtlogtdebugRtappendtreplacetretsearchtgrouptNonetasttliteral_evaltsalttloadertgrainst__opts__t
__grains__(RRR$Rtexpanded_configtcoalescet_statstchangesR%tinterface_regexptmatcht_send_eventt_diff_statst	_ret_difftinterface_configt_diff_stats_dictRR'tconfig_valuet	new_valuetgrains_info((sA/usr/lib/python2.7/site-packages/salt/beacons/network_settings.pytbeacon^st+		
#






(R
t
__future__RRtpyroute2RR*RRtImportErrorRR5R1tsalt.loaderR7tloggingtsalt.ext.six.movesRt	getLoggerRR-RRR,RRRR R)RJ(((sA/usr/lib/python2.7/site-packages/salt/beacons/network_settings.pyt<module>s2	


			

Zerion Mini Shell 1.0