�
�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
d d l m Z d d l
m Z d d l m Z d d l m Z y d d l m Z e Z Wn e k
r� e Z n Xd
e f d � � YZ d S(
s�
The junos 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 deepcopy( t to_bytes( t utils( t VlansArgs( t get_resource_config( t string_types( t etreet
VlansFactsc B` s2 e Z d Z d d d � Z d d � Z d � Z RS( s The junos 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( ( sX /usr/lib/python2.7/site-packages/ansible/module_utils/network/junos/facts/vlans/vlans.pyt __init__! s
c C` sC t s | j j d d � n | s= d } t | d | �} n t | t � rj t j t | d d �� } n | j d � } g } xH | D]@ } | d k r� | j | j | � } | r� | j
| � q� q� q� Wi } | r.g | d <t j | j i | d 6� }
x/ |
d D] } | d j
t j | � � qWn | 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
t msgs lxml is not installed.s�
<configuration>
<vlans>
</vlans>
</configuration>
t
config_filtert errorst surrogate_then_replaces configuration/vlans/vlant vlansR t ansible_network_resourcesN( t HAS_LXMLR
t fail_jsonR t
isinstanceR R t
fromstringR t xpatht Nonet
render_configR t appendR t validate_configR t remove_emptiest update( R t
connectiont
ansible_factst dataR t resourcest objst resourcet objt factst paramst cfg( ( sX /usr/lib/python2.7/site-packages/ansible/module_utils/network/junos/facts/vlans/vlans.pyt populate_facts/ s0
!c C` s[ t | � } t j | d � | d <t j | d � | d <t j | d � | 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
t names vlan-idt vlan_idt description( R R t get_xml_conf_argR&