Anons79 Mini Shell

Directory : /proc/self/root/lib/python2.7/site-packages/ansible/plugins/netconf/
Upload File :
Current File : //proc/self/root/lib/python2.7/site-packages/ansible/plugins/netconf/ce.pyc

�
�Udac@`sDddlmZmZmZeZdZddlZddlZddl	m
Z
mZddlm
Z
ddlmZmZyVddlmZddlmZdd	lmZdd
lmZmZmZeZWneefk
r�eZnXyddl m!Z!Wn!ek
r)ddl"m!Z!nXdefd
��YZ#dS(i(tabsolute_importtdivisiontprint_functions
---
netconf: ce
short_description: Use ce netconf plugin to run netconf commands on Huawei Cloudengine platform
description:
  - This ce plugin provides low level abstraction apis for
    sending and receiving netconf commands from Huawei Cloudengine network devices.
version_added: "2.9"
options:
  ncclient_device_handler:
    type: str
    default: huawei
    description:
      - Specifies the ncclient device handler name for Huawei Cloudengine.
        To identify the ncclient device handler name refer ncclient library documentation.
N(tto_texttto_bytes(tAnsibleConnectionFailure(tNetconfBasetensure_ncclient(tmanager(tRPCError(tSSHUnknownHostError(tto_eletto_xmltnew_ele(t
fromstringtNetconfcB`seZed��Zed��Zd�Zed��Zd�Zeed���Z	d�Z
d�Zed��Zd	�Z
d
�Zed��Zed��Zed
��Zed��Zed��Zd�Zd�Zedddd��ZRS(cC`s>y&t|j|�jdd�j�SWntk
r9nXdS(Nterrorstsurrogate_then_replace(RtfindttexttstriptAttributeError(tselftelettag((s>/usr/lib/python2.7/site-packages/ansible/plugins/netconf/ce.pytget_text?s&
cC`s�t�}d|d<d}|j|�}tjdd|�}tt|dd��}|jd�}|j|d	�|d
<|j|d�|d<|j|d
�|d<|j|d�|d<|S(Ntcet
network_oss><filter type="subtree">
                          <system xmlns="http://www.huawei.com/netconf/vrp" content-version="1.0" format-version="1.0">
                            <systemInfo>
                              <sysName></sysName>
                              <sysContact></sysContact>
                              <productVer></productVer>
                              <platformVer></platformVer>
                              <productName></productName>
                            </systemInfo>
                          </system>
                        </filter>sxmlns=".+?"tRtsurrogate_or_stricts
.//systemInfot
productVertnetwork_os_versiontsysNametnetwork_os_hostnametplatformVertnetwork_os_platform_versiontproductNametnetwork_os_platform(tdicttgettretsubRRRR(Rtdevice_infot
filter_xmltdatatreplytsw_info((s>/usr/lib/python2.7/site-packages/ansible/plugins/netconf/ce.pytget_device_infoFs	
cC`s
|j|�S(sQRPC to be execute on remote device
           :name: Name of rpc in string format(trpc(Rtname((s>/usr/lib/python2.7/site-packages/ansible/plugins/netconf/ce.pytexecute_rpcascO`s�|jd�r[t|ddd�|d<|jdd�dkr[t|d�|d<q[ny|jj||�jSWn(tk
r�}tt|j	���nXdS(s)Loads given configuration on device
        :format: Format of configuration (xml, text, set)
        :action: Action to be performed (merge, replace, override, update)
        :target: is the name of the configuration datastore being edited
        :config: is the configuration in string format.tconfigRRtformattxmlN(
R'RRtmtload_configurationtdata_xmlR	t	ExceptionRR5(Rtargstkwargstexc((s>/usr/lib/python2.7/site-packages/ansible/plugins/netconf/ce.pyR7fsc
C`s�t�}|j�ddddddddd	g	|d
<d|d<|j�|d
<g|jjD]}|^q_|d<g|jjD]}|^q�|d<|jj|d<tj|�S(NR2R7tget_configurationtcompare_configurationtexecute_actionthalttreboottexecute_nc_clitdispatch_rpcR0tnetconftnetwork_apiR*tserver_capabilitiestclient_capabilitiest
session_id(	R&tget_base_rpcR/R6RFRGRHtjsontdumps(Rtresulttc((s>/usr/lib/python2.7/site-packages/ansible/plugins/netconf/ce.pytget_capabilitiesws	
##cC`s�y�tjd|jjd|jjp'dd|jjd|jjd|jd|jd�d	|jd	�d
|jj	d|jd�d
|j
�
}Wn%tk
r�}tt
|���nXd}x-|jD]"}tjd|�r�d}Pq�q�W|j�|S(Nthosttporti>tusernametpasswordtkey_filenamethostkey_verifythost_key_checkingt
look_for_keystallow_agentttimeouttpersistent_connect_timeoutt
ssh_configthuaweiR(Rtconnectt
_play_contexttremote_addrRPtremote_userRRRSt
get_optionRWt_ssh_configR
RRtNoneRFR(tsearcht
close_session(tobjR6R<t
guessed_osRM((s>/usr/lib/python2.7/site-packages/ansible/plugins/netconf/ce.pytguess_network_os�s*		
cO`s|jj||�jS(s�Retrieve all or part of a specified configuration.
           :format: format in configuration should be retrieved
           :filter: specifies the portion of the configuration to retrieve
           (by default entire configuration is retrieved)(R6R=R8(RR:R;((s>/usr/lib/python2.7/site-packages/ansible/plugins/netconf/ce.pyR=�scO`s|jj||�jS(s7Compare configuration
           :rollback: rollback id(R6R>R8(RR:R;((s>/usr/lib/python2.7/site-packages/ansible/plugins/netconf/ce.pyR>�scC`sQd}y|jjd|�}Wn(tk
rI}tt|j���nX|jS(shuawei execute-actiontactionN(RbR6RhR	R9RR5(Rtxml_strtcon_objR<((s>/usr/lib/python2.7/site-packages/ansible/plugins/netconf/ce.pyR?�scC`s|jj�jS(sreboot the device(R6R@R8(R((s>/usr/lib/python2.7/site-packages/ansible/plugins/netconf/ce.pyR@�scC`s|jj�jS(sreboot the device(R6RAR8(R((s>/usr/lib/python2.7/site-packages/ansible/plugins/netconf/ce.pyRA�scO`swyH|jdt�}|r1|jj||�jS|jj||�jSWn(tk
rr}tt|j���nXdS(Ntif_rpc_reply(	tpoptFalseR6R'R5R8R	R9R(RR:R;RkR<((s>/usr/lib/python2.7/site-packages/ansible/plugins/netconf/ce.pyR'�scO`sIy|jj||�jSWn(tk
rD}tt|j���nXdS(N(R6t
get_configR8R	R9RR5(RR:R;R<((s>/usr/lib/python2.7/site-packages/ansible/plugins/netconf/ce.pyRn�scO`sIy|jj||�jSWn(tk
rD}tt|j���nXdS(N(R6tedit_configR5R	R9R(RR:R;R<((s>/usr/lib/python2.7/site-packages/ansible/plugins/netconf/ce.pyRo�scO`sIy|jj||�jSWn(tk
rD}tt|j���nXdS(N(R6tcliR5R	R9R(RR:R;R<((s>/usr/lib/python2.7/site-packages/ansible/plugins/netconf/ce.pyRB�scO`sIy|jj||�jSWn(tk
rD}tt|j���nXdS(N(R6tcommitR8R	R9RR5(RR:R;R<((s>/usr/lib/python2.7/site-packages/ansible/plugins/netconf/ce.pyRq�scO`s|jj||�jS(N(R6tvalidateR8(RR:R;((s>/usr/lib/python2.7/site-packages/ansible/plugins/netconf/ce.pyRr�scO`s|jj||�jS(N(R6tdiscard_changesR8(RR:R;((s>/usr/lib/python2.7/site-packages/ansible/plugins/netconf/ce.pyRs�scC`sF|dkrtd��n|jjt|�d|d|�}|jS(s�
        Execute rpc on the remote device eg. dispatch('get-next')
        :param rpc_command: specifies rpc command to be dispatched either in plain text or in xml element format (depending on command)
        :param source: name of the configuration datastore being queried
        :param filter: specifies the portion of the configuration to retrieve (by default entire configuration is retrieved)
        :return: Returns xml string containing the rpc-reply response received from remote host
        s"rpc_command value must be providedtsourcetfilterN(Rbt
ValueErrorR6tdispatchRR5(Rtrpc_commandRtRutresp((s>/usr/lib/python2.7/site-packages/ansible/plugins/netconf/ce.pyRC�s	$N(t__name__t
__module__RRR/R2R7RNtstaticmethodRgR=R>R?R@RAR'RnRoRBRqRrRsRbRC(((s>/usr/lib/python2.7/site-packages/ansible/plugins/netconf/ce.pyR=s*						
		($t
__future__RRRttypet
__metaclass__t
DOCUMENTATIONRJR(tansible.module_utils._textRRtansible.errorsRtansible.plugins.netconfRRtncclientRtncclient.operationsR	tncclient.transport.errorsR
t
ncclient.xml_RRR
tTruetHAS_NCCLIENTtImportErrorRRmt
lxml.etreeRtxml.etree.ElementTreeR(((s>/usr/lib/python2.7/site-packages/ansible/plugins/netconf/ce.pyt<module>s(




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