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_dldp.pyc

�
�Udac@s�idd6dgd6dd6ZdZdZdZd	d
lZd	dlmZd	dlmZd	d
l	m
Z
mZmZm
Z
dZdZdZdZdefd��YZd�Zedkr�e�nd
S(s1.1tmetadata_versiontpreviewtstatust	communitytsupported_bys,
---

module: ce_dldp
version_added: "2.4"
short_description: Manages global DLDP configuration on HUAWEI CloudEngine switches.
description:
    - Manages global DLDP configuration on HUAWEI CloudEngine switches.
author:
    - Zhijin Zhou (@QijunPan)
notes:
    - The relevant configurations will be deleted if DLDP is disabled using enable=disable.
    - When using auth_mode=none, it will restore the default DLDP authentication mode. By default,
      DLDP packets are not authenticated.
    - By default, the working mode of DLDP is enhance, so you are advised to use work_mode=enhance to restore default
      DLDP working mode.
    - The default interval for sending Advertisement packets is 5 seconds, so you are advised to use time_interval=5 to
      restore default DLDP interval.
    - 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:
    enable:
        description:
            - Set global DLDP enable state.
        choices: ['enable', 'disable']
    work_mode:
        description:
            - Set global DLDP work-mode.
        choices: ['enhance', 'normal']
    time_internal:
        description:
            - Specifies the interval for sending Advertisement packets.
              The value is an integer ranging from 1 to 100, in seconds.
              The default interval for sending Advertisement packets is 5 seconds.
    auth_mode:
        description:
            - Specifies authentication algorithm of DLDP.
        choices: ['md5', 'simple', 'sha', 'hmac-sha256', 'none']
    auth_pwd:
        description:
            - Specifies authentication password.
              The value is a string of 1 to 16 case-sensitive plaintexts or 24/32/48/108/128 case-sensitive encrypted
              characters. The string excludes a question mark (?).
    reset:
        description:
            - Specify whether reset DLDP state of disabled interfaces.
        choices: ['enable', 'disable']
sr
- name: DLDP 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: "Configure global DLDP enable state"
    ce_dldp:
      enable: enable
      provider: "{{ cli }}"

  - name: "Configure DLDP work-mode and ensure global DLDP state is already enabled"
    ce_dldp:
      enable: enable
      work_mode: normal
      provider: "{{ cli }}"

  - name: "Configure advertisement message time interval in seconds and ensure global DLDP state is already enabled"
    ce_dldp:
      enable: enable
      time_interval: 6
      provider: "{{ cli }}"

  - name: "Configure a DLDP authentication mode and ensure global DLDP state is already enabled"
    ce_dldp:
      enable: enable
      auth_mode: md5
      auth_pwd: abc
      provider: "{{ cli }}"

  - name: "Reset DLDP state of disabled interfaces and ensure global DLDP state is already enabled"
    ce_dldp:
      enable: enable
      reset: enable
      provider: "{{ cli }}"
s�
proposed:
    description: k/v pairs of parameters passed into module
    returned: always
    type: dict
    sample: {
                "enable": "enable",
                "reset": "enable",
                "time_internal": "12",
                "work_mode": "normal"
            }
existing:
    description: k/v pairs of existing global DLDP configuration
    returned: always
    type: dict
    sample: {
                "enable": "disable",
                "reset": "disable",
                "time_internal": "5",
                "work_mode": "enhance"
            }
end_state:
    description: k/v pairs of global DLDP configuration after module execution
    returned: always
    type: dict
    sample: {
                "enable": "enable",
                "reset": "enable",
                "time_internal": "12",
                "work_mode": "normal"
            }
updates:
    description: command sent to the device
    returned: always
    type: list
    sample: [
                "dldp enable",
                "dldp work-mode normal",
                "dldp interval 12",
                "dldp reset"
            ]
changed:
    description: check to see if a change was made on the device
    returned: always
    type: bool
    sample: true
i����N(tElementTree(t
AnsibleModule(tce_argument_spect
set_nc_configt
get_nc_configtexecute_nc_actions�
<action>
  <dldp xmlns="http://www.huawei.com/netconf/vrp" content-version="1.0" format-version="1.0">
    <resetDldp></resetDldp>
  </dldp>
</action>
s4
<filter type="subtree">
  <dldp xmlns="http://www.huawei.com/netconf/vrp" content-version="1.0" format-version="1.0">
    <dldpSys>
      <dldpEnable></dldpEnable>
      <dldpInterval></dldpInterval>
      <dldpWorkMode></dldpWorkMode>
      <dldpAuthMode></dldpAuthMode>
    </dldpSys>
  </dldp>
</filter>
s�
<config>
  <dldp xmlns="http://www.huawei.com/netconf/vrp" content-version="1.0" format-version="1.0">
    <dldpSys operation="merge">
      <dldpEnable>%s</dldpEnable>
      <dldpInterval>%s</dldpInterval>
      <dldpWorkMode>%s</dldpWorkMode>
s$
    </dldpSys>
  </dldp>
</config>
tDldpcBs�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�ZRS(s Manage global dldp configurationcCs||_d|_|j�|jjdp/d|_|jjdpHd|_|jjdpad|_|jjdpzd|_|jjd|_	|jjd|_
t�|_t
|_t
|_t�|_t�|_t�|_t�|_t�|_dS(Ntenablet	work_modet
time_intervaltresett	auth_modetauth_pwd(tspectNonetmoduletinit_moduletparamsRR
tinternalRRRtdictt	dldp_conftFalset	same_conftchangedtlisttupdates_cmdtresultstproposedtexistingt	end_state(tselft
argument_spec((sO/usr/lib/python2.7/site-packages/ansible/modules/network/cloudengine/ce_dldp.pyt__init__�s"		
		cCs�|jr#|j|jdkr#tS|jrF|j|jdkrFtSd}|jddkrhd}n|jr�|j|kr�tS|jr�|jdkr�tS|jdkr�|jdd	kr�tSn|jr�|jd
kr�tStS(s<Judge whether current config is the same as what we exceptedt
dldpEnabletdldpIntervaltnormaltdldpWorkModetdldpEnhancetenhancetnonetdldpAuthModetdldpAuthNoneR(RRRRR
RRtTrue(R#R
((sO/usr/lib/python2.7/site-packages/ansible/modules/network/cloudengine/ce_dldp.pytcheck_config_if_same�s"		"cCs@|jr"|jdkr"|js5|jrK|jrK|jjdd�n|jddkr�|jr�|js�|js�|js�|jr�|jjdd�q�n|jdkr�|js�|js�|js�|jr�|jjdd�n|jr_|jj	�s|jjdd�nt
|j�d	ksFt
|j�d
kr_|jjdd�q_n|jr<d|jkr�|jjdd
�nt|j�dkr<t|j�dkr<t|j�dkr<t|j�dkr<t|j�dkr<t|j�d	ks t|j�dkr9|jjdd�q9q<ndS(sCheck all input paramsR,tmsgs;Error: auth_mode and auth_pwd must both exist or not exist.R&tdisables�Error: when DLDP is already disabled globally, work_mode, time_internal auth_mode and reset parameters are not expected to configure.sxError: when using enable=disable, work_mode, time_internal auth_mode and reset parameters are not expected to configure.s#Error: time_interval must be digit.iids>Error: The value of time_internal should be between 1 and 100.t?s8Error: The auth_pwd string excludes a question mark (?).ii i0ili�iszError: The value is a string of 1 to 16 case-sensitive plaintexts or 24/32/48/108/128 case-sensitive encrypted characters.N(RRRt	fail_jsonRRR
RRtisdigittinttlen(R#((sO/usr/lib/python2.7/site-packages/ansible/modules/network/cloudengine/ce_dldp.pytcheck_paramss0"$3	
*
	
?**cCstd|jdt�|_dS(sInit module objectR$tsupports_check_modeN(RRR/R(R#((sO/usr/lib/python2.7/site-packages/ansible/modules/network/cloudengine/ce_dldp.pyR,scCs*d|kr&|jjdd|�ndS(s,Check if response message is already succeeds<ok/>R1sError: %s failed.N(RR4(R#txml_strtxml_name((sO/usr/lib/python2.7/site-packages/ansible/modules/network/cloudengine/ce_dldp.pytcheck_response2scCst�}t}t|j|�}d|kr1|S|jdd�jdd�jdd�jdd�}tj|�}|jd�}|s�|jjdd	�nxf|D]^}|j	dkr�|j	d
kr�|j
dkr�d}q�d}n	|j
}|||j	<q�q�W|S(s&Get current dldp existed configurations<data/>s
ts
s/xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"s)xmlns="http://www.huawei.com/netconf/vrp"sdldp/dldpSysR1s-Error: Get current DLDP configuration failed.R&R'R)R-ttrueRR2(s
dldpEnablesdldpIntervalsdldpWorkModesdldpAuthMode(RtCE_NC_GET_GLOBAL_DLDP_CONFIGR	RtreplaceRt
fromstringtfindR4ttagttext(R#RR:tcon_objtrootttopotelestvalue((sO/usr/lib/python2.7/site-packages/ansible/modules/network/cloudengine/ce_dldp.pytget_dldp_exist_config8s,	

			cCs
|jr
dS|j}|js/|jd}n|dkrDd}nd}|j}|jsl|jd}n|j}|js�|jd}n|dks�|d	kr�d	}nd
}|j}|js�|jd}n|dkr�d
}nT|dkrd}n?|dkrd}n*|dkr+d}n|dkr@d}nt|||f}|jr�|jdkrx|d7}q�|d|7}|d|j7}n|t7}t	|j
|�}|j|d�|jdkrt
}t|j
|�}|j|d�nt|_dS(sConfig global dldpNR&RR>tfalseR'R)R+R*t
dldpNormalR-tmd5tdldpAuthMD5tsimpletdldpAuthSimpletshatdldpAuthSHAshmac-sha256sdldpAuthHMAC-SHA256R,R.s)<dldpAuthMode>dldpAuthNone</dldpAuthMode>s<dldpAuthMode>%s</dldpAuthMode>s!<dldpPasswords>%s</dldpPasswords>tMERGE_DLDP_GLOBAL_CONFIGtACTION_RESET_DLDP(RRRRR
Rt#CE_NC_MERGE_DLDP_GLOBAL_CONFIG_HEADRt#CE_NC_MERGE_DLDP_GLOBAL_CONFIG_TAILRRR<RtCE_NC_ACTION_RESET_DLDPR
R/R(R#RRR
RR:tret_xml((sO/usr/lib/python2.7/site-packages/ansible/modules/network/cloudengine/ce_dldp.pytconfig_global_dldpYsZ																	

cCst�}|jjdd�|d<|jjdd�|d<|jjdd�}|dkrid|d<n
d	|d<|jjd
d�}|dkr�d|d
<nU|dkr�d|d
<n<|dkr�d|d
<n#|dkr�d|d
<n
d|d
<d|d<tj|�|_dS(sGet existing infoR&RR'RR)R*R+R
R(R-R.R,RRPRORNRMRRRQshmac-sha256R2RN(RRtgetRtcopytdeepcopyR!(R#RR
R((sO/usr/lib/python2.7/site-packages/ansible/modules/network/cloudengine/ce_dldp.pytget_existing�s&	







c
CsFtd|jd|jd|jd|jd|jd|j�|_dS(sGet proposed resultRR
RRRRN(RRR
RRRRR (R#((sO/usr/lib/python2.7/site-packages/ansible/modules/network/cloudengine/ce_dldp.pytget_proposed�scCs�|jr
dS|jrt|j|jdkrt|jdkrN|jjd�qt|jdkrt|jjd�dSnd}|jdd	kr�d
}n|jr�|j|kr�|jd
kr�|jjd�q�|jjd�n|jr|j|jd
kr|jjd|j�n|jrj|jdkrG|jjd�qj|jjd|j|jf�n|j	r�|j	dkr�|jjd�ndS(sGet update commandsNR&Rsdldp enableR2sundo dldp enableR(R)R*R+sdldp work-mode enhancesdldp work-mode normalR'sdldp interval %sR,sundo dldp authentication-modesdldp authentication-mode %s %ss
dldp reset(
RRRRtappendR
RRRR(R#R
((sO/usr/lib/python2.7/site-packages/ansible/modules/network/cloudengine/ce_dldp.pytget_update_cmd�s.			#cCsAt�}|j�|_|jjdd�|d<|jjdd�|d<|jjdd�}|dkrxd|d<n
d	|d<|jjd
d�}|dkr�d|d
<nU|dkr�d|d
<n<|dkr�d|d
<n#|dkr�d|d
<n
d|d
<d|d<|jdkr+d|d<ntj|�|_dS(sGet end state infoR&RR'RR)R*R+R
R(R-R.R,RRPRORNRMRRRQshmac-sha256R2RN(	RRJRRZRRR[R\R"(R#RR
R((sO/usr/lib/python2.7/site-packages/ansible/modules/network/cloudengine/ce_dldp.pyt
get_end_state�s,	








cCs�|j|jd<|j|jd<|j|jd<|j|jd<|jr\|j|jd<nt�|jd<|jj|j�dS(sShow resultRR R!R"tupdatesN(	RRR R!R"RRRt	exit_json(R#((sO/usr/lib/python2.7/site-packages/ansible/modules/network/cloudengine/ce_dldp.pytshow_result�s	cCsh|j�|_|j�|j�|_|j�|j�|j�|j�|j	�|j
�dS(tWorkerN(RJRR8R0RR]R^RYR`RaRd(R#((sO/usr/lib/python2.7/site-packages/ansible/modules/network/cloudengine/ce_dldp.pytworks





(t__name__t
__module__t__doc__R%R0R8RR<RJRYR]R^R`RaRdRf(((sO/usr/lib/python2.7/site-packages/ansible/modules/network/cloudengine/ce_dldp.pyR�s			&			!	=			!		cCs�tdtdddgdd�dtdddgdd�d	tdd�d
tdddgdd�dtddd
dddgdd�dtdddt��}|jt�t|�}|j�dS(sMain function entryRtchoicesR2ttypetstrR
R+R(RRRRMRORQshmac-sha256R,Rtno_logN(RR/tupdateRRRf(R$tdldp_obj((sO/usr/lib/python2.7/site-packages/ansible/modules/network/cloudengine/ce_dldp.pytmains$
t__main__(tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLEStRETURNR[t	xml.etreeRtansible.module_utils.basicRt+ansible.module_utils.network.cloudengine.ceRRR	R
RWR?RURVtobjectRRpRg(((sO/usr/lib/python2.7/site-packages/ansible/modules/network/cloudengine/ce_dldp.pyt<module>s$


2.0"
	�F	

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