Anons79 Mini Shell

Directory : /lib/python2.7/site-packages/ansible/modules/network/cloudengine/
Upload File :
Current File : //lib/python2.7/site-packages/ansible/modules/network/cloudengine/ce_bfd_global.pyc

�
�Udac@s�idd6dgd6dd6ZdZdZdZd	d
lZd	d
lZd	dlmZd	dlm	Z	d	d
l
mZmZm
Z
mZdZdZd�Zdefd��YZd�Zedkr�e�nd
S(s1.1tmetadata_versiontpreviewtstatust	communitytsupported_bys�	
---
module: ce_bfd_global
version_added: "2.4"
short_description: Manages BFD global configuration on HUAWEI CloudEngine devices.
description:
    - Manages BFD global configuration on HUAWEI CloudEngine devices.
author: QijunPan (@QijunPan)
notes:
  - This module requires the netconf system service be enabled on the remote device being managed.
  - Recommended connection is C(netconf).
  - This module also works with C(local) connections for legacy playbooks.
options:
    bfd_enable:
        description:
            - Enables the global Bidirectional Forwarding Detection (BFD) function.
        choices: ['enable', 'disable']
    default_ip:
        description:
            - Specifies the default multicast IP address.
              The value ranges from 224.0.0.107 to 224.0.0.250.
    tos_exp_dynamic:
        description:
            - Indicates the priority of BFD control packets for dynamic BFD sessions.
              The value is an integer ranging from 0 to 7.
              The default priority is 7, which is the highest priority of BFD control packets.
    tos_exp_static:
        description:
            - Indicates the priority of BFD control packets for static BFD sessions.
              The value is an integer ranging from 0 to 7.
              The default priority is 7, which is the highest priority of BFD control packets.
    damp_init_wait_time:
        description:
            - Specifies an initial flapping suppression time for a BFD session.
              The value is an integer ranging from 1 to 3600000, in milliseconds.
              The default value is 2000.
    damp_max_wait_time:
        description:
            - Specifies a maximum flapping suppression time for a BFD session.
              The value is an integer ranging from 1 to 3600000, in milliseconds.
              The default value is 15000.
    damp_second_wait_time:
        description:
            - Specifies a secondary flapping suppression time for a BFD session.
              The value is an integer ranging from 1 to 3600000, in milliseconds.
              The default value is 5000.
    delay_up_time:
        description:
            - Specifies the delay before a BFD session becomes Up.
              The value is an integer ranging from 1 to 600, in seconds.
              The default value is 0, indicating that a BFD session immediately becomes Up.
    state:
        description:
            - Determines whether the config should be present or not on the device.
        default: present
        choices: ['present', 'absent']
s�
- name: bfd global module test
  hosts: cloudengine
  connection: local
  gather_facts: no
  vars:
    cli:
      host: "{{ inventory_hostname }}"
      port: "{{ ansible_ssh_port }}"
      username: "{{ username }}"
      password: "{{ password }}"
      transport: cli

  tasks:
  - name: Enable the global BFD function
    ce_bfd_global:
      bfd_enable: enable
      provider: '{{ cli }}'

  - name: Set the default multicast IP address to 224.0.0.150
    ce_bfd_global:
      bfd_enable: enable
      default_ip: 224.0.0.150
      state: present
      provider: '{{ cli }}'

  - name: Set the priority of BFD control packets for dynamic and static BFD sessions
    ce_bfd_global:
      bfd_enable: enable
      tos_exp_dynamic: 5
      tos_exp_static: 6
      state: present
      provider: '{{ cli }}'

  - name: Disable the global BFD function
    ce_bfd_global:
      bfd_enable: disable
      provider: '{{ cli }}'
s 
proposed:
    description: k/v pairs of parameters passed into module
    returned: verbose mode
    type: dict
    sample: {
        "bfd_enalbe": "enable",
        "damp_init_wait_time": null,
        "damp_max_wait_time": null,
        "damp_second_wait_time": null,
        "default_ip": null,
        "delayUpTimer": null,
        "state": "present",
        "tos_exp_dynamic": null,
        "tos_exp_static": null
    }
existing:
    description: k/v pairs of existing configuration
    returned: verbose mode
    type: dict
    sample: {
        "global": {
            "bfdEnable": "false",
            "dampInitWaitTime": "2000",
            "dampMaxWaitTime": "12000",
            "dampSecondWaitTime": "5000",
            "defaultIp": "224.0.0.184",
            "delayUpTimer": null,
            "tosExp": "7",
            "tosExpStatic": "7"
        }
    }
end_state:
    description: k/v pairs of configuration after module execution
    returned: verbose mode
    type: dict
    sample: {
        "global": {
            "bfdEnable": "true",
            "dampInitWaitTime": "2000",
            "dampMaxWaitTime": "12000",
            "dampSecondWaitTime": "5000",
            "defaultIp": "224.0.0.184",
            "delayUpTimer": null,
            "tosExp": "7",
            "tosExpStatic": "7"
        }
    }
updates:
    description: commands sent to the device
    returned: always
    type: list
    sample: [ "bfd" ]
changed:
    description: check to see if a change was made on the device
    returned: always
    type: bool
    sample: true
i����N(tElementTree(t
AnsibleModule(t
get_nc_configt
set_nc_configtce_argument_spect
check_ip_addrs�
    <filter type="subtree">
      <bfd xmlns="http://www.huawei.com/netconf/vrp" content-version="1.0" format-version="1.0">
      %s
      </bfd>
    </filter>
sr
        <bfdSchGlobal>
          <bfdEnable></bfdEnable>
          <defaultIp></defaultIp>
          <tosExp></tosExp>
          <tosExpStatic></tosExpStatic>
          <dampInitWaitTime></dampInitWaitTime>
          <dampMaxWaitTime></dampMaxWaitTime>
          <dampSecondWaitTime></dampSecondWaitTime>
          <delayUpTimer></delayUpTimer>
        </bfdSchGlobal>
cCs�t|�stS|jd�dkr)tS|jd�}|ddksh|ddksh|ddkrltS|dj�s�t|d�dks�t|d�d	kr�tStS(
s&check the default multicast IP addresst.iit224it0iiki�(R
tFalsetcounttsplittisdigittinttTrue(tipaddrtips((sU/usr/lib/python2.7/site-packages/ansible/modules/network/cloudengine/ce_bfd_global.pytcheck_default_ip�s0=t	BfdGlobalcBsheZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�ZRS(sManages BFD GlobalcCsa||_d|_|j�|jjd|_|jjd|_|jjd|_|jjd|_|jjd|_	|jjd|_
|jjd|_|jjd|_|jjd	|_
|jjd
|_|jjd|_|jjd|_t|_t�|_t�|_t�|_t�|_t�|_t�|_t�|_dS(
Nt
bfd_enablet
default_ipttos_exp_dynamicttos_exp_statictdamp_init_wait_timetdamp_max_wait_timetdamp_second_wait_timet
delay_up_timetstatethosttusernametport(tspectNonetmodulet__init_module__tparamsRRRRRRRRR R!R"R#Rtchangedtdicttbfd_dicttlisttupdates_cmdtcommandstresultstproposedtexistingt	end_state(tselft
argument_spec((sU/usr/lib/python2.7/site-packages/ansible/modules/network/cloudengine/ce_bfd_global.pyt__init__�s.		
	cCs.dg}td|jd|dt�|_dS(	sinit moduleRRRR4trequired_togethertsupports_check_modeN(sdamp_init_wait_timesdamp_max_wait_timesdamp_second_wait_time(RR$RR&(R3R6((sU/usr/lib/python2.7/site-packages/ansible/modules/network/cloudengine/ce_bfd_global.pyR's	cCs�t�}t�|d<tt}t|j|�}d|krB|S|jdd�jdd�jdd�jdd�}tj|�}|jd�}|r�x7|D],}|j	d	k	r�|j	|d|j<q�q�Wn|S(
sbfd config dicttglobals<data/>s
ts
s/xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"s)xmlns="http://www.huawei.com/netconf/vrp"sbfd/bfdSchGlobalN(R*t
CE_NC_GET_BFDtCE_NC_GET_BFD_GLBRR&treplaceRt
fromstringtfindttextR%ttag(R3R+tconf_strtxml_strtroottglbtattr((sU/usr/lib/python2.7/site-packages/ansible/modules/network/cloudengine/ce_bfd_global.pytget_bfd_dicts 	


cCs�d}t}|jr�t|jdjdd�dk�t|jdk�kr�|jdkrwd}|jjd�q�d	}|jjd
�q�nd}|jr�|j}n(|jdjdd�dkr�d}n|jr�|dkr�|jdkrf|j|jdjd
�krf|d|j7}d|jkrL|jjd�n|jjd|j�q�|jdkr�|j|jdjd
�kr�|d7}d|jkr�|jjd�n|jjd�q�q�n|j	d2k	r�|dkr�|jdkrx|j	t|jdjdd��krx|d|j	7}d|jkr^|jjd�n|jjd|j	�q�|jdkr�|j	t|jdjdd��kr�|d7}d|jkr�|jjd�n|jjd�q�q�n|jd2k	r|dkr|jdkr�|jt|jdjdd��kr�|d|j7}d|jkry|jjd�n|jjd|j�q|jdkr|jt|jdjdd��kr|d7}d|jkr�|jjd�n|jjd�qqn|j
d2k	r:|dkr:|jdjdd�}|sW|j�r`d}n|jdkr�|j
t|�kr�|d |j
7}d|jkr�|jjd�n|jjd!|j
�q7|jdkr7|j
t|�kr7|d"7}d|jkr!|jjd�n|jjd#�q7q:n|jd2k	r�|jd2k	r�|jd2k	r�|dkr�|jdkr�|jt|jdjd$d%��kr�|d&|j7}t}n|jt|jdjd'd(��kr|d)|j7}t}n|jt|jdjd*d+��krH|d,|j7}t}n|r�d|jkrp|jjd�n|jjd-|j|j|jf�q�q�t}|jt|jdjd$d%��kr�t}n|jt|jdjd'd(��krt}n|jt|jdjd*d+��kr5t}n|r�|d.7}d|jkrg|jjd�n|jjd/|j|j|jf�q�q�n|r�d0|d1SdSd2S(3sconfigures bfd global paramsR9R8t	bfdEnabletfalsettruetenables<bfdEnable>true</bfdEnable>tbfds<bfdEnable>false</bfdEnable>sundo bfdtdisabletpresentt	defaultIps<defaultIp>%s</defaultIp>sdefault-ip-address %stabsents<defaultIp/>sundo default-ip-addressttosExpt7s<tosExp>%s</tosExp>stos-exp %s dynamics	<tosExp/>sundo tos-exp dynamicttosExpStatics<tosExpStatic>%s</tosExpStatic>stos-exp %s statics<tosExpStatic/>sundo tos-exp statictdelayUpTimerR
s<delayUpTimer>%s</delayUpTimer>sdelay-up %ss<delayUpTimer/>s
undo delay-uptdampMaxWaitTimet2000s%<dampMaxWaitTime>%s</dampMaxWaitTime>tdampInitWaitTimet12000s'<dampInitWaitTime>%s</dampInitWaitTime>tdampSecondWaitTimet5000s+<dampSecondWaitTime>%s</dampSecondWaitTime>s;dampening timer-interval maximum %s initial %s secondary %ss:<dampMaxWaitTime/><dampInitWaitTime/><dampSecondWaitTime/>s@undo dampening timer-interval maximum %s initial %s secondary %ss <bfdSchGlobal operation="merge">s</bfdSchGlobal>N(RRtboolR+tgetR-tappendRR RR%RRRRRRRR(R3RBtdamp_chgt	bfd_statet
delay_time((sU/usr/lib/python2.7/site-packages/ansible/modules/network/cloudengine/ce_bfd_global.pyt
config_global(s�	:			..
77
((
	
(	(	(	 (	(	(	
#cCs1|s
dSd|}t|j|�t|_dS(sload bfd config by netconfNs�
            <config>
            <bfd xmlns="http://www.huawei.com/netconf/vrp" content-version="1.0" format-version="1.0">
            %s
            </bfd>
            </config>(RR&RR)(R3RBtxml_cfg((sU/usr/lib/python2.7/site-packages/ansible/modules/network/cloudengine/ce_bfd_global.pytnetconf_load_config�s

c	Cs�|jr1t|j�s1|jjdd�q1n|jdk	rw|jdks^|jdkrw|jjdd�qwn|jdk	r�|jdks�|jdkr�|jjdd�q�n|jdk	r|jdks�|jdkr|jjdd	�qn|jdk	rI|jdks0|jdkrI|jjdd
�qIn|j	dk	r�|j	dksv|j	dkr�|jjdd�q�n|j
dk	r�|j
dks�|j
dkr�|jjdd
�q�ndS(sCheck all input paramstmsgsError: Default ip is invalid.iis9Error: Session tos_exp_dynamic is not ranges from 0 to 7.s8Error: Session tos_exp_static is not ranges from 0 to 7.ii��6sCError: Session damp_init_wait_time is not ranges from 1 to 3600000.sBError: Session damp_max_wait_time is not ranges from 1 to 3600000.sEError: Session damp_second_wait_time is not ranges from 1 to 3600000.iXs9Error: Session delay_up_time is not ranges from 1 to 600.N(RRR&t	fail_jsonRR%RRRRR(R3((sU/usr/lib/python2.7/site-packages/ansible/modules/network/cloudengine/ce_bfd_global.pytcheck_params�s*	cCs�|j|jd<|j|jd<|j|jd<|j|jd<|j|jd<|j|jd<|j|jd<|j|jd<|j	|jd	<d
S(sget proposed infot
bfd_enalbeRRRRRRRR N(
RR0RRRRRRRR (R3((sU/usr/lib/python2.7/site-packages/ansible/modules/network/cloudengine/ce_bfd_global.pytget_proposed�scCs*|js
dS|jjd�|jd<dS(sget existing infoNR8(R+R[R1(R3((sU/usr/lib/python2.7/site-packages/ansible/modules/network/cloudengine/ce_bfd_global.pytget_existing�s	cCsN|j�}|sdS|jd�|jd<|j|jkrJt|_ndS(sget end state infoNR8(RFR[R2R1RR)(R3R+((sU/usr/lib/python2.7/site-packages/ansible/modules/network/cloudengine/ce_bfd_global.pyt
get_end_state�scCs�|j�|j�|_|j�|j�|j�}|rX|j|�t|_n|j	�|j|j
d<|j|j
d<|j|j
d<|j
|j
d<|jr�|j|j
d<nt�|j
d<|jj|j
�dS(tworkerR)R0R1R2tupdatesN(ReRFR+RhRgR`RbRR)RiR/R0R1R2R-R,R&t	exit_json(R3RB((sU/usr/lib/python2.7/site-packages/ansible/modules/network/cloudengine/ce_bfd_global.pytwork�s"




	(
t__name__t
__module__t__doc__R5R'RFR`RbReRgRhRiRm(((sU/usr/lib/python2.7/site-packages/ansible/modules/network/cloudengine/ce_bfd_global.pyR�s				}		&	
		cCstdtdtdddddg�dtdtdd�d	tdtdd
�dtdtdd
�dtdtdd
�d
tdtdd
�dtdtdd
�dtdtdd
�dtdtdddddg��	}|jt�t|�}|j�dS(sModule mainRtrequiredttypetstrtchoicesRJRLRRRRRRRRR tdefaultRMRON(R*RtupdateR	RRm(R4R&((sU/usr/lib/python2.7/site-packages/ansible/modules/network/cloudengine/ce_bfd_global.pytmains!$
t__main__(tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLEStRETURNtsystsockett	xml.etreeRtansible.module_utils.basicRt+ansible.module_utils.network.cloudengine.ceRRR	R
R:R;RtobjectRRwRn(((sU/usr/lib/python2.7/site-packages/ansible/modules/network/cloudengine/ce_bfd_global.pyt<module>s$


:(<"
	�3	

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