�
�Udac @` s� d Z d d l m Z m Z m Z e Z d d l m Z d d l Z d d l
m Z d d l m
Z
d e f d � � YZ d � Z d S(
s�
The eos vlans 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 deepcopyN( t utils( t VlansArgst
VlansFactsc B` s2 e Z d Z d d d � Z d d � Z d � Z RS( s The eos vlans 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( ( sV /usr/lib/python2.7/site-packages/ansible/module_utils/network/eos/facts/vlans/vlans.pyt __init__ s
c C` s( | s | j d � } n d } d | | f } g t j | | t j � D] } | j � ^ qG } g } xB | D]: } | rl | j | j | � }
|
r� | j |
� q� ql ql W| d j d d � i } | rt
j | j i | d 6� } g | d D] }
t
j
|
� ^ q� | d <n | d j | � | S( s� Populate the facts for vlans
:param connection: the device connection
:param ansible_facts: Facts dictionary
:param data: previously collected conf
:rtype: dictionary
:returns: facts
s# show running-config | section ^vlant vlans (?:^|\n)%s.*?(?=(?:^|\n)%s|$)t ansible_network_resourcest vlansR N( t gett ret findallt DOTALLt stript
render_configR t extendt popt NoneR t validate_configR
t remove_emptiest update( R
t
connectiont
ansible_factst datat resource_delimt find_patternt pt resourcest objst resourcet objt factst paramst cfg( ( sV /usr/lib/python2.7/site-packages/ansible/module_utils/network/eos/facts/vlans/vlans.pyt populate_facts( s*
"
-c C` s� t | � } g } t t j | d � � } xZ | D]R } | | d <t j | d � | d <t j | d � | d <| j t j | � � q1 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
R t vlan_idt namet state( R t vlan_to_listR t parse_conf_argt appendR ( R
R t confR R t vlan_listR ( ( sV /usr/lib/python2.7/site-packages/ansible/module_utils/network/eos/facts/vlans/vlans.pyR K s
N( t __name__t
__module__t __doc__R R R/ R ( ( ( sV /usr/lib/python2.7/site-packages/ansible/module_utils/network/eos/facts/vlans/vlans.pyR s #c C` s� g } xt | j d � D]c } d | k rf | j d � \ } } | j t t | � t | � d � � q | j t | � � q W| S( Nt ,t -i ( t splitR t ranget intR5 ( t vlan_strR R t startt stop( ( sV /usr/lib/python2.7/site-packages/ansible/module_utils/network/eos/facts/vlans/vlans.pyR3 c s )( R: t
__future__R R R t typet
__metaclass__t copyR R t# ansible.module_utils.network.commonR t4 ansible.module_utils.network.eos.argspec.vlans.vlansR t objectR R3 ( ( ( sV /usr/lib/python2.7/site-packages/ansible/module_utils/network/eos/facts/vlans/vlans.pyt <module>
s M
Anons79 File Manager Version 1.0, Coded By Anons79
Email: [email protected]