�
�Udac @` s� d Z d d l m Z m Z m Z e Z d d l m Z m 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 vyos lldp_global 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 findallt M( t deepcopy( t utils( t Lldp_globalArgst Lldp_globalFactsc B` sD e Z d Z d d d � Z d d � Z d � Z d � Z d � Z RS( s% The vyos lldp_global 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( ( sc /usr/lib/python2.7/site-packages/ansible/module_utils/network/vyos/facts/lldp_global/lldp_global.pyt __init__ s
c C` s | s | j � } n i } t d | t � } | r� xX t | � D]G } d | } t | | t � } | j | � } | r@ | j | � q@ q@ Wn t d | t � }
|
s� | r� i } t | d <| j | � n i } t j | j i | d 6� }
t j
|
d � | d <| d j | � | S( s� Populate the facts for lldp_global
:param connection: the device connection
:param ansible_facts: Facts dictionary
:param data: previously collected conf
:rtype: dictionary
:returns: facts
s ^set service lldp (\S+)s %s .+$s ^set service (lldp)?('lldp')t enableR t lldp_globalt ansible_network_resources( t
get_configR R t sett
render_configt updatet TrueR t validate_configR t remove_empties( R t
connectiont
ansible_factst datat objst lldp_outputt itemt
lldp_regext cfgt objt lldp_servicet lldp_objt factst params( ( sc /usr/lib/python2.7/site-packages/ansible/module_utils/network/vyos/facts/lldp_global/lldp_global.pyt populate_facts( s*
c C` sn d j t d � | � � } d j t d � | � � } | j d d g | � } | j | � | d <t j | � 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
s
c S` s
d | k S( Ns legacy-protocols( ( t x( ( sc /usr/lib/python2.7/site-packages/ansible/module_utils/network/vyos/facts/lldp_global/lldp_global.pyt <lambda>S s c S` s
d | k S( Ns legacy-protocols( ( R- ( ( sc /usr/lib/python2.7/site-packages/ansible/module_utils/network/vyos/facts/lldp_global/lldp_global.pyR. T s t snmpt addresst legacy_protocols( t joint filtert
parse_attribst parse_protocolsR R ( R t conft
protocol_conft att_confR ( ( sc /usr/lib/python2.7/site-packages/ansible/module_utils/network/vyos/facts/lldp_global/lldp_global.pyR J s c C` s[ d } | rW t d | t � } | rW g } x'