Anons79 Mini Shell

Directory : /lib/python2.7/site-packages/ansible/module_utils/network/junos/config/interfaces/
Upload File :
Current File : //lib/python2.7/site-packages/ansible/module_utils/network/junos/config/interfaces/interfaces.pyc

�
�Udac@`s�dZddlmZmZmZeZddlmZddl	m
Z
ddlmZm
Z
mZmZmZddlmZddlmZmZde
fd	��YZd
S(s�
The junos_interfaces class
It is in this file where the current configuration (as dict)
is compared to the provided configuration (as dict) and the command set
necessary to bring the current configuration to it's desired end-state is
created
i(tabsolute_importtdivisiontprint_function(tto_list(t
ConfigBase(t
locked_configtload_configtcommit_configurationtdiscard_changesttostring(tFacts(tbuild_root_xml_nodetbuild_child_xml_nodet
InterfacescB`steZdZddgZdgZd�Zd�Zd�Zd�Zd�Z	d	�Z
d
�Zd�Zd�Z
RS(
s$
    The junos_interfaces class
    s!alls!mint
interfacescC`stt|�j|�dS(N(tsuperR
t__init__(tselftmodule((sc/usr/lib/python2.7/site-packages/ansible/module_utils/network/junos/config/interfaces/interfaces.pyR&scC`sHt|j�j|j|j�\}}|djd�}|sDgS|S(s� Get the 'facts' (the current configuration)

        :rtype: A dictionary
        :returns: The current configuration as a dictionary
        tansible_network_resourcesR(R
t_modulet	get_factst
gather_subsettgather_network_resourcestget(Rtfactst	_warningstinterfaces_facts((sc/usr/lib/python2.7/site-packages/ansible/module_utils/network/junos/config/interfaces/interfaces.pytget_interfaces_facts)s
'c	C`sitd6}|j�}|j|�}t|j���x)t|�D]}t|j|g�}qEW|jj}|r�|r�t|j�n
t	|j�t
|d<|jjr�i|d6|d<q�nWdQX||d<|j�}||d<|dr||d<n|S(sm Execute the module

        :rtype: A dictionary
        :returns: The result from module execution
        tchangedtpreparedtdiffNtcommandstbeforetafter(tFalseRt
set_configRRRRt
check_modeRRtTruet_diff(Rtresulttexisting_interfaces_factstconfig_xmlst
config_xmlRtcommittchanged_interfaces_facts((sc/usr/lib/python2.7/site-packages/ansible/module_utils/network/junos/config/interfaces/interfaces.pytexecute_module5s(







cC`s2|jjd}|}|j||�}t|�S(s! Collect the configuration from the args passed to the module,
            collect the current configuration (as a dict from facts)

        :rtype: A list
        :returns: the commands necessary to migrate the current configuration
                  to the desired configuration
        tconfig(Rtparamst	set_stateR(RR)twantthavetresp((sc/usr/lib/python2.7/site-packages/ansible/module_utils/network/junos/config/interfaces/interfaces.pyR$YscC`s�td�}|jjd}|dkr=|j||�}nc|dkr^|j||�}nB|dkr|j||�}n!|dkr�|j||�}nx|D]}|j|�q�Wt|�S(sf Select the appropriate function based on the state provided

        :param want: the desired configuration as a dictionary
        :param have: the current configuration as a dictionary
        :rtype: A list
        :returns: the list xml configuration necessary to migrate the current configuration
                  to the desired configuration
        Rtstatet
overriddentdeletedtmergedtreplaced(	RRR0t_state_overriddent_state_deletedt
_state_mergedt_state_replacedtappendR	(RR2R3trootR5R*txml((sc/usr/lib/python2.7/site-packages/ansible/module_utils/network/junos/config/interfaces/interfaces.pyR1fs	
cC`s<g}|j|j||��|j|j||��|S(s� The xml configuration generator when state is replaced

        :rtype: A list
        :returns: the xml configuration necessary to migrate the current configuration
                  to the desired configuration
        (textendR;R<(RR2R3tintf_xml((sc/usr/lib/python2.7/site-packages/ansible/module_utils/network/junos/config/interfaces/interfaces.pyR=scC`s�g}|j|j||��g}xD|D]<}x3|D]}|d|dkr9Pq9q9W|j|�q,W|r�|j|j||��n|S(s� The xml configuration generator when state is overridden

        :rtype: A list
        :returns: the xml configuration necessary to migrate the current configuration
                  to the desired configuration
        tname(RAR=R>R;(RR2R3tinterface_xmls_objt
delete_objthave_objtwant_obj((sc/usr/lib/python2.7/site-packages/ansible/module_utils/network/junos/config/interfaces/interfaces.pyR:�s

cC`sSg}xF|D]>}td�}t|d|d�ddg}|djd�sb|jd�nx4|D],}|j|�rit||||�qiqiW|jd�r�t|d|d�n|jd	�tkr�t|d
�n|jd�}|r>t|d�}	x3d
dgD]"}
t|	|
|j|
d��qWn|j|�q
W|S(s� The xml configuration generator when state is merged

        :rtype: A list
        :returns: the xml configuration necessary to merge the provided into
                  the current configuration
        t	interfaceRCtdescriptiontspeedtfxptmtutduplexs	link-modetenabledtdisablet	hold_times	hold-timetuptdownt(RRt
startswithR>RR#(RR2R3RBR/tintftintf_fieldstfieldtholdtimetholdtime_eletholdtime_field((sc/usr/lib/python2.7/site-packages/ansible/module_utils/network/junos/config/interfaces/interfaces.pyR<�s*

#c	C`s�g}|}|s|}nx�|D]�}td�}t|d|d�dg}t|djd�|djd�g�s�|jd�nt|djd�|djd�|djd�g�s�|jd�nx(|D] }t||did	d	6�q�Wt|djd�|djd�g�sMt|d
did	d	6�nt|ddid	d	6�t|d�}	x.d
dgD] }
t|	|
did	d	6�q�W|j|�q"W|S(s� The xml configuration generator when state is deleted

        :rtype: A list
        :returns: the xml configuration necessary to remove the current configuration
                  of the provided objects
        RHRCRItgrtloRJRKRLtdeletes	link-modeROs	hold-timeRQRRN(RRtanyRTR>tNone(RR2R3RBtintf_objR/RURVRWRYRZ((sc/usr/lib/python2.7/site-packages/ansible/module_utils/network/junos/config/interfaces/interfaces.pyR;�s:	
	
(t__name__t
__module__t__doc__RRRRR.R$R1R=R:R<R;(((sc/usr/lib/python2.7/site-packages/ansible/module_utils/network/junos/config/interfaces/interfaces.pyR
s					$	
		
		$N(Rct
__future__RRRttypet
__metaclass__t)ansible.module_utils.network.common.utilsRt,ansible.module_utils.network.common.cfg.baseRt(ansible.module_utils.network.junos.junosRRRRR	t.ansible.module_utils.network.junos.facts.factsR
t+ansible.module_utils.network.common.netconfRRR
(((sc/usr/lib/python2.7/site-packages/ansible/module_utils/network/junos/config/interfaces/interfaces.pyt<module>s(

Anons79 File Manager Version 1.0, Coded By Anons79
Email: [email protected]