%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python2.7/site-packages/salt/states/
Upload File :
Create Path :
Current File : //lib/python2.7/site-packages/salt/states/probes.pyo

�
���^c@@s�dZddlmZddlZeje�ZddlmZddl	m
Z
mZddlm
Z
ddlZdZd�Zd	�Zd
�Zd�Zd�Zd
�Zd�Zd�Zd�Zd�Zdd�ZdS(sw
Network Probes
===============

Configure RPM (JunOS)/SLA (Cisco) probes on the device via NAPALM proxy.

:codeauthor: Mircea Ulinic <mircea@cloudflare.com> & Jerome Fleury <jf@cloudflare.com>
:maturity:   new
:depends:    napalm
:platform:   unix

Dependencies
------------

- :mod:`napalm probes management module <salt.modules.napalm_probes>`

.. versionadded: 2016.11.0
i(tabsolute_importN(tdeepcopy(tloadstdumps(tsixtprobescC@stjjjttt�S(s_
    NAPALM library must be installed for this module to work and run in a (proxy) minion.
    (tsalttutilstnapalmtvirtualt__opts__t__virtualname__t__file__(((s6/usr/lib/python2.7/site-packages/salt/states/probes.pyt__virtual__2scC@s i|d6td6id6dd6S(sh
    Returns a default structure of the dictionary to be returned as output of the state functions.
    tnametresulttchangesttcomment(tFalse(R((s6/usr/lib/python2.7/site-packages/salt/states/probes.pyt_default_ret=s
cC@std�S(sl
    Will retrieve the probes from the network device using salt module "probes" throught NAPALM proxy.
    s
probes.config(t__salt__(((s6/usr/lib/python2.7/site-packages/salt/states/probes.pyt_retrieve_rpm_probesKsc
C@s�i}x�tj|�D]�\}}||j�krAi||<n|jdi�}x�tj|�D]x\}}|jdi�}t|�}	|	j|�|	j|�|	j|�|||j�krc|	|||<qcqcWqW|S(sP
    Updates the probes dictionary with different levels of default values.
    tdefaults(Rt	iteritemstkeystpopRtupdate(
RRtexpected_probest
probe_namet
probe_testtprobe_defaultst	test_namettest_detailst
test_defaultstexpected_test_details((s6/usr/lib/python2.7/site-packages/salt/states/probes.pyt_expand_probesTs



cC@s�t|�}t|�}x�tj|�D]~\}}|sM|j|�q(nxVtj|�D]E\}}|s�||j|�n|j|�s]|j|�q]q]Wq(WtS(sJ
    Will remove empty and useless values from the probes dictionary.
    (t_ordered_dict_to_dictRRRRtgettTrue(Rtprobes_copyRtprobe_testsR ttest_params((s6/usr/lib/python2.7/site-packages/salt/states/probes.pyt
_clean_probesls
cC@sQi}i}i}|s#i|d6S|s4i|d6St|j��}t|j��}||}||}x!|D]}	|j|	�||	<qsWx!|D]}	|j|	�||	<q�Wx�tj|�D]p\}	}
|j|	i�}t|j��}t|
j��}
|
|}||
}xN|D]F}|	|j�krFi||	<n||	ji|
j|�|6�q!WxN|D]F}|	|j�kr�i||	<n||	ji|j|�|6�qrWxutj|
�D]d\}}|j|i�}||kr�|	|j�kri||	<n||	ji||6�q�q�Wq�Wi|d6|d6|d6S(so
    Compares configured probes on the device with the expected configuration and returns the differences.
    taddtremoveR(tsetRRRRR&R(tconfigured_probesRt
new_probest
update_probest
remove_probestconfigured_probes_keys_settexpected_probes_keys_settnew_probes_keys_settremove_probes_keys_setRR)tconfigured_probe_teststconfigured_tests_keys_settexpected_tests_keys_settnew_tests_keys_settremove_tests_keys_setR R*tconfigured_test_params((s6/usr/lib/python2.7/site-packages/salt/states/probes.pyt_compare_probes�sX













cC@stt|��S(sKMandatory to be dict type in order to be used in the NAPALM Jinja template.(RR(R((s6/usr/lib/python2.7/site-packages/salt/states/probes.pyR%�scC@stdt|�dt�S(sO
    Calls the Salt module "probes" to configure the probes on the device.
    sprobes.set_probestcommit(RR%R(R((s6/usr/lib/python2.7/site-packages/salt/states/probes.pyt_set_rpm_probes�scC@stdt|�dt�S(sY
    Calls the Salt module "probes" to schedule the configured probes on the device.
    sprobes.schedule_probesR>(RR%R(R((s6/usr/lib/python2.7/site-packages/salt/states/probes.pyt_schedule_probes�scC@stdt|�dt�S(sJ
    Calls the Salt module "probes" to delete probes from the device.
    sprobes.delete_probesR>(RR%R(R((s6/usr/lib/python2.7/site-packages/salt/states/probes.pyt_delete_rpm_probes�scC@s�t|�}t}d}t�}|jd�sd|jitd6djd|jd��d6�|S|jdi�}t|t�s�i}nt	||�}t
|�t
|�t||�}	|	jd�}
|	jd�}|	jd	�}it|
�d
6t|�d6t|�d6}
|ji|
d
6�t
dtkr]|jidd6dd6�|St}|
r�t|
�}|jd�r�t}q�t}|djd|jd��7}n|rt|�}|jd�r�t}qt}|djd|jd��7}n|rYt|�}|jd�r1t}qYt}|djd|jd��7}n|rutd�\}}nt|
�}|jd�r�td�\}}n|r�|r�|dkr�d}q�n|ji|d6|d6�|S(s�
    Ensure the networks device is configured as specified in the state SLS file.
    Probes not specified will be removed, while probes not confiured as expected will trigger config updates.

    :param probes: Defines the probes as expected to be configured on the
        device.  In order to ease the configuration and avoid repeating the
        same parameters for each probe, the next parameter (defaults) can be
        used, providing common characteristics.

    :param defaults: Specifies common parameters for the probes.

    SLS Example:

    .. code-block:: yaml

        rpmprobes:
            probes.managed:
                - probes:
                    probe_name1:
                        probe1_test1:
                            source: 192.168.0.2
                            target: 192.168.0.1
                        probe1_test2:
                            target: 172.17.17.1
                        probe1_test3:
                            target: 8.8.8.8
                            probe_type: http-ping
                    probe_name2:
                        probe2_test1:
                            test_interval: 100
                - defaults:
                    target: 10.10.10.10
                    probe_count: 15
                    test_interval: 3
                    probe_type: icmp-ping

    In the probes configuration, the only mandatory attribute is *target*
    (specified either in probes configuration, either in the defaults
    dictionary).  All the other parameters will use the operating system
    defaults, if not provided:

    - ``source`` - Specifies the source IP Address to be used during the tests.  If
      not specified will use the IP Address of the logical interface loopback0.

    - ``target`` - Destination IP Address.
    - ``probe_count`` - Total number of probes per test (1..15). System
      defaults: 1 on both JunOS & Cisco.
    - ``probe_interval`` - Delay between tests (0..86400 seconds). System
      defaults: 3 on JunOS, 5 on Cisco.
    - ``probe_type`` - Probe request type. Available options:

      - icmp-ping
      - tcp-ping
      - udp-ping

    Using the example configuration above, after running the state, on the device will be configured 4 probes,
    with the following properties:

    .. code-block:: yaml

        probe_name1:
            probe1_test1:
                source: 192.168.0.2
                target: 192.168.0.1
                probe_count: 15
                test_interval: 3
                probe_type: icmp-ping
            probe1_test2:
                target: 172.17.17.1
                probe_count: 15
                test_interval: 3
                probe_type: icmp-ping
            probe1_test3:
                target: 8.8.8.8
                probe_count: 15
                test_interval: 3
                probe_type: http-ping
        probe_name2:
            probe2_test1:
                target: 10.10.10.10
                probe_count: 15
                test_interval: 3
                probe_type: icmp-ping
    RRsDCannot retrieve configurtion of the probes from the device: {reason}treasonRtoutR,RR-taddedtupdatedtremovedRttests,Testing mode: configuration was not changed!s#Cannot define new probes: {reason}
sCannot update probes: {reason}
sCannot remove probes! {reason}
snet.config_controlsProbes updated successfully!N(RR'RR&RRtformatt
isinstancetdictR$R+R=R%R
tNoneR?RARR@(RRRtretRRtrpm_probes_configR/Rtdifft
add_probesR1R2Rtconfig_change_expectedRDRERFt
add_scheduled((s6/usr/lib/python2.7/site-packages/salt/states/probes.pytmanaged�s�W				



						(t__doc__t
__future__Rtloggingt	getLoggert__name__tlogtcopyRtjsonRRtsalt.extRtsalt.utils.napalmRRR
RRR$R+R=R%R?R@RARKRR(((s6/usr/lib/python2.7/site-packages/salt/states/probes.pyt<module>s&							K				

Zerion Mini Shell 1.0