�
�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 interfaces 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 InterfacesArgst InterfacesFactsc B` sD e Z d Z d d d � Z d d � Z d � Z d � Z d � Z RS( s$ The vyos interfaces 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( ( sa /usr/lib/python2.7/site-packages/ansible/module_utils/network/vyos/facts/interfaces/interfaces.pyt __init__ s
c C` s, | s | j d d g � } n g } t d | t � } | r� xt t | � D]c } d | j d � } t | | t � } | j | � } | j d � | d <| rI | j | � qI qI Wn i }
| rg |
d <t j | j i | d 6� } x/ | d D] } |
d j t j
| � � q� Wn | d j |
� | S(
s� Populate the facts for interfaces
:param connection: the device connection
:param ansible_facts: Facts dictionary
:param data: previously collected conf
:rtype: dictionary
:returns: facts
t flagss | grep interfacessK ^set interfaces (?:ethernet|bonding|vti|loopback|vxlan) (?:\'*)(\S+)(?:\'*)s %s .+$t 't namet
interfacesR t ansible_network_resources( t
get_configR R t sett stript
render_configt appendR t validate_configR t remove_emptiest update( R t
connectiont
ansible_factst datat objst interface_namest interfacet
intf_regext cfgt objt factst params( ( sa /usr/lib/python2.7/site-packages/ansible/module_utils/network/vyos/facts/interfaces/interfaces.pyt populate_facts) s*
!c C` st d j t d � | � � } d j t d � | � � } | j d d 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( Nt vif( ( t x( ( sa /usr/lib/python2.7/site-packages/ansible/module_utils/network/vyos/facts/interfaces/interfaces.pyt <lambda>S s c S` s
d | k S( NR. ( ( R/ ( ( sa /usr/lib/python2.7/site-packages/ansible/module_utils/network/vyos/facts/interfaces/interfaces.pyR0 T s t descriptiont speedt mtut duplext vifs( t joint filtert
parse_attribst
parse_vifsR R ( R t conft vif_conft eth_confR ( ( sa /usr/lib/python2.7/site-packages/ansible/module_utils/network/vyos/facts/interfaces/interfaces.pyR I s
c C` s� t d | t � } d } | r� g } xw t | � D]i } d | } d j t | | t � � } | j d d g | � } t | � | d <| r1 | j | � q1 q1 Wt | d d � �} n | S( Ns vif (?:\'*)(\d+)(?:\'*)s %s .+$s
R1 R3 t vlan_idt keyc S` s | d S( NR= ( ( t i( ( sa /usr/lib/python2.7/site-packages/ansible/module_utils/network/vyos/facts/interfaces/interfaces.pyR0 h s ( R R t NoneR R6 R8 t intR t sorted( R R: t vif_namest vifs_listR. t vif_regexR) R* ( ( sa /usr/lib/python2.7/site-packages/ansible/module_utils/network/vyos/facts/interfaces/interfaces.pyR9 [ s
c C` s� i } xt | D]l } t j | | � } | rS | d k rS t | j d � � | | <q
| ro | j d � | | <q
d | | <q
Wd | k r� t | d <n
t | d <t j | � S( NR3 R t disablet enabled( R t parse_conf_argRA R R@ t Falset TrueR ( R t attribsR: R t itemt value( ( sa /usr/lib/python2.7/site-packages/ansible/module_utils/network/vyos/facts/interfaces/interfaces.pyR8 l s
N( t __name__t
__module__t __doc__R R@ R- R R9 R8 ( ( ( sa /usr/lib/python2.7/site-packages/ansible/module_utils/network/vyos/facts/interfaces/interfaces.pyR s N( RP t
__future__R R R t typet
__metaclass__t reR R t copyR t# ansible.module_utils.network.commonR t? ansible.module_utils.network.vyos.argspec.interfaces.interfacesR t objectR ( ( ( sa /usr/lib/python2.7/site-packages/ansible/module_utils/network/vyos/facts/interfaces/interfaces.pyt <module> s
Anons79 File Manager Version 1.0, Coded By Anons79
Email: [email protected]