Anons79 Mini Shell

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

�
�Udac@`s�ddlmZmZmZeZddlmZddlmZddlm	Z	ddlm
Z
ddlmZdefd��YZ
d	S(
i(tabsolute_importtdivisiontprint_function(tFAZ_RC(tFAZBaseException(t	FAZCommon(t
scrub_dict(t
FAZMethodstFortiAnalyzerHandlercB`seZd�Zd�Zd�Zd�Zdd�Zdd�Zdd�Z	de
d�Zdddddddddddd�Zd	de
e
e
e
e
e
e
e
dd�Zed��Zed
��Zejd��Zed��Zejd��Zd�Zd�ZRS(cC`sv||_||_t|_d|_d|_t�|_d|_	|j
�|jrr|jd|jjd�ndS(Ntadom(
t_connt_moduleRt_toolstNonet_uses_workspacet_uses_adomstlistt_locked_adom_listt
_lock_infotworkspace_checkt
get_lock_infot	paramgram(tselftconntmodule((s\/usr/lib/python2.7/site-packages/ansible/module_utils/network/fortianalyzer/fortianalyzer.pyt__init__8s						
	cC`s!yN|jjd}|jrM||jkrM|tjkrM|jd|�nWntk
ro}t|��nX|j	j
|||�}|jj||�}y^|jjd}|jr�||jkr�|ddkr�|tjkr�|j
d|�nWntk
r}t|��nX|S(s	
        Formats and Runs the API Request via Connection Plugin. Streamlined for use from Modules.

        :param url: Connection URL to access
        :type url: string
        :param datagram: The prepared payload for the API Request in dictionary format
        :type datagram: dict
        :param method: The preferred API Request method (GET, ADD, POST, etc....)
        :type method: basestring

        :return: Dictionary containing results of the API Request via Connection Plugin.
        :rtype: dict
        R	i(RRtuses_workspaceRRtGETt	lock_adomt
BaseExceptionRRtformat_requestR
tsend_requesttcommit_changes(RturltdatagramtmethodR	terrtdatatresponse((s\/usr/lib/python2.7/site-packages/ansible/module_utils/network/fortianalyzer/fortianalyzer.pytprocess_requestEs 'cC`s6d}iddgd6}|j||tj�}yD|dddkrTt|_n |dddkrtt|_nWnEtk
r�t|_n,tk
r�}td	d
t	|���nXy-|dddkr�t|_
n	t|_
WnEtk
rt|_
n,tk
r1}td	dt	|���nXd
S(sC
       Checks FortiAnalyzer for the use of Workspace mode.
       s/cli/global/system/globalsworkspace-modesadom-statustfieldsitworkflowtnormaltdisabledtmsgs8Couldn't determine workspace-mode in the plugin. Error: tenables5Couldn't determine adom-status in the plugin. Error: N(R)R*(iR-(R'RRtTrueRtFalsetKeyErrorRRtstrt
uses_adoms(RR!R%tresp_objR$((s\/usr/lib/python2.7/site-packages/ansible/module_utils/network/fortianalyzer/fortianalyzer.pyRms(


cC`s%x|jD]}|j|�q
WdS(sC
        Checks for ADOM status, if locked, it will unlock
        N(Rtunlock_adom(Rtadom_locked((s\/usr/lib/python2.7/site-packages/ansible/module_utils/network/fortianalyzer/fortianalyzer.pyt
run_unlock�scC`s|s|dkrd}n-|j�dkr7d}ndjd|�}i}|jjtj||�}|jjtj|�}|d}|dkr�|dd	d
j�dkr�|j|�n=|j	d|�}|j
jdd
t|�dt|��|S(s+
        Locks an ADOM for changes
        troots/dvmdb/adom/root/workspace/locktglobals/dvmdb/global/workspace/lock/s"/dvmdb/adom/{adom}/workspace/lock/R	iitstatustmessagetokR,s2An error occurred trying to lock the adom. Error: s
, LOCK INFO: (
tlowertformatRRRtEXECR
Rtadd_adom_to_lock_listRRt	fail_jsonR1(RR	R!R"R%R3tcodetlockinfo((s\/usr/lib/python2.7/site-packages/ansible/module_utils/network/fortianalyzer/fortianalyzer.pyR�s		
*cC`s�|s|dkrd}n-|j�dkr7d}ndjd|�}i}|jjtj||�}|jjtj|�}|d}|dkr�|dd	d
j�dkr�|j|�n|j	j
dd
t|��|S(s/
        Unlocks an ADOM after changes
        R7s!/dvmdb/adom/root/workspace/unlockR8s/dvmdb/global/workspace/unlock/s$/dvmdb/adom/{adom}/workspace/unlock/R	iiR9R:R;R,s4An error occurred trying to unlock the adom. Error: (R<R=RRRR>R
Rtremove_adom_from_lock_listRR@R1(RR	R!R"R%R3RA((s\/usr/lib/python2.7/site-packages/ansible/module_utils/network/fortianalyzer/fortianalyzer.pyR4�s		
*cC`s�|s|dkrd}n-|j�dkr7d}ndjd|�}i}|jjtj||�}|jjtj|�}|d}|dkr�|jj	dd	t
|��n|dkr�|d
|_n|S(s�
        Gets ADOM lock info so it can be displayed with the error messages. Or if determined to be locked by ansible
        for some reason, then unlock it.
        R7s#/dvmdb/adom/root/workspace/lockinfoR8s!/dvmdb/global/workspace/lockinfo/s&/dvmdb/adom/{adom}/workspace/lockinfo/R	iR,s;An error occurred trying to get the ADOM Lock Info. Error: i(R<R=RRRRR
RRR@R1R(RR	R!R"R%R3RA((s\/usr/lib/python2.7/site-packages/ansible/module_utils/network/fortianalyzer/fortianalyzer.pyR�s		
 cC`s�|s|dkrd}nH|r7djd|�}n-|j�dkrRd}ndjd|�}i}|jjtj||�}|jjtj|�}|d}|dkr�|jj	d	d
t
|��ndS(s,
        Commits changes to an ADOM
        R7s!/dvmdb/adom/root/workspace/commits'/pm/config/adom/{adom}/workspace/commitR	R8s/dvmdb/global/workspace/commit/s#/dvmdb/adom/{adom}/workspace/commitiR,s?An error occurred trying to commit changes to the adom. Error: N(R=R<RRRR>R
RRR@R1(RR	tauxR!R"R%R3RA((s\/usr/lib/python2.7/site-packages/ansible/module_utils/network/fortianalyzer/fortianalyzer.pyR �s		
cC`s�|dkr'|dkr'td��ny|d}Wntk
rTtd��nXd}y"tjd�}|j|�}Wntk
r�nX|s�i}n|dk	r�||d<n|dk	r�||d<n|dk	r�||d<n|dk	r||d<n|dk	r||d	<n|	dk	r6|	|d
<n|
dk	rO|
|d<n|dk	rh||d<n|dk	r�||d
<n|dk	r�||d<n|dk	r�||d<n|
dkr�i|d<n
|
|d<|jd|d|d|jdd�d|jdd�d|jdt�d|jdt�d|jdt�d	|jd	t�d
|jd
t�d
|jd
t�d|jdt�d|jdt�d|jdt���
S(s�
        This function will attempt to apply default values to canned responses from FortiAnalyzer we know of.
        This saves time, and turns the response in the module into a "one-liner", while still giving us...
        the flexibility to directly use return_response in modules if we have too. This function saves repeated code.

        :param module: The Ansible Module CLASS object, used to run fail/exit json
        :type module: object
        :param msg: An overridable custom message from the module that called this.
        :type msg: string
        :param results: A dictionary object containing an API call results
        :type results: dict
        :param good_codes: A list of exit codes considered successful from FortiAnalyzer
        :type good_codes: list
        :param stop_on_fail: If true, stops playbook run when return code is NOT IN good codes (default: true)
        :type stop_on_fail: boolean
        :param stop_on_success: If true, stops playbook run when return code is IN good codes (default: false)
        :type stop_on_success: boolean
        :param changed: If True, tells Ansible that object was changed (default: false)
        :type skipped: boolean
        :param skipped: If True, tells Ansible that object was skipped (default: false)
        :type skipped: boolean
        :param unreachable: If True, tells Ansible that object was unreachable (default: false)
        :type unreachable: boolean
        :param failed: If True, tells Ansible that execution was a failure. Overrides good_codes. (default: false)
        :type unreachable: boolean
        :param success: If True, tells Ansible that execution was a success. Overrides good_codes. (default: false)
        :type unreachable: boolean
        :param changed_if_success: If True, defaults to changed if successful if you specify or not"
        :type changed_if_success: boolean
        :param ansible_facts: A prepared dictionary of ansible facts from the execution.
        :type ansible_facts: dict
        sHgovern_response() was called without a module and/or results tuple! Fix!isBgovern_response() was called without the return code at results[0]tfaz_return_codest
good_codeststop_on_failtstop_on_successtskippedtchangedtunreachabletfailedtsuccesstchanged_if_successtresultsR,t
ansible_factsRtNULLN(i(	R
RRRtgettreturn_responseR.R/tdict(RRROR,RFRGRHRIRJRKRLRMRNRPtrctrc_datatrc_codes((s\/usr/lib/python2.7/site-packages/ansible/module_utils/network/fortianalyzer/fortianalyzer.pytgovern_response�sh$

	












RQicC`s�t|�dks*|
r|s*|rC|	rC|jdddt�n|
r�|r�t|�dkr�|d|kr|t}
q�|d|kr�t}q�q�nt|�dkr�|dkr�y|ddd}Wq�tk
r�d	}q�Xn|
r�|
r|rt}
n|
r|	rt}
n|r�|jrky|j�Wqktk
rg}tdd
t|���qkXn|jd|d|
d|d|	d
|d|dd|
d|ddi|
dd6�	q�q�|r�|r�t}t}n|r�|jr.y|j�Wq.tk
r*}tdd
t|���q.Xn|jd|d|d|d|	d
|d|dd|
d|ddi|
dd6�	q�q�n|S(sF
        This function controls the logout and error reporting after an method or function runs. The exit_json for
        ansible comes from logic within this function. If this function returns just the msg, it means to continue
        execution on the playbook. It is called from the ansible module, or from the self.govern_response function.

        :param module: The Ansible Module CLASS object, used to run fail/exit json
        :type module: object
        :param msg: An overridable custom message from the module that called this.
        :type msg: string
        :param results: A dictionary object containing an API call results
        :type results: dict
        :param good_codes: A list of exit codes considered successful from FortiAnalyzer
        :type good_codes: list
        :param stop_on_fail: If true, stops playbook run when return code is NOT IN good codes (default: true)
        :type stop_on_fail: boolean
        :param stop_on_success: If true, stops playbook run when return code is IN good codes (default: false)
        :type stop_on_success: boolean
        :param changed: If True, tells Ansible that object was changed (default: false)
        :type skipped: boolean
        :param skipped: If True, tells Ansible that object was skipped (default: false)
        :type skipped: boolean
        :param unreachable: If True, tells Ansible that object was unreachable (default: false)
        :type unreachable: boolean
        :param failed: If True, tells Ansible that execution was a failure. Overrides good_codes. (default: false)
        :type unreachable: boolean
        :param success: If True, tells Ansible that execution was a success. Overrides good_codes. (default: false)
        :type unreachable: boolean
        :param changed_if_success: If True, defaults to changed if successful if you specify or not"
        :type changed_if_success: boolean
        :param ansible_facts: A prepared dictionary of ansible facts from the execution.
        :type ansible_facts: dict

        :return: A string object that contains an error message
        :rtype: str
        iR,s�Handle_response was called with no results, or conflicting failed/success or changed/unreachable parameters. Fix the exit code on module. Generic FailureRLRQiR9R:srNo status message returned at results[1][status][message], and none supplied to msg parameter for handle_response.sCouldn't unlock ADOM! Error: RJRKRIRORPRUt
invocationtansible_paramstmodule_argsRM(	tlent	exit_jsonR.RR/RR6RR1(RRROR,RFRGRHRIRJRKRLRMRNRPR$((s\/usr/lib/python2.7/site-packages/ansible/module_utils/network/fortianalyzer/fortianalyzer.pyRSIsV)*
	

			 '		 ! cO`sTi|d6t|�d6t|�d6}|r:||d<n|rP|j|�n|S(s�
        Constructs a dictionary to return to ansible facts, containing various information about the execution.

        :param response: Contains the response from the FortiAnalyzer.
        :type response: dict
        :param ansible_params: Contains the parameters Ansible was called with.
        :type ansible_params: dict
        :param paramgram: Contains the paramgram passed to the modules' local modify function.
        :type paramgram: dict
        :param args: Free-form arguments that could be added.
        :param kwargs: Free-form keyword arguments that could be added.

        :return: A dictionary containing lots of information to append to Ansible Facts.
        :rtype: dict
        R&RZRtcustom_args(Rtupdate(R&RZRtargstkwargstfacts((s\/usr/lib/python2.7/site-packages/ansible/module_utils/network/fortianalyzer/fortianalyzer.pytconstruct_ansible_facts�s

cC`s|jS(N(R(R((s\/usr/lib/python2.7/site-packages/ansible/module_utils/network/fortianalyzer/fortianalyzer.pyR�scC`s
||_dS(N(R(Rtval((s\/usr/lib/python2.7/site-packages/ansible/module_utils/network/fortianalyzer/fortianalyzer.pyR�scC`s|jS(N(R(R((s\/usr/lib/python2.7/site-packages/ansible/module_utils/network/fortianalyzer/fortianalyzer.pyR2�scC`s
||_dS(N(R(RRd((s\/usr/lib/python2.7/site-packages/ansible/module_utils/network/fortianalyzer/fortianalyzer.pyR2�scC`s&||jkr"|jj|�ndS(N(Rtappend(RR	((s\/usr/lib/python2.7/site-packages/ansible/module_utils/network/fortianalyzer/fortianalyzer.pyR?�scC`s&||jkr"|jj|�ndS(N(Rtremove(RR	((s\/usr/lib/python2.7/site-packages/ansible/module_utils/network/fortianalyzer/fortianalyzer.pyRC�sN(i((t__name__t
__module__RR'RR6R
RR4RR/R RXR.RStstaticmethodRctpropertyRtsetterR2R?RC(((s\/usr/lib/python2.7/site-packages/ansible/module_utils/network/fortianalyzer/fortianalyzer.pyR7s.	
	(			`	\	N(t
__future__RRRttypet
__metaclass__t1ansible.module_utils.network.fortianalyzer.commonRRRRRtobjectR(((s\/usr/lib/python2.7/site-packages/ansible/module_utils/network/fortianalyzer/fortianalyzer.pyt<module>s

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