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

�
�Udac@`s5dZddlmZmZmZeZidd6dgd6dd6Zd	Zd
Z	dZ
ddlZdd
lm
Z
ddlmZddljjZddlmZej�Zy0ddlmZmZmZddlmZWnek
r�eZnXde fd��YZ!d�Z"e#dkr1e"�ndS(s%Element SW Software Snapshot Schedulei(tabsolute_importtdivisiontprint_functions1.1tmetadata_versiontpreviewtstatust	certifiedtsupported_bys}

module: na_elementsw_snapshot_schedule

short_description: NetApp Element Software Snapshot Schedules
extends_documentation_fragment:
    - netapp.solidfire
version_added: '2.7'
author: NetApp Ansible Team (@carchi8py) <[email protected]>
description:
- Create, destroy, or update accounts on ElementSW

options:

    state:
        description:
        - Whether the specified schedule should exist or not.
        required: true
        choices: ['present', 'absent']

    paused:
        description:
        - Pause / Resume a schedule.
        type: bool

    recurring:
        description:
        - Should the schedule recur?
        type: bool

    schedule_type:
        description:
        - Schedule type for creating schedule.
        choices: ['DaysOfWeekFrequency','DaysOfMonthFrequency','TimeIntervalFrequency']

    time_interval_days:
        description: Time interval in days.
        default: 1

    time_interval_hours:
        description: Time interval in hours.
        default: 0

    time_interval_minutes:
        description: Time interval in minutes.
        default: 0

    days_of_week_weekdays:
        description: List of days of the week (Sunday to Saturday)

    days_of_week_hours:
        description: Time specified in hours
        default: 0

    days_of_week_minutes:
        description:  Time specified in minutes.
        default: 0

    days_of_month_monthdays:
        description: List of days of the month (1-31)

    days_of_month_hours:
        description: Time specified in hours
        default: 0

    days_of_month_minutes:
        description:  Time specified in minutes.
        default: 0

    name:
        description:
        - Name for the snapshot schedule.
        - It accepts either schedule_id or schedule_name
        - if name is digit, it will consider as schedule_id
        - If name is string, it will consider as schedule_name

    snapshot_name:
        description:
        - Name for the created snapshots.

    volumes:
        description:
        - Volume IDs that you want to set the snapshot schedule for.
        - It accepts both volume_name and volume_id

    account_id:
        description:
        - Account ID for the owner of this volume.
        - It accepts either account_name or account_id
        - if account_id is digit, it will consider as account_id
        - If account_id is string, it will consider as account_name

    retention:
        description:
        - Retention period for the snapshot.
        - Format is 'HH:mm:ss'.

    starting_date:
        description:
        - Starting date for the schedule.
        - Required when C(state=present).
        - "Format: C(2016-12-01T00:00:00Z)"


    password:
        description:
        - Element SW access account password
        aliases:
        - pass

    username:
        description:
        - Element SW access account user-name
        aliases:
        - user
sS
   - name: Create Snapshot schedule
     na_elementsw_snapshot_schedule:
       hostname: "{{ elementsw_hostname }}"
       username: "{{ elementsw_username }}"
       password: "{{ elementsw_password }}"
       state: present
       name: Schedule_A
       schedule_type: TimeIntervalFrequency
       time_interval_days: 1
       starting_date: '2016-12-01T00:00:00Z'
       volumes:
       - 7
       - test
       account_id: 1

   - name: Update Snapshot schedule
     na_elementsw_snapshot_schedule:
       hostname: "{{ elementsw_hostname }}"
       username: "{{ elementsw_username }}"
       password: "{{ elementsw_password }}"
       state: present
       name: Schedule_A
       schedule_type: TimeIntervalFrequency
       time_interval_days: 1
       starting_date: '2016-12-01T00:00:00Z'
       volumes:
       - 8
       - test1
       account_id: 1

   - name: Delete Snapshot schedule
     na_elementsw_snapshot_schedule:
       hostname: "{{ elementsw_hostname }}"
       username: "{{ elementsw_username }}"
       password: "{{ elementsw_password }}"
       state: absent
       name: 6
sn

schedule_id:
    description: Schedule ID of the newly created schedule
    returned: success
    type: str
N(t
AnsibleModule(t	to_native(tNaElementSWModule(tDaysOfWeekFrequencytWeekdaytDaysOfMonthFrequency(tApiServerErrortElementSWSnapShotSchedulecB`sheZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�ZRS(s�
    Contains methods to parse arguments,
    derive details of ElementSW objects
    and send requests to ElementSW via
    the ElementSW SDK
    c,C`s�tj�|_|jjtdtdtdddg�dtdtdd�d	tdtdd
ddg�d
tdtdddd�dtdtdddd�dtdtdddd�dtdtdd�dtdtdddd�dtdtdddd�dtdtdd�dtdtdddd�dtdtdddd�dtdtdd�dtdtdd�dtdtdd�dtdtdd�d tdtdd�d!tdtdd�d"tdtdd���td#|jd$ddd!d d	gfd	ddgfd	d
dgfgd%t�|_|jj	}|d|_
|d|_|d	|_|d|_
|d|_|d|_|d|_|d|_|d|_|d
|_|d|_|d|_|d|_|d|_|jd
kr�|j
d+k	r�g|_xg|j
D]Y}t|�j�rk|jjtjt|���q1|jjtj |j!���q1Wq�n|j
dkr�|jd+kr�|jj"d&d'�n|j
dkr�|jd+kr�|jj"d&d(�n|d|_#|d|_$|d |_%|d!|_&|d"|_'d+|_(t)tkrh|jj"d&d)�n*tj*d*|j�|_+t,|j+�|_-d+S(,sn
        Parse arguments, setup state variables,
        check parameters and ensure SDK is installed
        tstatetrequiredtchoicestpresenttabsenttnamettypetstrt
schedule_typeRR
tTimeIntervalFrequencyttime_interval_daystinttdefaultittime_interval_hoursittime_interval_minutestdays_of_week_weekdaystlisttdays_of_week_hourstdays_of_week_minutestdays_of_month_monthdaystdays_of_month_hourstdays_of_month_minutestpausedtboolt	recurringt
starting_datet
snapshot_nametvolumest
account_idt	retentiont
argument_spectrequired_iftsupports_check_modetmsgs0Please provide required parameter: schedule_types'Please provide required parameter: names)Unable to import the ElementSW Python SDKtmoduleN(.tnetapp_utilstontap_sf_host_argument_specR.tupdatetdicttTruetFalseRR2tparamsRRRRR!R"R#R$R%RRRR&R(tNonetweekdaysRtisdigittappendRtfrom_idRt	from_namet
capitalizet	fail_jsonR)R*R+R,R-tcreate_schedule_resultt
HAS_SF_SDKtcreate_sf_connectiontsfeR
telementsw_helper(tselftparamtday((sa/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_elementsw_snapshot_schedule.pyt__init__�s�	













	")






	cC`s~y|jj�}Wntk
