Anons79 Mini Shell

Directory : /lib/python2.7/site-packages/ansible/modules/storage/netapp/
Upload File :
Current File : //lib/python2.7/site-packages/ansible/modules/storage/netapp/na_ontap_vscan_on_access_policy.pyc

�
�Udac@`s�ddlmZmZmZeZidd6dgd6dd6ZdZd	Zd
Z	ddl
Z
ddlmZdd
l
mZddljjZej�Zdefd��YZd�Zedkr�e�ndS(i(tabsolute_importtdivisiontprint_functions1.1tmetadata_versiontpreviewtstatust	certifiedtsupported_bys�
module: na_ontap_vscan_on_access_policy
short_description: NetApp ONTAP Vscan on access policy configuration.
extends_documentation_fragment:
    - netapp.na_ontap
version_added: '2.8'
author: NetApp Ansible Team (@carchi8py) <[email protected]>
description:
- Configure on access policy for Vscan (virus scan)
options:
  state:
    description:
    - Whether a Vscan on Access policy is present or not
    choices: ['present', 'absent']
    default: present

  vserver:
    description:
    - the name of the data vserver to use.
    required: true

  policy_name:
    description:
    - The name of the policy
    required: true

  file_ext_to_exclude:
    description:
    - File extensions for which On-Access scanning must not be performed.

  file_ext_to_include:
    description:
    - File extensions for which On-Access scanning is considered. The default value is '*', which means that all files are considered for scanning except
    - those which are excluded from scanning.

  filters:
    description:
    - A list of filters which can be used to define the scope of the On-Access policy more precisely. The filters can be added in any order. Possible values
    - scan_ro_volume  Enable scans for read-only volume,
    - scan_execute_access  Scan only files opened with execute-access (CIFS only)

  is_scan_mandatory:
    description:
    - Specifies whether access to a file is allowed if there are no external virus-scanning servers available for virus scanning. It is true if not provided at
     the time of creating a policy.
    type: bool

  max_file_size:
    description:
    - Max file-size (in bytes) allowed for scanning. The default value of 2147483648 (2GB) is taken if not provided at the time of creating a policy.

  paths_to_exclude:
    description:
    - File paths for which On-Access scanning must not be performed.

  scan_files_with_no_ext:
    description:
    - Specifies whether files without any extension are considered for scanning or not.
    default: True
s�
    - name: Create Vscan On Access Policy
      na_ontap_vscan_on_access_policy:
        state: present
        username: '{{ netapp_username }}'
        password: '{{ netapp_password }}'
        hostname: '{{ netapp_hostname }}'
        vserver: carchi-vsim2
        policy_name: carchi_policy
        file_ext_to_exclude: ['exe', 'yml']
    - name: modify Vscan on Access Policy
      na_ontap_vscan_on_access_policy:
        state: present
        username: '{{ netapp_username }}'
        password: '{{ netapp_password }}'
        hostname: '{{ netapp_hostname }}'
        vserver: carchi-vsim2
        policy_name: carchi_policy
        file_ext_to_exclude: ['exe', 'yml', 'py']
    - name: Delete On Access Policy
      na_ontap_vscan_on_access_policy:
        state: absent
        username: '{{ netapp_username }}'
        password: '{{ netapp_password }}'
        hostname: '{{ netapp_hostname }}'
        vserver: carchi-vsim2
        policy_name: carchi_policy
s

N(t
AnsibleModule(t	to_nativetNetAppOntapVscanOnAccessPolicycB`skeZdZd�Zdd�Zd�Zd�Zd�Zd�Z	d�Z
d�Zd	�Zd
�Z
RS(s6
    Create/Modify/Delete a Vscan OnAccess policy
    cC`s�tj�|_|jjtdtdddgdd�dtdtdd	�d
tdtdd	�dtdtdd�d
tdtdd�dtdtdd�dtdtdddt�dtdtdd�dtdtdd�dtdtdtdt��
�td|jdt�|_	|j	j
}|d|_|d|_|d
|_
|d|_|d
|_|d|_|d|_|d|_|d|_|d|_ttkr�|j	jdd�n!tjd|j	d|j�|_dS(Ntstatetchoicestpresenttabsenttdefaulttvservertrequiredttypetstrtpolicy_nametfile_ext_to_excludetlisttfile_ext_to_includetfilterstis_scan_mandatorytboolt
max_file_sizetinttpaths_to_excludetscan_files_with_no_extt
argument_spectsupports_check_modetmsgs(the python NetApp-Lib module is requiredtmodule(tnetapp_utilstna_ontap_host_argument_specRtupdatetdicttTruetFalseRRR"tparamsRRRRRRRRRRtHAS_NETAPP_LIBt	fail_jsontsetup_na_ontap_zapitserver(tselft
parameters((sb/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_ontap_vscan_on_access_policy.pyt__init__ys:	









cC`s-|dkr|j�}n|r%tStSdS(sl
        Check if a Vscan Access policy exists
        :return: True if Exist, False if it does not
        N(tNonetreturn_on_access_policyR'R((R.t
policy_obj((sb/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_ontap_vscan_on_access_policy.pytexists_access_policy�s
cC`s7tjjd�}tjjd�}|jd|j�tjjd�}|j|�|j|�y|jj|t�}WnKtjj	k
r�}|j
jdd|jt|�fdt
j��nX|jd�r3t|jd��d	kr�|St|jd��d	kr3|j
jdd
|j�q3ndS(s�
        Return a Vscan on Access Policy
        :return: None if there is no access policy, return the policy if there is
        svscan-on-access-policy-get-itersvscan-on-access-policy-infospolicy-nametqueryR!s-Error searching Vscan on Access Policy %s: %st	exceptionsnum-recordsis+Mutiple Vscan on Access Policy matching %s:N(R#tzapit	NaElementt
add_new_childRtadd_child_elemR-tinvoke_successfullyR't
NaApiErrorR"R+R	t	tracebackt
format_exctget_child_by_nameRtget_child_contentR1(R.taccess_policy_objtaccess_policy_infoR5tresultterror((sb/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_ontap_vscan_on_access_policy.pyR2�s"

' cC`s�tjjd�}|jd|j�|jdd�|j|�}y|jj|t�WnKtjj	k
r�}|j
jdd|jt|�fdt
j��nXdS(	sG
        Create a Vscan on Access policy
        :return: none
        svscan-on-access-policy-createspolicy-nametprotocoltcifsR!s,Error creating Vscan on Access Policy %s: %sR6N(R#R7R8R9Rt_fill_in_access_policyR-R;R'R<R"R+R	R=R>(R.RARD((sb/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_ontap_vscan_on_access_policy.pytcreate_on_access_policy�scC`s�tjjd�}|jd|j�y|jj|t�WnKtjjk
r�}|j	j
dd|jt|�fdtj
��nXdS(sB
        Delete a Vscan On Access Policy
        :return:
        svscan-on-access-policy-deletespolicy-nameR!s,Error Deleting Vscan on Access Policy %s: %sR6N(R#R7R8R9RR-R;R'R<R"R+R	R=R>(R.RARD((sb/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_ontap_vscan_on_access_policy.pytdelete_on_access_policy�scC`s�tjjd�}|jd|j�|j|�}y|jj|t�WnKtjj	k
r�}|j
jdd|jt|�fdt
j��nXdS(sJ
        Modify a Vscan On Access policy
        :return: nothing
        svscan-on-access-policy-modifyspolicy-nameR!s-Error Modifying Vscan on Access Policy %s: %sR6N(R#R7R8R9RRGR-R;R'R<R"R+R	R=R>(R.RARD((sb/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_ontap_vscan_on_access_policy.pytmodify_on_access_policy�scC`s�|jdk	r1|jdt|j�j��n|jrV|jdt|j��n|jdk	r�|jdt|j��n|jr�tj	j
d�}|j|�x$|jD]}|jd|�q�Wn|jrtj	j
d�}|j|�x$|jD]}|jd|�qWn|j
rntj	j
d�}|j|�x$|j
D]}|jd|�qQWn|jr�tj	j
d	�}|j|�x$|jD]}|jd
|�q�Wn|S(Nsis-scan-mandatorys
max-file-sizesscan-files-with-no-extsfile-ext-to-excludesfile-extensionsfile-ext-to-includeRs vscan-on-access-policy-ui-filterspaths-to-excludes	file-path(RR1R9RtlowerRRRR#R7R8R:RRR(R.RAtext_objt	extensiont
ui_filter_objtfiltertpath_objtpath((sb/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_ontap_vscan_on_access_policy.pyRG�s6"		
	
	
	
c
C`s |j�}|dkrtSy|jd�jd�}WnKtjjk
r�}|jjdd|j	t
|�fdtj��nX|j
dk	r�t|j
�j�|jd�kr�tSn|jr�|jt|jd��kr�tSn|jdk	r(t|j�j�|jd�kr(tSn|jr�|jd	�dkrJtSg}x0|jd	�j�D]}|j|j��qfW|j|j|�}|r�tSn|jr"|jd
�dkr�tSg}x0|jd
�j�D]}|j|j��q�W|j|j|�}|r"tSn|jr�|jd�dkrDtSg}x0|jd�j�D]}|j|j��q`W|j|j|�}|r�tSn|jr|jd�dkr�tSg}	x0|jd�j�D]}|	j|j��q�W|j|j|	�}|rtSntS(
Nsattributes-listsvscan-on-access-policy-infoR!s'Error Accessing on access policy %s: %sR6sis-scan-mandatorys
max-file-sizesscan-files-with-no-extsfile-ext-to-excludesfile-ext-to-includeRspaths-to-exclude(R2R1R(R?R#R7R<R"R+RR	R=R>RRRKR@R'RRRRtget_childrentappendtget_contentt_diffRRR(
R.tresultsR3RDtcurrent_to_excludeteachtktcurrent_to_includetcurrent_filterstcurrent_paths_to_exlude((sb/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_ontap_vscan_on_access_policy.pythas_policy_changedsl'$	$				cC`s9g||D]$}||ks)||kr|^q}|S(s�
        :param li1: list 1
        :param li2: list 2
        :return: a list contain items that are not on both lists
        ((R.tli1tli2titli_dif((sb/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_ontap_vscan_on_access_policy.pyRUEs5cC`s�tjd|j�t}|j�}|jdkr�|j|�se|jjs\|j	�nt
}q�|j�r�|jjs�|j�nt
}q�n|jdkr�|j|�r�|jjs�|j
�nt
}q�n|jjd|�dS(Ntna_ontap_vscan_on_access_policyR
Rtchanged(R#t
ems_log_eventR-R(R2RR4R"t
check_modeRHR'R]RJRIt	exit_json(R.RcR3((sb/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_ontap_vscan_on_access_policy.pytapplyNs$
	

N(t__name__t
__module__t__doc__R0R1R4R2RHRIRJRGR]RURg(((sb/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_ontap_vscan_on_access_policy.pyR
us	#			
			>		cC`st�}|j�dS(s&
    Execute action from playbook
    N(R
Rg(tcommand((sb/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_ontap_vscan_on_access_policy.pytmaines	t__main__(t
__future__RRRRt
__metaclass__tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLEStRETURNR=tansible.module_utils.basicRtansible.module_utils._textR	tansible.module_utils.netapptmodule_utilstnetappR#thas_netapp_libR*tobjectR
RlRh(((sb/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_ontap_vscan_on_access_policy.pyt<module>s 


=�	

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