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_quotas.pyc

�
�Udac@`s�ddlmZmZmZeZidd6dgd6dd6ZdZd	Zd
Z	ddl
Z
ddlmZdd
l
mZddljjZddlmZej�Zdefd��YZd�Zedkr�e�ndS(i(tabsolute_importtdivisiontprint_functions1.1tmetadata_versiontpreviewtstatust	certifiedtsupported_bys�
module: na_ontap_quotas
short_description: NetApp ONTAP Quotas
extends_documentation_fragment:
    - netapp.na_ontap
version_added: '2.8'
author: NetApp Ansible Team (@carchi8py) <[email protected]>
description:
- Set/Modify/Delete quota on ONTAP
options:
  state:
    description:
    - Whether the specified quota should exist or not.
    choices: ['present', 'absent']
    default: present
    type: str
  vserver:
    required: true
    description:
      - Name of the vserver to use.
    type: str
  volume:
    description:
    - The name of the volume that the quota resides on.
    required: true
    type: str
  quota_target:
    description:
    - The quota target of the type specified.
    required: true
    type: str
  qtree:
    description:
    - Name of the qtree for the quota.
    - For user or group rules, it can be the qtree name or "" if no qtree.
    - For tree type rules, this field must be "".
    default: ""
    type: str
  type:
    description:
    - The type of quota rule
    choices: ['user', 'group', 'tree']
    required: true
    type: str
  policy:
    description:
    - Name of the quota policy from which the quota rule should be obtained.
    type: str
  set_quota_status:
    description:
    - Whether the specified volume should have quota status on or off.
    type: bool
  file_limit:
    description:
    - The number of files that the target can have.
    default: '-'
    type: str
  disk_limit:
    description:
    - The amount of disk space that is reserved for the target.
    default: '-'
    type: str
  threshold:
    description:
    - The amount of disk space the target would have to exceed before a message is logged.
    default: '-'
    type: str
sy
    - name: Add/Set quota
      na_ontap_quotas:
        state: present
        vserver: ansible
        volume: ansible
        quota_target: /vol/ansible
        type: user
        policy: ansible
        file_limit: 2
        disk_limit: 3
        set_quota_status: True
        hostname: "{{ netapp_hostname }}"
        username: "{{ netapp_username }}"
        password: "{{ netapp_password }}"
    - name: modify quota
      na_ontap_quotas:
        state: present
        vserver: ansible
        volume: ansible
        quota_target: /vol/ansible
        type: user
        policy: ansible
        file_limit: 2
        disk_limit: 3
        threshold: 3
        set_quota_status: False
        hostname: "{{ netapp_hostname }}"
        username: "{{ netapp_username }}"
        password: "{{ netapp_password }}"
    - name: Delete quota
      na_ontap_quotas:
        state: absent
        vserver: ansible
        volume: ansible
        quota_target: /vol/ansible
        type: user
        policy: ansible
        hostname: "{{ netapp_hostname }}"
        username: "{{ netapp_username }}"
        password: "{{ netapp_password }}"
s

N(t
AnsibleModule(t	to_native(tNetAppModuletNetAppONTAPQuotascB`sVeZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
RS(	sClass with quotas methodscC`s�tj�|_|jjtdtdtdddgdd�dtdtdd	�d
tdtdd	�dtdtdd	�dtdtdd	dd
�dtdtdd	ddddg�dtdtdd	�dtdtdd�dtdtdd	dd�dtdtdd	dd�dtdtdd	dd���td|jdt�|_t	�|_
|j
j|jj�|_
ttkr�|jjdd�n%tjd|jd|j
d�|_dS(Ntstatetrequiredtchoicestpresenttabsenttdefaulttvserverttypetstrtvolumetquota_targettqtreettusertgroupttreetpolicytset_quota_statustboolt
file_limitt-t
disk_limitt	thresholdt
argument_spectsupports_check_modetmsgs(the python NetApp-Lib module is requiredtmodule(tnetapp_utilstna_ontap_host_argument_specR#tupdatetdicttFalsetTrueRR&R
t	na_helpertset_parameterstparamst
parameterstHAS_NETAPP_LIBt	fail_jsontsetup_na_ontap_zapitserver(tself((sR/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_ontap_quotas.pyt__init__�s,!$	
cC`s�tjjd�}|ji|jdd6�y|jj|dt�}WnBtjjk
r�}|j	j
ddt|�dtj
��nX|r�|dSdS(	s�
        Return details about the quota status
        :param:
            name : volume name
        :return: status of the quota. None if not found.
        :rtype: dict
        squota-statusRtenable_tunnelingR%s%Error fetching quotas status info: %st	exceptionRN(R'tzapit	NaElementttranslate_structR0R4tinvoke_successfullyR,t
NaApiErrorR&R2R	t	tracebackt
format_exctNone(R5tquota_status_gettresultterror((sR/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_ontap_quotas.pytget_quota_status�s	cC`s�tjjd�}iii|jdd6|jdd6|jdd6|jdd6d6d	6}|j|�|jjd
�r�|d	djd
|jd
�ny|jj|dt	�}WnBtjj
k
r�}|jjdd
t
|�dtj��nX|jd�r�t|jd��dkr�i|dddd6|dddd6|dddd6|dddd6}|SdS(sc
        Get quota details
        :return: name of volume if quota exists, None otherwise
        squota-list-entries-iterRRsquota-targetRs
quota-typeRsquota-entrytqueryRR7R%sError fetching quotas info: %sR8snum-recordsisattributes-lists
file-limitRs
disk-limitR!R"N(R'R9R:R0R;tgett
add_new_childR4R<R,R=R&R2R	R>R?tget_child_by_nametinttget_child_contentR@(R5t	quota_getRERBRCt
return_values((sR/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_ontap_quotas.pyt
get_quotas�s.
"*cC`si|jdd6|jdd6|jdd6|jdd6|jdd6|jd	d
6|jdd6}|jjd�r�|jd|d<ntjjjd
|�}y|jj|dt�WnOtjj	k
r}|j
jdd|jdt|�fdt
j��nXdS(s$
        Adds a quota entry
        RRsquota-targetRs
quota-typeRRs
file-limitR!s
disk-limitR"Rsquota-set-entryR7R%s)Error adding/modifying quota entry %s: %sR8N(R0RFR'R9R:tcreate_node_with_childrenR4R<R,R=R&R2R	R>R?(R5toptionst	set_entryRC((sR/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_ontap_quotas.pytquota_entry_set�s"cC`s�i|jdd6|jdd6|jdd6|jdd6}tjjjd|�}|jjd�r�|jd|jd�ny|jj|d	t	�WnOtjj
k
r�}|jjd
d|jdt
|�fdtj��nXd
S(s'
        Deletes a quota entry
        RRsquota-targetRs
quota-typeRsquota-delete-entryRR7R%s!Error deleting quota entry %s: %sR8N(R0R'R9R:RNRFRGR4R<R,R=R&R2R	R>R?(R5RORPRC((sR/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_ontap_quotas.pytquota_entry_delete�scC`s�i|jdd6|jdd6|jdd6|jdd6}|j|�|jjd�rwt|jd�|d<ntjjjd|�}y|jj	|d	t
�WnOtjjk
r�}|jj
d
d|jdt|�fdtj��nXd
S(s(
        Modifies a quota entry
        RRsquota-targetRs
quota-typeRRsquota-modify-entryR7R%s"Error modifying quota entry %s: %sR8N(R0R)RFRR'R9R:RNR4R<R,R=R&R2R	R>R?(R5tmodify_attrsROtmodify_entryRC((sR/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_ontap_quotas.pytquota_entry_modify
s
cC`s�tjjj|i|jdd6�}y|jj|dt�WnRtjjk
r�}|j	j
dd||jdt|�fdtj
��nXdS(s!
        on or off quota
        RR7R%sError setting %s for %s: %sR8N(R'R9R:RNR0R4R<R,R=R&R2R	R>R?(R5RtquotaRC((sR/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_ontap_quotas.pyton_or_off_quota!scC`s�tjd|j�d}d}|j�}d|jkr�|j�}|dk	r�|jji|dkrpt	nt
