�
�Udac @` sr d Z d d l m Z m Z m Z e Z d d l m Z d d l m
Z
d d l m Z d e
f d � � YZ d S( s�
The iosxr lldp fact class
It is in this file the configuration is collected from the device
for a given resource, parsed, and the facts tree is populated
based on the configuration.
i ( t absolute_importt divisiont print_function( t deepcopy( t utils( t Lldp_globalArgst Lldp_globalFactsc B` s2 e Z d Z d d d � Z d d � Z d � Z RS( s The iosxr lldp fact class
t configt optionsc C` sj | | _ t j | _ t | j � } | rN | rA | | | } qT | | } n | } t j | � | _ d S( N( t _moduleR t
argument_specR R t
generate_dictt generated_spec( t selft modulet subspecR t spect facts_argument_spec( ( sd /usr/lib/python2.7/site-packages/ansible/module_utils/network/iosxr/facts/lldp_global/lldp_global.pyt __init__ s
c C` s� | s | j d d � } n i } | rN | j | j | � } | rN | } qN n | d j d d � i } t j | j i | d 6� } t j | d � | d <| d j | � | S( s� Populate the facts for lldp
:param connection: the device connection
:param ansible_facts: Facts dictionary
:param data: previously collected conf
:rtype: dictionary
:returns: facts
t flagst lldpt ansible_network_resourcest lldp_globalR N(
t
get_configt
render_configR t popt NoneR t validate_configR
t remove_emptiest update( R
t
connectiont
ansible_factst datat objt lldp_objt factst params( ( sd /usr/lib/python2.7/site-packages/ansible/module_utils/network/iosxr/facts/lldp_global/lldp_global.pyt populate_facts) s c C` s� t | � } x� | j � D]� } | d k rJ d | k r= t n d | | <q | d k r� x� d d d d d g D]; } d j | j d
d � � | k r� t n d | | | <ql Wq t j | | � } | r� t | � n | | | <q W| S(
s
Render config as dictionary structure and delete keys
from spec for null values
:param spec: The facts tree, generated from the argspec
:param conf: The configuration
:rtype: dictionary
:returns: The generated config
t
subinterfacess subinterfaces enablet
tlv_selectt system_namet port_descriptiont management_addresst system_descriptiont system_capabilitiess {0} disablet _t -N(
R t keyst TrueR t formatt replacet FalseR t parse_conf_argt int( R
R t confR t keyt itemt value( ( sd /usr/lib/python2.7/site-packages/ansible/module_utils/network/iosxr/facts/lldp_global/lldp_global.pyR C s
< N( t __name__t
__module__t __doc__R R R% R ( ( ( sd /usr/lib/python2.7/site-packages/ansible/module_utils/network/iosxr/facts/lldp_global/lldp_global.pyR s N( R<