�
�Udac @` s� d Z d d l m Z m Z m Z e Z d d l m Z d d l m
Z
m Z m Z m
Z
m Z d d l m Z d d l m Z d d l m Z m Z d e f d � � YZ d
S( s�
The junos_lldp class
It is in this file where the current configuration (as dict)
is compared to the provided configuration (as dict) and the command set
necessary to bring the current configuration to it's desired end-state is
created
i ( t absolute_importt divisiont print_function( t
ConfigBase( t
locked_configt load_configt commit_configurationt discard_changest tostring( t to_list( t Facts( t build_root_xml_nodet build_child_xml_nodet Lldp_globalc B` sk e Z d Z d d g Z d g Z d � Z d � Z d � Z d � Z d � Z d � Z
d
� Z d � Z RS( s
The junos_lldp class
s !alls !mint lldp_globalc C` s t t | � j | � d S( N( t superR
t __init__( t selft module( ( se /usr/lib/python2.7/site-packages/ansible/module_utils/network/junos/config/lldp_global/lldp_global.pyR % s c C` sH t | j � j | j | j � \ } } | d j d � } | sD i S| S( s� Get the 'facts' (the current configuration)
:rtype: A dictionary
:returns: The current configuration as a dictionary
t ansible_network_resourcesR ( R
t _modulet get_factst
gather_subsett gather_network_resourcest get( R t factst _warningst
lldp_facts( ( se /usr/lib/python2.7/site-packages/ansible/module_utils/network/junos/config/lldp_global/lldp_global.pyt get_lldp_global_facts( s
'c C` s i t d 6} | j � } | j | � } t | j � �� x) t | � D] } t | j | g � } qE W| j j } | r� | r� t | j � n
t | j � t
| d <| j j r� i | d 6| d <q� n Wd QX| | d <| j � } | | d <| d r| | d <n | S( sl Execute the module
:rtype: A dictionary
:returns: The result from module execution
t changedt preparedt diffNt commandst beforet after( t FalseR t
set_configR R R R t
check_modeR R t Truet _diff( R t resultt existing_lldp_global_factst config_xmlst
config_xmlR t committ changed_lldp_global_facts( ( se /usr/lib/python2.7/site-packages/ansible/module_utils/network/junos/config/lldp_global/lldp_global.pyt execute_module3 s(
c C` s2 | j j d } | } | j | | � } t | � S( s Collect the configuration from the args passed to the module,
collect the current configuration (as a dict from facts)
:rtype: A list
:returns: the commands necessary to migrate the current configuration
to the desired configuration
t config( R t paramst set_stateR ( R R) t wantt havet resp( ( se /usr/lib/python2.7/site-packages/ansible/module_utils/network/junos/config/lldp_global/lldp_global.pyR$ V s c C` s� t d � } | j j d } | d k r= | j | | � } nB | d k r^ | j | | � } n! | d k r | j | | � } n x | D] } | j | � q� Wt | � S( se Select the appropriate function based on the state provided
:param want: the desired configuration as a dictionary
:param have: the current configuration as a dictionary
:rtype: A list
:returns: the list xml configuration necessary to migrate the current configuration
to the desired configuration
t protocolst statet deletedt mergedt replaced( R R R0 t _state_deletedt
_state_mergedt _state_replacedt appendR ( R R2 R3 t rootR6 R* t xml( ( se /usr/lib/python2.7/site-packages/ansible/module_utils/network/junos/config/lldp_global/lldp_global.pyR1 b s
c C` s<