d6|j�}|r�|dr�dnd}q�q�n|jj||j�}|dkr�|jj||j�}n|jjr�|j
jrq�|dkr|j�nk|dkr4|j�nR|dk	r�x3t|�D]%}|j|�||jdd	�<qMW|j|�n|dk	r�|j|�q�n|j
jd
|jj�dS(s(
        Apply action to quotas
        tna_ontap_quotasRtonsquota-ons	quota-offtcreatetdeletet_R tchangedN(R't
ems_log_eventR4R@RMR0RDR-tget_modified_attributesR,R+t
get_cd_actionR]R&t
check_modeRQRRtlisttpoptreplaceRURWt	exit_json(R5tmodify_quota_statustmodify_quotatcurrenttquota_statustquota_status_actiont	cd_actiontkey((sR/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_ontap_quotas.pytapply/s8	(

#(t__name__t
__module__t__doc__R6RDRMRQRRRURWRm(((sR/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_ontap_quotas.pyR�s			 				cC`st�}|j�dS(sExecute actionN(RRm(t	quota_obj((sR/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_ontap_quotas.pytmainRs	t__main__(t
__future__RRRRt
__metaclass__tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLEStRETURNR>tansible.module_utils.basicRtansible.module_utils._textR	tansible.module_utils.netapptmodule_utilstnetappR't"ansible.module_utils.netapp_moduleR
thas_netapp_libR1tobjectRRrRn(((sR/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_ontap_quotas.pyt<module>s"


F+�	

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