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_view.pyo

�
�Udac@s�idd6dgd6dd6ZdZdZdZd	d
lZd	dlmZd	dlmZd	d
l	m
Z
mZmZdZ
dZdZdefd��YZd�Zedkr�e�nd
S(s1.1tmetadata_versiontpreviewtstatust	communitytsupported_bysu

---
module: ce_bfd_view
version_added: "2.4"
short_description: Manages BFD session view configuration on HUAWEI CloudEngine devices.
description:
    - Manages BFD session view 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:
    session_name:
        description:
            - Specifies the name of a BFD session.
              The value is a string of 1 to 15 case-sensitive characters without spaces.
        required: true
    local_discr:
        description:
            - Specifies the local discriminator of a BFD session.
              The value is an integer that ranges from 1 to 16384.
    remote_discr:
        description:
            - Specifies the remote discriminator of a BFD session.
              The value is an integer that ranges from 1 to 4294967295.
    min_tx_interval:
        description:
            - Specifies the minimum interval for receiving BFD packets.
              The value is an integer that ranges from 50 to 1000, in milliseconds.
    min_rx_interval:
        description:
            - Specifies the minimum interval for sending BFD packets.
              The value is an integer that ranges from 50 to 1000, in milliseconds.
    detect_multi:
        description:
            - Specifies the local detection multiplier of a BFD session.
              The value is an integer that ranges from 3 to 50.
    wtr_interval:
        description:
            - Specifies the WTR time of a BFD session.
              The value is an integer that ranges from 1 to 60, in minutes.
              The default value is 0.
    tos_exp:
        description:
            - Specifies a priority for BFD control packets.
              The value is an integer ranging from 0 to 7.
              The default value is 7, which is the highest priority.
    admin_down:
        description:
            - Enables the BFD session to enter the AdminDown state.
              By default, a BFD session is enabled.
              The default value is bool type.
        type: bool
        default: 'no'
    description:
        description:
            - Specifies the description of a BFD session.
              The value is a string of 1 to 51 case-sensitive characters with spaces.
    state:
        description:
            - Determines whether the config should be present or not on the device.
        default: present
        choices: ['present', 'absent']
extends_documentation_fragment: ce
s�
- name: bfd view 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: Set the local discriminator of a BFD session to 80 and the remote discriminator to 800
    ce_bfd_view:
      session_name: atob
      local_discr: 80
      remote_discr: 800
      state: present
      provider: '{{ cli }}'

  - name: Set the minimum interval for receiving BFD packets to 500 ms
    ce_bfd_view:
      session_name: atob
      min_rx_interval: 500
      state: present
      provider: '{{ cli }}'
s
proposed:
    description: k/v pairs of parameters passed into module
    returned: always
    type: dict
    sample: {
        "admin_down": false,
        "description": null,
        "detect_multi": null,
        "local_discr": 80,
        "min_rx_interval": null,
        "min_tx_interval": null,
        "remote_discr": 800,
        "session_name": "atob",
        "state": "present",
        "tos_exp": null,
        "wtr_interval": null
    }
existing:
    description: k/v pairs of existing configuration
    returned: always
    type: dict
    sample: {
        "session": {
            "adminDown": "false",
            "createType": "SESS_STATIC",
            "description": null,
            "detectMulti": "3",
            "localDiscr": null,
            "minRxInt": null,
            "minTxInt": null,
            "remoteDiscr": null,
            "sessName": "atob",
            "tosExp": null,
            "wtrTimerInt": null
        }
    }
end_state:
    description: k/v pairs of configuration after module execution
    returned: always
    type: dict
    sample: {
        "session": {
            "adminDown": "false",
            "createType": "SESS_STATIC",
            "description": null,
            "detectMulti": "3",
            "localDiscr": "80",
            "minRxInt": null,
            "minTxInt": null,
            "remoteDiscr": "800",
            "sessName": "atob",
            "tosExp": null,
            "wtrTimerInt": null
        }
    }
updates:
    description: commands sent to the device
    returned: always
    type: list
    sample: [
        "bfd atob",
        "discriminator local 80",
        "discriminator remote 800"
    ]
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_specs�
    <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>
        </bfdSchGlobal>
s�
        <bfdCfgSessions>
          <bfdCfgSession>
            <sessName>%s</sessName>
            <createType></createType>
            <localDiscr></localDiscr>
            <remoteDiscr></remoteDiscr>
            <minTxInt></minTxInt>
            <minRxInt></minRxInt>
            <detectMulti></detectMulti>
            <wtrTimerInt></wtrTimerInt>
            <tosExp></tosExp>
            <adminDown></adminDown>
            <description></description>
          </bfdCfgSession>
        </bfdCfgSessions>
tBfdViewcBsheZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�ZRS(sManages BFD ViewcCs�||_d|_|j�|jjd|_|jjd|_|jjd|_|jjd|_|jjd|_	|jjd|_
|jjd|_|jjd|_|jjd	|_
|jjd
|_|jjd|_|jjd|_|jjd
|_|jjd|_t|_t�|_t�|_t�|_t�|_t�|_t�|_t�|_dS(Ntsession_nametlocal_discrtremote_discrtmin_tx_intervaltmin_rx_intervaltdetect_multitwtr_intervalttos_expt
admin_downtdescriptiontstatethosttusernametport(tspectNonetmodulet__init_module__tparamsRRR
RRRRRRRRRRRtFalsetchangedtdicttbfd_dicttlisttupdates_cmdtcommandstresultstproposedtexistingt	end_state(tselft
argument_spec((sS/usr/lib/python2.7/site-packages/ansible/modules/network/cloudengine/ce_bfd_view.pyt__init__�s2		
	cCstd|jdt�|_dS(sinit moduleR*tsupports_check_modeN(RRtTrueR(R)((sS/usr/lib/python2.7/site-packages/ansible/modules/network/cloudengine/ce_bfd_view.pyRscCst�}t�|d<t�|d<ttt|j}t|j|�}d|krZ|S|jdd�jdd�jdd�jdd�}tj	|�}|j
d	�}|r�x%|D]}|j|d|j<q�Wn|j
d
�}|rx%|D]}|j|d|j<q�Wn|S(sbfd config dicttglobaltsessions<data/>s
ts
s/xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"s)xmlns="http://www.huawei.com/netconf/vrp"sbfd/bfdSchGlobals bfd/bfdCfgSessions/bfdCfgSession(
R t
CE_NC_GET_BFDtCE_NC_GET_BFD_GLBtCE_NC_GET_BFD_SESSIONRRRtreplaceRt
fromstringtfindttextttag(R)R!tconf_strtxml_strtroottglbtattrtsess((sS/usr/lib/python2.7/site-packages/ansible/modules/network/cloudengine/ce_bfd_view.pytget_bfd_dicts(	



cCs�d}t�}d}|js"|S|jdjdd�dkrW|jjdd�n|jdsz|jjdd	�n|jd}d
|j}d|j}|jd?k	rO|jdkrt	|j�|jd
�kr|d|j7}|j
d|j�qO|jdkrOt	|j�|jd
�krO|d7}|j
d�qOn|jd?k	r�|jdkr�t	|j�|jd�kr�|d|j7}|j
d|j�q�|jdkr�t	|j�|jd�kr�|d7}|j
d�q�n|jd?k	r�|jdkrat	|j�|jd�kra|d|j7}|j
d|j�q�|jdkr�t	|j�|jd�kr�|d7}|j
d�q�n|j
d?k	rY|jdkrt	|j
�|jd�kr|d|j
7}|j
d|j
�qY|jdkrYt	|j
�|jd�krY|d 7}|j
d!�qYn|jd?k	r|jdkr�t	|j�|jd"�kr�|d#|j7}|j
d$|j�q|jdkrt	|j�|jd"�kr|d%7}|j
d&�qn|jd?k	r�|jdkrkt	|j�|jd'�krk|d(|j7}|j
d)|j�q�|jdkr�t	|j�|jd'�kr�|d*7}|j
d+�q�n|jd?k	rc|jdkrt	|j�|jd,�kr|d-|j7}|j
d.|j�qc|jdkrct	|j�|jd,�krc|d/7}|j
d0�qcn|jr�|jd1d�dkr�|d27}|j
d3�n<|jr�|jd1d�dkr�|d47}|j
d5�n|jrv|jdkr2|j|jd6�kr2|d7|j7}|j
d8|j�qv|jdkrv|j|jd6�krv|d97}|j
d:�qvn|jd;�r�dS|jd<|�|jj|�d=|d>Sd?S(@sconfigures bfd sessionR0R.t	bfdEnabletfalsettruetmsgs(Error: Please enable BFD globally first.R/s Error: BFD session is not exist.s<sessName>%s</sessName>sbfd %stpresentt
localDiscrs<localDiscr>%s</localDiscr>sdiscriminator local %stabsents
<localDiscr/>sundo discriminator localtremoteDiscrs<remoteDiscr>%s</remoteDiscr>sdiscriminator remote %ss<remoteDiscr/>sundo discriminator remotetminTxInts<minTxInt>%s</minTxInt>smin-tx-interval %ss<minTxInt/>sundo min-tx-intervaltminRxInts<minRxInt>%s</minRxInt>smin-rx-interval %ss<minRxInt/>sundo min-rx-intervaltdetectMultis <detectMulti>%s</detectMulti>sdetect-multiplier %ss <detectMulti/>sundo detect-multipliertwtrTimerInts <wtrTimerInt>%s</wtrTimerInt>swtr %ss <wtrTimerInt/>sundo wtrttosExps <tosExp>%s</tosExp>s
tos-exp %ss
 <tosExp/>sundo tos-expt	adminDowns <adminDown>true</adminDown>tshutdowns <adminDown>false</adminDown>s
undo shutdownRs<description>%s</description>sdescription %ss<description/>sundo descriptions</sessName>is1<bfdCfgSessions><bfdCfgSession operation="merge">s!</bfdCfgSession></bfdCfgSessions>N(R"RR!tgetRt	fail_jsonRRRtstrtappendR
RRRRRRRtendswithtinsertR#textend(R)R:tcmd_listtcmd_sessionR/((sS/usr/lib/python2.7/site-packages/ansible/modules/network/cloudengine/ce_bfd_view.pytconfig_session0s�		



--
--
--
--
--
--
--
!
"
	''
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>(RRR-R(R)R:txml_cfg((sS/usr/lib/python2.7/site-packages/ansible/modules/network/cloudengine/ce_bfd_view.pytnetconf_load_config�s

cCs�|js|jjdd�n|jrkt|j�dksRt|j�dkrk|jjdd�qkn|jdk	r�|jdks�|jdkr�|jjdd�q�n|jdk	r�|jdks�|jdkr�|jjdd	�q�n|jdk	r=|jd
ks$|jdkr=|jjdd�q=n|jdk	r�|jd
ksj|jdkr�|jjdd
�q�n|j	dk	r�|j	dks�|j	d
kr�|jjdd�q�n|j
dk	r|j
dks�|j
dkr|jjdd�qn|jdk	rU|jdks<|jdkrU|jjdd�qUn|jr�t|j�dks�t|j�dkr�|jjdd�q�ndS(sCheck all input paramsRCs0Error: Missing required arguments: session_name.iisError: Session name is invalid.i@s9Error: Session local_discr is not ranges from 1 to 16384.I����s?Error: Session remote_discr is not ranges from 1 to 4294967295.i2i�s=Error: Session min_tx_interval is not ranges from 50 to 1000.s=Error: Session min_rx_interval is not ranges from 50 to 1000.is7Error: Session detect_multi is not ranges from 3 to 50.i<s7Error: Session wtr_interval is not ranges from 1 to 60.iis1Error: Session tos_exp is not ranges from 0 to 7.i3s&Error: Session description is invalid.N(
RRRPtlenRRR
RRRRRR(R)((sS/usr/lib/python2.7/site-packages/ansible/modules/network/cloudengine/ce_bfd_view.pytcheck_params�s:		*	*cCs�|j|jd<|j|jd<|j|jd<|j|jd<|j|jd<|j|jd<|j|jd<|j|jd<|j	|jd	<|j
|jd
<|j|jd<dS(
sget proposed infoRRR
RRRRRRRRN(RR&RR
RRRRRRRR(R)((sS/usr/lib/python2.7/site-packages/ansible/modules/network/cloudengine/ce_bfd_view.pytget_proposed�scCs*|js
dS|jjd�|jd<dS(sget existing infoNR/(R!ROR'(R)((sS/usr/lib/python2.7/site-packages/ansible/modules/network/cloudengine/ce_bfd_view.pytget_existing�s	cCsN|j�}|sdS|jd�|jd<|j|jkrJt|_ndS(sget end state infoNR/(R?ROR(R'RR(R)R!((sS/usr/lib/python2.7/site-packages/ansible/modules/network/cloudengine/ce_bfd_view.pyt
get_end_state�scCs�|j�|j�|_|j�|j�d}|jrO||j�7}n|rn|j|�t|_	n|j
�|j	|jd<|j|jd<|j
|jd<|j|jd<|j	r�|j|jd<nt�|jd<|jj|j�dS(tworkerR0RR&R'R(tupdatesN(R\R?R!R^R]RRXRZR-RR_R%R&R'R(R#R"Rt	exit_json(R)R:((sS/usr/lib/python2.7/site-packages/ansible/modules/network/cloudengine/ce_bfd_view.pytwork�s&


	

	(
t__name__t
__module__t__doc__R+RR?RXRZR\R]R^R_Rc(((sS/usr/lib/python2.7/site-packages/ansible/modules/network/cloudengine/ce_bfd_view.pyR
�s	!			e		3			cCs)tdtdtdd�dtdtdd�dtdtdd�dtdtdd�d	tdtdd�d
tdtdd�dtdtdd�dtdtdd�d
tdtdddt�dtdtdd�dtdtdddddg��}|jt�t|�}|j�dS(sModule mainRtrequiredttypeRQRtintR
RRRRRRtbooltdefaultRRRDtchoicesRFN(R R-RtupdateR	R
Rc(R*R((sS/usr/lib/python2.7/site-packages/ansible/modules/network/cloudengine/ce_bfd_view.pytmains$
t__main__(tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLEStRETURNtsyst	xml.etreeRtansible.module_utils.basicRt+ansible.module_utils.network.cloudengine.ceRRR	R1R2R3tobjectR
RnRd(((sS/usr/lib/python2.7/site-packages/ansible/modules/network/cloudengine/ce_bfd_view.pyt<module>s"


CH	�4	

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