Anons79 Mini Shell

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

�
�Udac@s�ddlmZddlmZddlmZddlmZyddlmZeZWne	k
rse
ZnXdefd��YZdefd	��YZ
d
efd��YZdS(
i����(tFMGR_RC(tFMGBaseException(t
FMGRCommon(t
scrub_dict(tFortiManagertFortiManagerHandlerc
Bs}eZd�Zd�Zdddddddddddd�Zeddeeeeeeeed	d��Z	d�Z
RS(
cCs||_||_t|_dS(N(t_connt_moduleRt_tools(tselftconntmodule((sZ/usr/lib/python2.7/site-packages/ansible/module_utils/network/fortimanager/fortimanager.pyt__init__8s		cCs1|jj|||�}|jj||�}|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
        (Rtformat_requestRtsend_request(R	turltdatagramtmethodtdatatresponse((sZ/usr/lib/python2.7/site-packages/ansible/module_utils/network/fortimanager/fortimanager.pytprocess_request=scCs�|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 FortiManager 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 FortiManager
        :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]tfmgr_return_codest
good_codeststop_on_failtstop_on_successtskippedtchangedtunreachabletfailedtsuccesstchanged_if_successtresultstmsgt
ansible_factsRtNULLN(i(	tNoneRt
BaseExceptionRtgettreturn_responsetTruetFalsetdict(R	RRR RRRRRRRRRR!trctrc_datatrc_codes((sZ/usr/lib/python2.7/site-packages/ansible/module_utils/network/fortimanager/fortimanager.pytgovern_responseVsh$

	












R"ic

Cs�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�|jd|d|	d
|d|d|d
|dd|d|ddi|dd6�	q�q�|
r�|r�t}t}
n|r�|jd|d|
d
|d|d|d
|dd|d|ddi|dd6�	q�q�n|S(sE
        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 FortiManager
        :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 FailureRR"itstatustmessagesrNo status message returned at results[1][status][message], and none supplied to msg parameter for handle_response.RRRRR!R*t
invocationtansible_paramstmodule_argsR(tlent	exit_jsonR'R$R((
RRR RRRRRRRRRR!((sZ/usr/lib/python2.7/site-packages/ansible/module_utils/network/fortimanager/fortimanager.pyR&�sB**
	

		'	! cOsdi|d6t|�d6t|�d6|jj�d6}|rJ||d<n|r`|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 FortiManager.
        :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
        RR1t	paramgramtconnected_fmgrtcustom_args(RRtreturn_connected_fmgrtupdate(R	RR1R5targstkwargstfacts((sZ/usr/lib/python2.7/site-packages/ansible/module_utils/network/fortimanager/fortimanager.pytconstruct_ansible_factss


N(i((t__name__t
__module__RRR#R-tstaticmethodR'R(R&R=(((sZ/usr/lib/python2.7/site-packages/ansible/module_utils/network/fortimanager/fortimanager.pyR7s			`	RtFMGLockContextcBs�eZdZd�Zed��Zejd��Zed��Zejd��Zd�Zd�Z	d�Z
d	�Zd
d
�Z
d
d�Zd
ed�ZRS(s�
    - DEPRECATING: USING CONNECTION MANAGER NOW INSTEAD. EVENTUALLY THIS CLASS WILL DISAPPEAR. PLEASE
    - CONVERT ALL MODULES TO CONNECTION MANAGER METHOD.
    - LEGACY pyFMG HANDLER OBJECT: REQUIRES A CHECK FOR PY FMG AT TOP OF PAGE
    cCs+||_t�|_t|_t|_dS(N(t_fmgtlistt_locked_adom_listR(t_uses_workspacet_uses_adoms(R	tfmg((sZ/usr/lib/python2.7/site-packages/ansible/module_utils/network/fortimanager/fortimanager.pyR?s		cCs|jS(N(RE(R	((sZ/usr/lib/python2.7/site-packages/ansible/module_utils/network/fortimanager/fortimanager.pytuses_workspaceEscCs
||_dS(N(RE(R	tval((sZ/usr/lib/python2.7/site-packages/ansible/module_utils/network/fortimanager/fortimanager.pyRHIscCs|jS(N(RF(R	((sZ/usr/lib/python2.7/site-packages/ansible/module_utils/network/fortimanager/fortimanager.pyt
uses_adomsMscCs
||_dS(N(RF(R	RI((sZ/usr/lib/python2.7/site-packages/ansible/module_utils/network/fortimanager/fortimanager.pyRJQscCs&||jkr"|jj|�ndS(N(RDtappend(R	tadom((sZ/usr/lib/python2.7/site-packages/ansible/module_utils/network/fortimanager/fortimanager.pytadd_adom_to_lock_listUscCs&||jkr"|jj|�ndS(N(RDtremove(R	RL((sZ/usr/lib/python2.7/site-packages/ansible/module_utils/network/fortimanager/fortimanager.pytremove_adom_from_lock_listYscCs�d}|jj|dddg�\}}y |ddkrIt|_nWntk
rft|_nXy |ddkr�t|_nWntk
r�t|_nXdS(Ns/cli/global/system/globaltfieldssworkspace-modesadom-statusii(RBR%R'RHtKeyErrorR(RJ(R	Rtcodetresp_obj((sZ/usr/lib/python2.7/site-packages/ansible/module_utils/network/fortimanager/fortimanager.pyt
check_mode]s$


cCs%x|jD]}|j|�q
WdS(N(RDtunlock_adom(R	tadom_locked((sZ/usr/lib/python2.7/site-packages/ansible/module_utils/network/fortimanager/fortimanager.pyt
run_unlockkscOs�|r6|j�dkr!d}q<djd|�}nd}|jj|i||�\}}|dkr�|ddj�d	kr�|j|�n||fS(
Ntglobals/dvmdb/global/workspace/lock/s"/dvmdb/adom/{adom}/workspace/lock/RLs/dvmdb/adom/root/workspace/lockiR.R/tok(tlowertformatRBtexecuteRM(R	RLR:R;RRRtrespobj((sZ/usr/lib/python2.7/site-packages/ansible/module_utils/network/fortimanager/fortimanager.pyt	lock_adomos	!&cOs�|r6|j�dkr!d}q<djd|�}nd}|jj|i||�\}}|dkr�|ddj�d	kr�|j|�n||fS(
NRXs/dvmdb/global/workspace/unlock/s$/dvmdb/adom/{adom}/workspace/unlock/RLs!/dvmdb/adom/root/workspace/unlockiR.R/RY(RZR[RBR\RO(R	RLR:R;RRRR]((sZ/usr/lib/python2.7/site-packages/ansible/module_utils/network/fortimanager/fortimanager.pyRU|s	!&cOsp|rQ|r!djd|�}qW|j�dkr<d}qWdjd|�}nd}|jj|i||�S(Ns'/pm/config/adom/{adom}/workspace/commitRLRXs/dvmdb/global/workspace/commit/s#/dvmdb/adom/{adom}/workspace/commits!/dvmdb/adom/root/workspace/commit(R[RZRBR\(R	RLtauxR:R;R((sZ/usr/lib/python2.7/site-packages/ansible/module_utils/network/fortimanager/fortimanager.pytcommit_changes�s	N(R>R?t__doc__RtpropertyRHtsetterRJRMRORTRWR#R^RUR(R`(((sZ/usr/lib/python2.7/site-packages/ansible/module_utils/network/fortimanager/fortimanager.pyRA9s					

tAnsibleFortiManagercBs�eZdZd
d
d
eedd�Zd�Zd�Zd�Z	d�Z
d�Zd�Zd	�Z
d
�Zd�Zd�ZRS(s�
    - DEPRECATING: USING CONNECTION MANAGER NOW INSTEAD. EVENTUALLY THIS CLASS WILL DISAPPEAR. PLEASE
    - CONVERT ALL MODULES TO CONNECTION MANAGER METHOD.
    - LEGACY pyFMG HANDLER OBJECT: REQUIRES A CHECK FOR PY FMG AT TOP OF PAGE
    i,cCse||_||_||_||_||_||_d|_tsX|j	dd�n||_
dS(NR sACould not import the python library pyFMG required by this module(tiptusernametpasswdtuse_sslt
verify_sslttimeoutR#t
fmgr_instancet
HAS_PYFMGRt	fail_jsonR(R	RReRfRgRhRiRj((sZ/usr/lib/python2.7/site-packages/ansible/module_utils/network/fortimanager/fortimanager.pyR�s							cCse|jdk	rat|j|j|jd|jd|jd|jdtdt	�|_
|j
j�SdS(NRhRiRjtdebugtdisable_request_warnings(ReR#RRfRgRhRiRjR(R'Rktlogin(R	((sZ/usr/lib/python2.7/site-packages/ansible/module_utils/network/fortimanager/fortimanager.pyRp�s
!cCs&|jjdk	r"|jj�ndS(N(RktsidR#tlogout(R	((sZ/usr/lib/python2.7/site-packages/ansible/module_utils/network/fortimanager/fortimanager.pyRr�scCs|jj||�S(N(RkR%(R	RR((sZ/usr/lib/python2.7/site-packages/ansible/module_utils/network/fortimanager/fortimanager.pyR%�scCs|jj||�S(N(Rktset(R	RR((sZ/usr/lib/python2.7/site-packages/ansible/module_utils/network/fortimanager/fortimanager.pyRs�scCs|jj||�S(N(RkR9(R	RR((sZ/usr/lib/python2.7/site-packages/ansible/module_utils/network/fortimanager/fortimanager.pyR9�scCs|jj||�S(N(Rktdelete(R	RR((sZ/usr/lib/python2.7/site-packages/ansible/module_utils/network/fortimanager/fortimanager.pyRt�scCs|jj||�S(N(Rktadd(R	RR((sZ/usr/lib/python2.7/site-packages/ansible/module_utils/network/fortimanager/fortimanager.pyRu�scCs|jj||�S(N(RkR\(R	RR((sZ/usr/lib/python2.7/site-packages/ansible/module_utils/network/fortimanager/fortimanager.pyR\�scCs|jj||�S(N(Rktmove(R	RR((sZ/usr/lib/python2.7/site-packages/ansible/module_utils/network/fortimanager/fortimanager.pyRv�scCs|jj||�S(N(Rktclone(R	RR((sZ/usr/lib/python2.7/site-packages/ansible/module_utils/network/fortimanager/fortimanager.pyRw�sN(R>R?RaR#R'R(RRpRrR%RsR9RtRuR\RvRw(((sZ/usr/lib/python2.7/site-packages/ansible/module_utils/network/fortimanager/fortimanager.pyRd�s									N(t0ansible.module_utils.network.fortimanager.commonRRRRtpyFMG.fortimgrRR'RltImportErrorR(tobjectRRARd(((sZ/usr/lib/python2.7/site-packages/ansible/module_utils/network/fortimanager/fortimanager.pyt<module>s


�_

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