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

�
�Udac@s�idd6dgd6dd6ZdZdZdZd	d
lmZd	dlmZd	dlm	Z	m
Z
mZd
ZdZ
dZdZdZdZdZdZdZdZdZdZd�Zd�Zdefd��YZd�Zedkr�e�ndS( s1.1tmetadata_versiontpreviewtstatust	communitytsupported_bys�

---
module: ce_interface_ospf
version_added: "2.4"
short_description: Manages configuration of an OSPF interface instanceon HUAWEI CloudEngine switches.
description:
    - Manages configuration of an OSPF interface instanceon HUAWEI CloudEngine switches.
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:
    interface:
        description:
            - Full name of interface, i.e. 40GE1/0/10.
        required: true
    process_id:
        description:
            - Specifies a process ID.
              The value is an integer ranging from 1 to 4294967295.
        required: true
    area:
        description:
            - Ospf area associated with this ospf process.
              Valid values are a string, formatted as an IP address
              (i.e. "0.0.0.0") or as an integer between 1 and 4294967295.
        required: true
    cost:
        description:
            - The cost associated with this interface.
              Valid values are an integer in the range from 1 to 65535.
    hello_interval:
        description:
            - Time between sending successive hello packets.
              Valid values are an integer in the range from 1 to 65535.
    dead_interval:
        description:
            - Time interval an ospf neighbor waits for a hello
              packet before tearing down adjacencies. Valid values are an
              integer in the range from 1 to 235926000.
    silent_interface:
        description:
            - Setting to true will prevent this interface from receiving
              HELLO packets. Valid values are 'true' and 'false'.
        type: bool
        default: 'no'
    auth_mode:
        description:
            - Specifies the authentication type.
        choices: ['none', 'null', 'hmac-sha256', 'md5', 'hmac-md5', 'simple']
    auth_text_simple:
        description:
            - Specifies a password for simple authentication.
              The value is a string of 1 to 8 characters.
    auth_key_id:
        description:
            - Authentication key id when C(auth_mode) is 'hmac-sha256', 'md5' or 'hmac-md5.
              Valid value is an integer is in the range from 1 to 255.
    auth_text_md5:
        description:
            - Specifies a password for MD5, HMAC-MD5, or HMAC-SHA256 authentication.
              The value is a string of 1 to 255 case-sensitive characters, spaces not supported.
    state:
        description:
            - Determines whether the config should be present or not
              on the device.
        default: present
        choices: ['present','absent']
sC
- name: eth_trunk 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: Enables OSPF and sets the cost on an interface
    ce_interface_ospf:
      interface: 10GE1/0/30
      process_id: 1
      area: 100
      cost: 100
      provider: '{{ cli }}'

  - name: Sets the dead interval of the OSPF neighbor
    ce_interface_ospf:
      interface: 10GE1/0/30
      process_id: 1
      area: 100
      dead_interval: 100
      provider: '{{ cli }}'

  - name: Sets the interval for sending Hello packets on an interface
    ce_interface_ospf:
      interface: 10GE1/0/30
      process_id: 1
      area: 100
      hello_interval: 2
      provider: '{{ cli }}'

  - name: Disables an interface from receiving and sending OSPF packets
    ce_interface_ospf:
      interface: 10GE1/0/30
      process_id: 1
      area: 100
      silent_interface: true
      provider: '{{ cli }}'
s	
proposed:
    description: k/v pairs of parameters passed into module
    returned: verbose mode
    type: dict
    sample: {"process_id": "1", "area": "0.0.0.100", "interface": "10GE1/0/30", "cost": "100"}
existing:
    description: k/v pairs of existing configuration
    returned: verbose mode
    type: dict
    sample: {"process_id": "1", "area": "0.0.0.100"}
end_state:
    description: k/v pairs of configuration after module execution
    returned: verbose mode
    type: dict
    sample: {"process_id": "1", "area": "0.0.0.100", "interface": "10GE1/0/30",
             "cost": "100", "dead_interval": "40", "hello_interval": "10",
             "silent_interface": "false", "auth_mode": "none"}
updates:
    description: commands sent to the device
    returned: always
    type: list
    sample: ["interface 10GE1/0/30",
             "ospf enable 1 area 0.0.0.100",
             "ospf cost 100"]
changed:
    description: check to see if a change was made on the device
    returned: always
    type: bool
    sample: true
i����(tElementTree(t
AnsibleModule(t
get_nc_configt
set_nc_configtce_argument_specs�
    <filter type="subtree">
      <ospfv2 xmlns="http://www.huawei.com/netconf/vrp" content-version="1.0" format-version="1.0">
        <ospfv2comm>
          <ospfSites>
            <ospfSite>
              <processId>%s</processId>
              <routerId></routerId>
              <vrfName></vrfName>
              <areas>
                <area>
                  <areaId>%s</areaId>
                  <interfaces>
                    <interface>
                      <ifName>%s</ifName>
                      <networkType></networkType>
                      <helloInterval></helloInterval>
                      <deadInterval></deadInterval>
                      <silentEnable></silentEnable>
                      <configCost></configCost>
                      <authenticationMode></authenticationMode>
                      <authTextSimple></authTextSimple>
                      <keyId></keyId>
                      <authTextMd5></authTextMd5>
                    </interface>
                  </interfaces>
                </area>
              </areas>
            </ospfSite>
          </ospfSites>
        </ospfv2comm>
      </ospfv2>
    </filter>
s�
    <config>
      <ospfv2 xmlns="http://www.huawei.com/netconf/vrp" content-version="1.0" format-version="1.0">
        <ospfv2comm>
          <ospfSites>
            <ospfSite>
              <processId>%s</processId>
              <areas>
                <area>
                  <areaId>%s</areaId>
                  %s
                </area>
              </areas>
            </ospfSite>
          </ospfSites>
        </ospfv2comm>
      </ospfv2>
    </config>
s�
                  <interfaces>
                    <interface operation="merge">
                    %s
                    </interface>
                  </interfaces>
s�
                  <interfaces>
                    <interface operation="delete">
                    %s
                    </interface>
                  </interfaces>
s+
                      <ifName>%s</ifName>
s9
                      <helloInterval>%s</helloInterval>
s7
                      <deadInterval>%s</deadInterval>
s7
                      <silentEnable>%s</silentEnable>
s3
                      <configCost>%s</configCost>
sC
                      <authenticationMode>%s</authenticationMode>
s;
                      <authTextSimple>%s</authTextSimple>
s]
                      <keyId>%s</keyId>
                      <authTextMd5>%s</authTextMd5>
cCs@|d%krd%Sd%}|j�jd�r4d}n|j�jd�rRd}n�|j�jd�rpd}n�|j�jd�r�d}n�|j�jd	�r�d
}n�|j�jd�r�d}nl|j�jd
�r�d}nN|j�jd�rd}n0|j�jd�r$d}n|j�jd�rBd}n�|j�jd�r`d}n�|j�jd�r~d}n�|j�jd�r�d}n�|j�jd�r�d}n||j�jd�r�d}n^|j�jd�r�d }n@|j�jd!�rd"}n"|j�jd#�r2d$}nd%S|j�S(&s>Gets the type of interface, such as 10GE, ETH-TRUNK, VLANIF...tGEtget10GEt10get25GEt25get4X10GEt4x10get40GEt40get100GEt100getVLANIFtvlaniftLOOPBACKtloopbacktMETHtmeths	ETH-TRUNKs	eth-trunktVBDIFtvbdiftNVEtnvetTUNNELttunneltETHERNETtethernets	FCOE-PORTs	fcoe-portsFABRIC-PORTsfabric-ports
STACK-PORTs
stack-porttNULLtnullN(tNonetuppert
startswithtlower(t	interfacetiftype((sY/usr/lib/python2.7/site-packages/ansible/modules/network/cloudengine/ce_interface_ospf.pytget_interface_typesR																		cCs�|s
tS|jd�dkr|jd�}t|�dkrDtSx4|D],}|j�satSt|�dkrKtSqKWtStS(scheck is ipv4 addr is validt.i����ii�(tFalsetfindtsplittlentisdigittinttTrue(taddrt	addr_listteach_num((sY/usr/lib/python2.7/site-packages/ansible/modules/network/cloudengine/ce_interface_ospf.pytis_valid_v4addrLs
t
InterfaceOSPFcBs�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�ZRS(s>
    Manages configuration of an OSPF interface instance.
    cCsU||_d|_|j�|jjd|_|jjd|_|jjd|_|jjd|_|jjd|_	|jjd|_
|jjd|_|jjd|_|jjd	|_
|jjd
|_|jjd|_|jjd|_t�|_t|_t�|_t�|_t�|_t�|_t�|_dS(
NR*t
process_idtareatcostthello_intervalt
dead_intervaltsilent_interfacet	auth_modetauth_text_simpletauth_key_idt
auth_text_md5tstate(tspecR&tmoduletinit_moduletparamsR*R:R;R<R=R>R?R@RARBRCRDtdictt	ospf_infoR.tchangedtlisttupdates_cmdtresultstproposedtexistingt	end_state(tselft
argument_spec((sY/usr/lib/python2.7/site-packages/ansible/modules/network/cloudengine/ce_interface_ospf.pyt__init__es,		
	cCstd|jdt�|_dS(sinit moduleRStsupports_check_modeN(RRER4RF(RR((sY/usr/lib/python2.7/site-packages/ansible/modules/network/cloudengine/ce_interface_ospf.pyRG�scCs<t|j|�}d|kr8|jjdd|�ndS(snetconf set configs<ok/>tmsgsError: %s failed.N(RRFt	fail_json(RRtxml_strtxml_nametrcv_xml((sY/usr/lib/python2.7/site-packages/ansible/modules/network/cloudengine/ce_interface_ospf.pytnetconf_set_config�scCs�|jj�s|jSdgd}tt|j�d@d?d@�|d<tt|j�d@d?d@�|d	<tt|j�d
@d?d@�|d<tt|j�d@�|d
<dj|�S(sconvert integer to ip addresst0iI�ii�ii�iii�iiiR-(R;R2tstrR3tjoin(RRtaddr_int((sY/usr/lib/python2.7/site-packages/ansible/modules/network/cloudengine/ce_interface_ospf.pytget_area_ip�s
%%%cCs�t�}t|j|j�|jf}t|j|�}d|krJ|S|jdd�jdd�jdd�jdd�}tj	|�}|j
d�}|s�|jjdd	�nx0|D](}|jdkr�|j
||j<q�q�Wd|d
<|j
d�}|r@x1|D]&}	|	jd
kr|	j
|d
<PqqWnt�|d<|j
d�}
|
r�x7|
D],}|jdkri|j
|d|j<qiqiWn|S(s get one ospf attributes dict.s<data/>s
ts
s/xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"s)xmlns="http://www.huawei.com/netconf/vrp"s$ospfv2/ospfv2comm/ospfSites/ospfSiteRVs#Error: ospf process does not exist.t	processIdtrouterIdtvrfNametareaIds/ospfv2/ospfv2comm/ospfSites/ospfSite/areas/areaR*sDospfv2/ospfv2comm/ospfSites/ospfSite/areas/area/interfaces/interfacetifNametnetworkTypet
helloIntervaltdeadIntervaltsilentEnablet
configCosttauthenticationModetauthTextSimpletkeyIdtauthTextMd5(RbRcRd(
RfRgRhRiRjRkRlRmRnRo(RItCE_NC_GET_OSPFR:R`R*RRFtreplaceRt
fromstringR/RWttagttext(RRRJtconf_strRZRXtroottospfsitetsitetareasR;tintftattr((sY/usr/lib/python2.7/site-packages/ansible/modules/network/cloudengine/ce_interface_ospf.pyt
get_ospf_dict�sH	

	


	
	cCs�t|j}|jjd|j�|jjd|j��|jr�|tt|j�j	�7}|jr�|jjd|j�q�|jjd|j�n|jjd|j�|jjd|j|j�f�|j
r|t|j
7}|jjd|j
�n|jrC|t
|j7}|jjd|j�n|jrw|t|j7}|jjd	|j�n|jr�|t|j7}|jd
kr�|jjd�n|jjd|j�|jd
kr#|jr#|t|j7}|jj�|jjd|j|jf�q�|jdkr�|jr�|t|j|jf7}|jj�|jjd|j|j|jf�q�nt|j|j�t|f}|j|d�t|_dS(s6set interface ospf enable, and set its ospf attributessospf %ssarea %sssilent-interface %ssundo silent-interface %ssinterface %ssospf enable %s area %ssospf cost %ssospf timer hello %ssospf timer dead %stnonesundo ospf authentication-modesospf authentication-mode %stsimplesospf authentication-mode %s %sshmac-sha256tmd5shmac-md5s!ospf authentication-mode %s %s %stSET_INTERFACE_OSPFN(shmac-sha256Rshmac-md5(tCE_NC_XML_SET_IF_NAMER*RMtappendR:R`R?tCE_NC_XML_SET_SILENTR]R)R<tCE_NC_XML_SET_COSTR=tCE_NC_XML_SET_HELLOR>tCE_NC_XML_SET_DEADR@tCE_NC_XML_SET_AUTH_MODERAtCE_NC_XML_SET_AUTH_TEXT_SIMPLEtpopRBtCE_NC_XML_SET_AUTH_MD5RCtCE_NC_XML_BUILD_PROCESStCE_NC_XML_BUILD_MERGE_INTFR[R4RK(RRtxml_intfRX((sY/usr/lib/python2.7/site-packages/ansible/modules/network/cloudengine/ce_interface_ospf.pytset_ospf_interface�sV
						

		cCsZ|jd}d}|jd�t|j�j�kr�|tt|j�j�7}|jjd|j�|jjd|j	��|jr�|jjd|j
