Anons79 Mini Shell

Directory : /lib/python2.7/site-packages/ansible/module_utils/network/fortios/
Upload File :
Current File : //lib/python2.7/site-packages/ansible/module_utils/network/fortios/fortios.pyc

�
�Udac@sddlZddlZddlZddlmZddlmZddlZy0ddlm	Z	m
Z
ddlmZe
ZWnek
r�eZnXededdd	e�d
edd�de�d
ededgf�dededgfde
�deddd	d�dedd�deddd	e�dedd�dedd��
Zdedd
dggde
d
ggde
dgggZd
dgd
d
gd
dggZidd6dd6Zdefd ��YZd!�Zd"efd#��YZdS($i����N(tto_text(tenv_fallback(tFortiOStFortiConfig(tFailedCommitt	file_modettypetbooltdefaulttconfig_filetpaththosttusernametfallbacktANSIBLE_NET_USERNAMEtpasswordtANSIBLE_NET_PASSWORDtno_logttimeouttinti<tvdomtstrtbackuptbackup_pathtbackup_filenamesObject not founds-3s
Command errors-61tFortiOSHandlercBs�eZd�Zddd�Zddd�Zdd�Zdd�Zdd�Zdddd�Z	dddd�Z
dddd�Zdddd	�Zdddd
d�Z
ddddd�Zdd
�ZRS(cCs
||_dS(N(t_conn(tselftconn((sP/usr/lib/python2.7/site-packages/ansible/module_utils/network/fortios/fortios.pyt__init__TscCscd|d|}|r/|dt|�}n|r_|dkrN|d7}q_|d|7}n|S(Ns
/api/v2/cmdb/t/tglobals	?global=1s?vdom=(R(RR
tnameRtmkeyturl((sP/usr/lib/python2.7/site-packages/ansible/module_utils/network/fortios/fortios.pytcmdb_urlWs
cCscd|d|}|r/|dt|�}n|r_|dkrN|d7}q_|d|7}n|S(Ns/api/v2/monitor/RRs	?global=1s?vdom=(R(RR
R RR!R"((sP/usr/lib/python2.7/site-packages/ansible/module_utils/network/fortios/fortios.pytmon_urlcs
cCs�|dkr%|j||�d}n|j||d|�d}|jjd|�\}}|dkr�|dkr�tjt|��ddStjt|��dSntjt|��SdS(	Ns?action=schemaRs&action=schemaR"i�Ritresults(tNoneR#Rtsend_requesttjsontloadsR(RR
R RR"tstatustresult_data((sP/usr/lib/python2.7/site-packages/ansible/module_utils/network/fortios/fortios.pytschemanscCs?|j||d|�}y|d}Wntk
r:tSX|S(NRR!(R,tKeyErrortFalse(RR
R RR,tkeyname((sP/usr/lib/python2.7/site-packages/ansible/module_utils/network/fortios/fortios.pytget_mkeyname~s
cCsF|j|||�}|sdSy||}Wntk
rAdSX|S(N(R0R&R-(RR
R tdataRR/R!((sP/usr/lib/python2.7/site-packages/ansible/module_utils/network/fortios/fortios.pytget_mkey�s
c	CsU|j|||d|�}|jjd|d|dd�\}}|j|d|�S(NR!R"tparamstmethodtGETR(R#RR'tformatresponse(	RR
R RR!t
parametersR"R*R+((sP/usr/lib/python2.7/site-packages/ansible/module_utils/network/fortios/fortios.pytget�s'c	CsR|j||||�}|jjd|d|dd�\}}|j|d|�S(NR"R3R4R5R(R$RR'R6(	RR
R RR!R7R"R*R+((sP/usr/lib/python2.7/site-packages/ansible/module_utils/network/fortios/fortios.pytmonitor�s'c
	Cs�|s$|j|||d|�}n|j||||�}|jjd|d|dtj|�dd�\}}	|dks�|dks�|d	kr�|j|||||�S|j|	d|�SdS(
NRR"R3R1R4tPUTi�i�i�(R2R#RR'R(tdumpstpostR6(
RR
R R1R!RR7R"R*R+((sP/usr/lib/python2.7/site-packages/ansible/module_utils/network/fortios/fortios.pytset�s6$c	Cs�|r(|j|||�}|||<n|j|||dd�}|jjd|d|dtj|�dd�\}	}
|j|
d|�S(NR!R"R3R1R4tPOSTR(R0R#R&RR'R(R;R6(RR
R R1RR!R7tmkeynameR"R*R+((sP/usr/lib/python2.7/site-packages/ansible/module_utils/network/fortios/fortios.pyR<�s
6i,cCsj|j|||d|�}|jjd|d|dtj|�ddd|�\}	}
|j|
d|�S(	NR!R"R3R1R4R>RR(R$RR'R(R;R6(RR
R R1RR!R7RR"R*R+((sP/usr/lib/python2.7/site-packages/ansible/module_utils/network/fortios/fortios.pytexecute�s<c
	Cs�|s$|j|||d|�}n|j||||�}|jjd|d|dtj|�dd�\}}	|j|	d|�S(NRR"R3R1R4tDELETE(R2R#RR'R(R;R6(
RR
R RR!R7R1R"R*R+((sP/usr/lib/python2.7/site-packages/ansible/module_utils/network/fortios/fortios.pytdelete�s
6cCsK|dkr2tjt|��d}d|d<ntjt|��}|S(NRiR(R(R)R(RtresRtresp((sP/usr/lib/python2.7/site-packages/ansible/module_utils/network/fortios/fortios.pyR6�s

N(t__name__t
__module__RR&R#R$R,R0R2R8R9R=R<R@RBR6(((sP/usr/lib/python2.7/site-packages/ansible/module_utils/network/fortios/fortios.pyRRs	
cCs|jd}|jd}tjj|�smytj|�Wqmtk
ri|jddj|��qmXntj	dtj
tj���}dt|�kr�d||f}nd||jd	|f}yt|d
�j
|�Wn*tk
r|jddj|��nXdS(NRRtmsgs.Can't create directory {0} Permission denied ?s%Y-%m-%d@%H:%M:%Sis%s/%ss%s/%s_config.%sRtws0Can't create backup file {0} Permission denied ?(R3tosR
texiststmkdirt	Exceptiont	fail_jsontformatttimetstrftimet	localtimetlentopentwrite(tmoduletrunning_configRRttstamptfilename((sP/usr/lib/python2.7/site-packages/ansible/module_utils/network/fortios/fortios.pyR�s


 !
tAnsibleFortioscBsPeZd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z	RS(cCs6ts|jdd�nitd6|_||_dS(NRGs@Could not import the python library pyFG required by this moduletchanged(tHAS_PYFGRMR.tresultRU(RRU((sP/usr/lib/python2.7/site-packages/ansible/module_utils/network/fortios/fortios.pyR�s

c
Cs�|jjdr"td�|_n�|jjd}|jjd}|jjd}|jjd}|jjd}t|d|d|d|d|�|_y|jj�Wn<tk
r�}|jjdd	t|�d
tj	��nXdS(NRtRRRRRRGsError connecting device. %st	exception(
RUR3Rtforti_deviceRSRLRMRt	tracebackt
format_exc(RRRRRRte((sP/usr/lib/python2.7/site-packages/ansible/module_utils/network/fortios/fortios.pyt_connect�s'cCso||_|j�|jjdr�y3t|jjdd�}|j�}|j�Wn<tk
r�}|jjddt	|�dt
j��nX|jj
d|d|�ncy|jj
d|�WnItk
r}|jj�|jjdd	t	|�dt
j��nX|jjj	�|jd
<|jj|_|jjdrkt|j|jjj	��ndS(NRR	trRGs$Error reading configuration file. %sR^tconfig_textR
s Error reading running config. %sRVR(R
RcRUR3RStreadtclosetIOErrorRMRR`RaR_tload_configRLRVR\tcandidate_configR(RR
tftrunningRb((sP/usr/lib/python2.7/site-packages/ansible/module_utils/network/fortios/fortios.pyRis*	

cCs^|jj�}|r2||jd<t|jd<n|rG|jjrG|jjdr�y=t|jjdd�}|j|j	j
��|j�WqDtk
r�}|jj
ddt
|�dtj��qDXqGy|jj�WnOtk
r6}|jj�|j|�}|jj
d	|dd
|j�nX|jj�n|jj|j�dS(Nt
change_stringRZRR	RHRGs$Error writing configuration file. %sR^tmsg_error_lists:Unable to commit change, check your args, the error was %s(R_tcompare_configR\tTrueRUt
check_modeR3RSRTRjRRgRhRMR`RatcommitRtget_error_infostmessaget	exit_json(RRmRkRbt
error_list((sP/usr/lib/python2.7/site-packages/ansible/module_utils/network/fortios/fortios.pyt
apply_changes"s*
!
$cCs|jj|jj|�dS(N(R_RjR
t	del_block(Rtblock_id((sP/usr/lib/python2.7/site-packages/ansible/module_utils/network/fortios/fortios.pyRx>scCs||jj|j|<dS(N(R_RjR
(RRytblock((sP/usr/lib/python2.7/site-packages/ansible/module_utils/network/fortios/fortios.pyt	add_blockAsc
Cswg}xj|jD]_}xV|D]N}|d}|d}tj|d�}|jtd|d|d|��qWqW|S(Niitunknownt
error_codet
error_typeterror_string(targstfortios_error_codesR8tappendtdict(Rt
cli_errorsRvterrorsterrorR}RR~((sP/usr/lib/python2.7/site-packages/ansible/module_utils/network/fortios/fortios.pyRsDs


*cCs
t||�S(N(R(Rt
block_namet
block_type((sP/usr/lib/python2.7/site-packages/ansible/module_utils/network/fortios/fortios.pytget_empty_configuration_blockOs(
RERFRRcRiRwRxR{RsR�(((sP/usr/lib/python2.7/site-packages/ansible/module_utils/network/fortios/fortios.pyRY�s								(RIROR`tansible.module_utils._textRtansible.module_utils.basicRR(tpyFGRRtpyFG.exceptionsRRpR[tImportErrorR.R�tfortios_argument_spectfortios_required_iftfortios_mutually_exclusiveR�tobjectRRRY(((sP/usr/lib/python2.7/site-packages/ansible/module_utils/network/fortios/fortios.pyt<module>sD


			
�	

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