r'dSXxO|jD]D}t|j�|jkr`|j|_|S|j|jkr2|Sq2WdS(N(REtlist_schedulesRR:t	schedulesRtschedule_idR(RGt
schedule_listtschedule((sa/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_elementsw_snapshot_schedule.pytget_schedule-s
cC`s6y|jj|j�}|SWntk
r1dSXdS(N(RFtaccount_existsR,RR:(RGR,((sa/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_elementsw_snapshot_schedule.pytget_account_id>s

cC`sig}x\|jD]Q}|jj|j�|j�}|rJ|j|�q|jjdd|�qW|S(NR1s"Specified volume %s does not exist(R+RFt
volume_existststripR,R=R2RA(RGt
volume_idstvolumet	volume_id((sa/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_elementsw_snapshot_schedule.pyt
get_volume_idGsc
C`sd}|jdk	r]|jdkr]|jdk	r�td|jd|jd|j�}q�n�|jdk	r�|jdkr�|jdk	r�td|jd|jd|j	�}q�nH|jdk	r�|jdkr�t
jd|jd|j
d|j�}n|S(	NRR;thourstminutesR
t	monthdaysRtdays(R:RR;RR!R"R#R
R$R%R3RRRR(RGt	frequency((sa/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_elementsw_snapshot_schedule.pyt
get_frequencySs 			cC`s1t|j�jd�d|jkr)tStSdS(Nt(i(RR]tsplitRR7R8(RGtschedule_detail((sa/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_elementsw_snapshot_schedule.pytis_same_schedule_typefs%cC`sy�|j�}|dkr8|jjdd|j�n|j}tjd|jd|j	d|j
�}tj|||�}|j|_|j
|_
|j|_|jj|�|_WnHtk
r}|jjdd|jt|j�fdtj��nXdS(NR1s?Failed to create schedule frequency object - type %s parametersRUR*R-sError creating schedule %s: %st	exception(R^R:R2RARRR3tScheduleInfoR+R*R-tScheduleR&R(R)REtcreate_scheduleRBt	ExceptionR	tmessaget	tracebackt
format_exc(RGR]Rt
schedule_infotschedte((sa/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_elementsw_snapshot_schedule.pyRfms"				(cC`s�y>|jjd|�}|j}t|_|jjd|�WnHtk
r�}|jjdd|j	t
|j�fdtj
��nXdS(NRMROR1sError deleting schedule %s: %sRc(RERPROR7t
to_be_deletedtmodify_scheduleRgR2RARR	RhRiRj(RGRMtget_schedule_resultRlRm((sa/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_elementsw_snapshot_schedule.pytdelete_schedule�s		(cC`s�yB|jjd|�}|j}|j�|_|jdkr\|jjdd|j�n|j	dk	r�t
|j	�dkr�|j	|j_n|j
dk	r�|j
|j_
n|jdk	r�|j|j_n|jdk	r�|j|_n|jdk	r|j|_n|jdk	r.|j|_n|jjd|�WnHtk
r�}|jjdd|jt|j�fdtj��nXdS(NRMR1s?Failed to create schedule frequency object - type %s parametersiROsError updating schedule %s: %sRc(RERPROR^R]R:R2RARR+tlenRkRUR-R*R&R(R)RoRgRR	RhRiRj(RGRMRpRlRm((sa/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_elementsw_snapshot_schedule.pytupdate_schedule�s,	$(cC`srt}t}|jdk	r-|j�|_n|jdkr||jdk	r||jrf|j�|_q||jjdd�n|j	�}|dkr�|jdkr�t
|j�dkr�t}q�|jjdd�n�|dk	r�|jdkr�t}q�|jdk	r.|j
j|jkr.t}t}n|jdk	ra|j
j|jkrat}t}n�|jdk	r�|j|jkr�t}t}n�|jdk	r�|j|jkr�t}t}n�|jdk	r�|j|jkr�t}t}n\|jdk	rMt
|j�dkrMx5|j
jD]$}||jkr"t}t}q"q"Wn|j�}|dk	r�|j|�r�|jdkr�|jj|jks�|jj|jks�|jj|jkr�t}t}q�q�|jdkr�t
|jj�t
|j�ks.|jj|jks.|jj|jkr=t}t}q�t
|jj�t
|j�kr�|jj}|j}x,|D]!}||krzt}t}qzqzWq�q�|jd	kr�t
|jj�t
|j�ks�|jj|jks�|jj|jkrt}t}q�t
|jj�t
|j�kr�|jj}	|j}
t
gt|	|
�D]\}}||krW|^qW�dkr�t}t}q�q�q�q�t}t}q�|jjdd
|j�nd}
|rU|jjr�d}
qU|jdkr*|r|j|j�d
}
qR|j �d}
qU|jdkrU|j!|j�d}
qUn|jj"d|d|
�dS(NRR1s#Specified account id does not existis Specified volumes not on clusterRRR
Rs?Failed to create schedule frequency object - type %s parameterst sCheck mode, skipping changessSnapshot Schedule modifiedsSnapshot Schedule createdsSnapshot Schedule deletedtchanged(#R8R,R:RRRR+RXR2RARPRrR7R-RkR*R&R(R)RUR^RbRR]R\RYRZR[R;tzipt
check_modeRsRMRfRqt	exit_json(RGRuRsRatvolumeIDttemp_frequencytactual_frequency_monthdayttemp_frequency_monthdaytmonthdaytactual_frequency_weekdaysttemp_frequency_weekdaystactual_weekdayttemp_weekdaytresult_message((sa/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_elementsw_snapshot_schedule.pytapply�s�			$	$	!	!	!	$!	!	
!	!	:			
	(
t__name__t
__module__t__doc__RJRPRRRXR^RbRfRqRsR�(((sa/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_elementsw_snapshot_schedule.pyR�s	c									cC`st�}|j�dS(N(RR�(tv((sa/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_elementsw_snapshot_schedule.pytmain%s	t__main__($R�t
__future__RRRRt
__metaclass__tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLEStRETURNRitansible.module_utils.basicRtansible.module_utils._textR	tansible.module_utils.netapptmodule_utilstnetappR3t,ansible.module_utils.netapp_elementsw_moduleR
t
has_sf_sdkRCtsolidfire.custom.modelsRRR
tsolidfire.commonRRgR8tobjectRR�R�(((sa/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_elementsw_snapshot_schedule.pyt<module>s0


v(

�d	

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