�q�|jjd|j
�nd}|jjd|j
�|jr+|jd	�|jkr+|t|j7}|jjd
|j�n|j
rw|jd�|j
krw|t|j
7}|jjd|j
�n|jr�|jd
�|jkr�|t|j7}|jjd|j�n|jr�|t|j7}|jdkr�|jjd�n|jjd|j�|jdkro|jro|t|j7}|jj�|jjd|j|jf�q�|jdkr�|jr�|t|j|jf7}|jj�|jjd|j|j|jf�q�n|s�|jj�n|r|rdSt|j
}|||7}t|j|j	�t|f}|j|d�t|_dS(smerge interface ospf attributesR*RaRjsospf %ssarea %sssilent-interface %ssundo silent-interface %ssinterface %sRksospf cost %sRhsospf timer hello %sRisospf timer dead %sR}sundo ospf authentication-modesospf authentication-mode %sR~sospf authentication-mode %s %sshmac-sha256Rshmac-md5s!ospf authentication-mode %s %s %sNtMERGE_INTERFACE_OSPF(shmac-sha256smd5shmac-md5(RJtgetR]R?R)R�RMR�R:R`R*R<R�R=R�R>R�R@R�RAR�R�RBR�RCR�R�R�R[R4RK(RRt	intf_dicttxml_ospfR�txml_sumRX((sY/usr/lib/python2.7/site-packages/ansible/modules/network/cloudengine/ce_interface_ospf.pytmerge_ospf_interfacesb
$	!!!	


		cCs@|jd}d}t|j}|jd�dkr�|t|td7}|jjd|j�|jjd|j	��|jjd|j�n|t
|7}t|j|j	�|f}|j|d	�|jjd
�|jjd�|jjd�|jjd
�|jjd|j|j	�f�t
|_dS(sGset interface ospf disable, and all its ospf attributes will be removedR*RaRjttruetfalsesospf %ssarea %ssundo silent-interface %stDELETE_INTERFACE_OSPFsundo ospf costsundo ospf timer hellosundo ospf timer deadsundo ospf authentication-modesundo ospf enable %s area %sN(RJR�R*R�R�R�RMR�R:R`tCE_NC_XML_BUILD_DELETE_INTFR�R[R4RK(RRR�R�R�RX((sY/usr/lib/python2.7/site-packages/ansible/modules/network/cloudengine/ce_interface_ospf.pytunset_ospf_interfaceFs,

			
c
Cs�|jjdd�j�|_t|j�sC|jjdd�n|jj�sh|jjdd�nt|j�dks�t|j�dkr�|jjdd�n|j	j�r�t|j	�d	ks�t|j	�dkr|jjdd
�qn%t
|j	�s|jjdd�n|jdkr�|jr�|jd
kr}|j
r}t|j
�dkr}|jjdd�q}n|jd kr�|jr�|jr�|jjdd�n|jr�|jr�|jjdd�n|jrO|jj�s|jjdd�nt|j�dks6t|j�dkrO|jjdd�qOn|jr�t|j�dkr�|jjdd�q�q�q�n|jr�|jj�s�|jjdd�nt|j�dks�t|j�dkr�|jjdd�q�n|jrn|jj�s+|jjdd�nt|j�dksUt|j�dkrn|jjdd�qnn|jr�|jj�s�|jjdd�nt|j�dks�t|j�dkr�|jjdd�q�ndS(!sCheck all input paramst RaRVsError: interface is invalid.sError: process_id is not digit.iI����s>Error: process_id must be an integer between 1 and 4294967295.is:Error: area id (Integer) must be between 0 and 4294967295.sError: area id is invalid.tpresentR~is8Error: auth_text_simple is not in the range from 1 to 8.shmac-sha256RsDError: auth_key_id and auth_text_md5 should be set at the same time.s Error: auth_key_id is not digit.i�s5Error: auth_key_id is not in the range from 1 to 255.s7Error: auth_text_md5 is not in the range from 1 to 255.sError: cost is not digit.i��s/Error: cost is not in the range from 1 to 65535s#Error: hello_interval is not digit.s9Error: hello_interval is not in the range from 1 to 65535s"Error: dead_interval is not digit.i��s<Error: dead_interval is not in the range from 1 to 235926000N(shmac-sha256shmac-sha256smd5(R*RqR'R,RFRWR:R2R3R;R8RDR@RAR1RBRCR<R=R>(RR((sY/usr/lib/python2.7/site-packages/ansible/modules/network/cloudengine/ce_interface_ospf.pytcheck_paramsasl**	


	
*
	*
	
*
	*cCs�|j|jd<|j|jd<|j�|jd<|j|jd<|j|jd<|j|jd<|j|jd<|jr�|j|jd<|jd	kr�|j	|jd
<n|jdkr�|j
|jd
<|j|jd<q�n|j|jd<dS(sget proposed infoR*R:R;R<R=R>R?R@R~RAshmac-sha256RRBRCRDN(shmac-sha256shmac-sha256smd5(
R*ROR:R`R<R=R>R?R@RARBRCRD(RR((sY/usr/lib/python2.7/site-packages/ansible/modules/network/cloudengine/ce_interface_ospf.pytget_proposed�s	cCsA|js
dS|jdr|j|jd<|jdjd�|jd<|jdjd�|jd<|jdjd�|jd<|jdjd	�|jd
<|jdjd�|jd<|jdjd
�|jd<|jdjd�|jd<|jdjd�|jd<n|jd|jd<|jd|jd<dS(sget existing infoNR*RkR<RhR=RiR>RjR?RlR@RmRARnRBRoRCRbR:ReR;(RJR*RPR�(RR((sY/usr/lib/python2.7/site-packages/ansible/modules/network/cloudengine/ce_interface_ospf.pytget_existing�s	
 cCs)|j�}|sdS|dr|j|jd<|djd�|jd<|djd�|jd<|djd�|jd<|djd	�|jd
<|djd�|jd<|djd
�|jd<|djd�|jd<|djd�|jd<n|d|jd<|d|jd<dS(sget end state infoNR*RkR<RhR=RiR>RjR?RlR@RmRARnRBRoRCRbR:ReR;(R|R*RQR�(RRRJ((sY/usr/lib/python2.7/site-packages/ansible/modules/network/cloudengine/ce_interface_ospf.pyt
get_end_state�s
cCs|j�|j�|_|j�|j�|jdkrn|jsT|jdra|j�q�|j�n#|jr�|jdr�|j�n|j	�|j
|jd<|j|jd<|j
|jd<|j|jd<|j
r�|j|jd<nt�|jd<|jj|j�dS(	tworkerR�R*RKRORPRQtupdatesN(R�R|RJR�R�RDR�R�R�R�RKRNRORPRQRMRLRFt	exit_json(RR((sY/usr/lib/python2.7/site-packages/ansible/modules/network/cloudengine/ce_interface_ospf.pytwork�s&






	(t__name__t
__module__t__doc__RTRGR[R`R|R�R�R�R�R�R�R�R�(((sY/usr/lib/python2.7/site-packages/ansible/modules/network/cloudengine/ce_interface_ospf.pyR9`s					2	7	?		H			c Csbtdtdtdd�dtdtdd�dtdtdd�dtdtdd�dtdtdd�d	tdtdd�d
tdtdtdd�d
tdtdddddddgdd�dtdtdddt�dtdtdd�dtdtdddt�dtdtdddddg��}|jt�t|�}|j�dS(sModule mainR*trequiredttypeR]R:R;R<R=R>R?tdefaulttboolR@tchoicesR}R%shmac-sha256Rshmac-md5R~RAtno_logRBRCRDR�tabsentN(RIR4R.tupdateR	R9R�(RSRF((sY/usr/lib/python2.7/site-packages/ansible/modules/network/cloudengine/ce_interface_ospf.pytmains$!
t__main__N(tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLEStRETURNt	xml.etreeRtansible.module_utils.basicRt+ansible.module_utils.network.cloudengine.ceRRR	RpR�R�R�R�R�R�R�R�R�R�R�R,R8tobjectR9R�R�(((sY/usr/lib/python2.7/site-packages/ansible/modules/network/cloudengine/ce_interface_ospf.pyt<module>s6


G/ #	2	��	

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