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/netapp_e_flashcache.pyo

�
�Udac@`sKddlmZmZmZeZidd6dgd6dd6ZdZd	Zd
Z	ddl
Z
ddlZddlZddl
Z
ddlmZdd
lmZddlmZddlmZddlmZddlmZeedeeedeeeeeed�
Zdefd��YZd�Z e!dkrGe �ndS(i(tabsolute_importtdivisiontprint_functions1.1tmetadata_versiontpreviewtstatust	communitytsupported_bys1
module: netapp_e_flashcache
author: Kevin Hulquest (@hulquest)
version_added: '2.2'
short_description: NetApp E-Series manage SSD caches
description:
- Create or remove SSD caches on a NetApp E-Series storage array.
options:
  api_username:
      required: true
      description:
      - The username to authenticate with the SANtricity WebServices Proxy or embedded REST API.
  api_password:
      required: true
      description:
      - The password to authenticate with the SANtricity WebServices Proxy or embedded REST API.
  api_url:
      required: true
      description:
      - The url to the SANtricity WebServices Proxy or embedded REST API.
  validate_certs:
      required: false
      default: true
      description:
      - Should https certificates be validated?
      type: bool
  ssid:
    required: true
    description:
    - The ID of the array to manage (as configured on the web services proxy).
  state:
    required: true
    description:
    - Whether the specified SSD cache should exist or not.
    choices: ['present', 'absent']
    default: present
  name:
    required: true
    description:
    - The name of the SSD cache to manage
  io_type:
    description:
    - The type of workload to optimize the cache for.
    choices: ['filesystem','database','media']
    default: filesystem
  disk_count:
    description:
    - The minimum number of disks to use for building the cache. The cache will be expanded if this number exceeds the number of disks already in place
  size_unit:
    description:
    - The unit to be applied to size arguments
    choices: ['bytes', 'b', 'kb', 'mb', 'gb', 'tb', 'pb', 'eb', 'zb', 'yb']
    default: gb
  cache_size_min:
    description:
    - The minimum size (in size_units) of the ssd cache. The cache will be expanded if this exceeds the current size of the cache.
s:
    - name: Flash Cache
      netapp_e_flashcache:
        ssid: "{{ ssid }}"
        api_url: "{{ netapp_api_url }}"
        api_username: "{{ netapp_api_username }}"
        api_password: "{{ netapp_api_password }}"
        validate_certs: "{{ netapp_api_validate_certs }}"
        name: SSDCacheBuiltByAnsible
sz
msg:
    description: Success message
    returned: success
    type: str
    sample: json for newly created flash cache
N(tbasic_auth_argument_spec(t
AnsibleModule(treduce(t	HTTPError(t	to_native(topen_urltGETi
cC`sy[td|d|d|d|d|d|d|d|d	|d
|	d|
d|d
|�
}Wntk
ry}|j}nXy.|j�}|r�tj|�}nd}Wn&tk
r�|
r�q�t|��nX|j�}|dkr|
rt||��n
||fSdS(Nturltdatatheaderstmethodt	use_proxytforcet
last_mod_timettimeouttvalidate_certsturl_usernameturl_passwordt
http_agenttforce_basic_authi�(	R
RtfptreadtjsontloadstNonet	Exceptiontgetcode(RRRRRRRRRRRRRt
ignore_errorstrterrtraw_datat	resp_code((sV/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_flashcache.pytrequesths($



tNetAppESeriesFlashCachecB`s�eZd�Zddd�Zd�Zd�Zd�Zed��Z	ed��Z
ed��Zed	��Zed
��Z
ed��Zd�Zd
�ZRS(c%C`s$d|_d|_d|_d|_d|_d|_d|_d|_d|_	d|_
d|_d|_d|_
d|_tddddddddBddCd
dDddEddFddGddH�
|_t�}|jtdtdddt�dtdddtdt�dtdddt�dtdddddgdd�d tdtdd�d!tdtdd�d"tdd#�d$tdd%�d&tdd#�d'tdd(dd(d)d*g�d+tddddddddd
ddddg
dd�d,tdd-d.d/d0d1d2d3gdd�d4tdd�d5tdd���td6|d7gd8gd9t�|_|jj|jj�tj|jj�|_|jj|_|jd:kr�|jr�tjd;tjd<|j�n.|jd=krtjd;tjd>t j!�ntd?d@�|_"d@|j"dA<dS(INtbytesitbtkbitmbitgbittbitpbitebitzbitybitapi_usernamettypetstrtrequiredtapi_passwordtno_logtapi_urltstatetdefaulttpresenttchoicestabsenttssidtnamet
disk_counttintt	disk_refstlisttcache_size_mintio_typet
filesystemtdatabasetmediat	size_unittcriteria_disk_phy_typetsastsas4ktfibret	fibre520btscsitsatatpatatlog_modetlog_patht
argument_spectrequired_iftmutually_exclusivetsupports_check_modetfiletleveltfilenametstderrtstreamtAcceptsapplication/jsonsContent-Typeii@IIIll (#R RARTRUR:R4R8R@RRBRKRFRGt	driveRefsR;tdictt_size_unit_mapRtupdatetTrueR	tmodulet__dict__tparamstloggingt	getLoggert	__class__t__name__t_loggertdebugtbasicConfigtDEBUGtsysR]tpost_headers(tselfRV((sV/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_flashcache.pyt__init__�sr															!0	!	R.c
C`s�|jd�td|d|dd�}|r;||d<nt|jd|jdtj|�d	|jd
dd|jd
|j	d|j
�\}}|dkr�|jjdd�ng|D]}|d^q�}t
d�|d�}	||	fS(Nsgetting candidate disks...t
driveCounttsizeUnitt	driveTypetssdttargetUsableCapacitys/storage-systems/%s/drivesRRRtPOSTRRRi�tmsgs;Cannot find disks to match requested criteria for ssd cachetidcS`s|t|d�S(NtusableCapacity(RC(tstd((sV/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_flashcache.pyt<lambda>�si(RmRaR(R:R@RtdumpsRqR4R8RRet	fail_jsonR
(
RrRBRKtcapacityt
drives_reqtrctdrives_respR~tdisk_idsR*((sV/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_flashcache.pytget_candidate_disks�s 
	
cC`s�|jd|jd|jd|j�\}}|jd�td|d|j�}t|jd|j	dt
j|�d	|jd
dd|j
d
|jd|j�\}|_dS(NRBRKR�screating ssd cache...R`RAs/storage-systems/%s/flash-cacheRRRRyRRR(R�RBRKRFRmRaRAR(R:R@RR�RqR4R8Rtresp(RrR�R*t
create_fc_reqR�((sV/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_flashcache.pytcreate_cache�s
cC`s�|jd�td|jd|j�}t|jd|jdtj|�d|j	ddd	|j
d
|jd|j�\}|_
dS(Nsupdating flash cache config...RAt
configTypes)/storage-systems/%s/flash-cache/configureRRRRyRRR(RmRaRARGR(R:R@RR�RqR4R8RR�(Rrt
update_fc_reqR�((sV/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_flashcache.pytupdate_cache�s
	cC`s[|jd�t|jd|jddd|jd|jd|jdt�\}|_dS(	Nsdeleting flash cache...s/storage-systems/%s/flash-cacheRtDELETERRRR#(	RmR(R:R@R4R8RRdR�(RrR�((sV/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_flashcache.pytdelete_caches
cC`sGt|jd�|jkrC|jdt|jd�|j�tSdS(NR`sBneeds resize: current disk count %s < requested requested count %s(tlentcache_detailRBRmRd(Rr((sV/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_flashcache.pytneeds_more_diskss	cC`sGt|jd�|jkrC|jdt|jd�|j�tSdS(NR`sBneeds resize: current disk count %s < requested requested count %s(R�R�RBRmRd(Rr((sV/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_flashcache.pytneeds_less_diskss	cC`st|jddd�S(NtfcDriveInfotfcWithDrivestusedCapacity(RCR�(Rr((sV/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_flashcache.pytcurrent_size_bytesscC`s&|jr|j|j|jSdSdS(Ni(RFRbRK(Rr((sV/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_flashcache.pytrequested_size_bytess	cC`s3|j|jkr/|jd|j|j�tSdS(NsEneeds resize: current capacity %sb is less than requested minimum %sb(R�R�RmRd(Rr((sV/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_flashcache.pytneeds_more_capacity%s	cC`s|jp|jp|jS(N(R�R�R�(Rr((sV/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_flashcache.pytneeds_resize,scC`s�t|jd�}d}d}g}|jr%|j|}|jd|�\}}|}|}xH|j||jkr�|d7}|jd|�\}}|}|}qbWtd|�}|jd�t	|j
d|jdtj
|�d	|jd
dd|jd
|jd|j�\}	|_n�|jr�|jr�td|j�}
t	|j
d|jdtj
|
�d	|jd
dd|jd
|jd|j�\}	|_ndS(NR`iRBitdriveRefsadding drives to flash-cache...s)/storage-systems/%s/flash-cache/addDrivesRRRRyRRRs,/storage-systems/%s/flash-cache/removeDrives(R�R�R�RBR�R�R�RaRmR(R:R@RR�RqR4R8RR�R�R`(Rrtcurrent_disk_counttproposed_new_diskstproposed_additional_bytestproposed_disk_idstproposed_disk_countR�R*tadd_drives_reqR�t	rm_drives((sV/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_flashcache.pytresize_cache0s6	


	
c
C`sPtdt�}t|jd|jd|jd|jd|jdt�\}}|dkrh||_	n	d|_	|dkr�td	||f��n|jd
krR|j	r8|j	d|j
kr�|jd�t|d<n|j	d
d|jkr|jd�t|d<n|jrO|jd�t|d<qOqu|jd�t|d<n#|j	ru|jd�t|d<n|ds�|jd�|jj|�n|jjr�|jd�|jj|�n|jd
kr|j	s�|j�n|jr|j�n|j�n|jdkr/|j�n|jjd|d|j�dS(Ntchangeds/storage-systems/%s/flash-cacheRRRR#i�i�sJUnexpected error code %s fetching flash cache detail. Response data was %sR=RAsCHANGED: name differstflashCacheBaseR�sCHANGED: io_type differssCHANGED: resize requireds>CHANGED: requested state is 'present' but cache does not exists5CHANGED: requested state is 'absent' but cache existssno changes, exiting...s/changes pending in check mode, exiting early...R?(i�i�(RatFalseR(R:R@R4R8RRdR�R R!R;RARmRGR�Ret	exit_jsont
check_modeR�R�R�R�R�(RrtresultR�t
cache_resp((sV/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_flashcache.pytapplyXsR		



	


	




	
	


N(Rkt
__module__RsR R�R�R�R�tpropertyR�R�R�R�R�R�R�R�(((sV/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_flashcache.pyR)�s	I				(cC`spt�}y|j�WnRtk
rk}|jdt|��|jjddt|�dtj��nXdS(NsException in apply(): 
%sRzs'Failed to create flash cache. Error[%s]t	exception(	R)R�R!RmRReR�t	tracebackt
format_exc(tspte((sV/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_flashcache.pytmain�s	t__main__("t
__future__RRRR5t
__metaclass__tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLEStRETURNRRhRpR�tansible.module_utils.apiRtansible.module_utils.basicR	tansible.module_utils.six.movesR
t+ansible.module_utils.six.moves.urllib.errorRtansible.module_utils._textRtansible.module_utils.urlsR
R RdR�R(tobjectR)R�Rk(((sV/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_flashcache.pyt<module>s2


;�	


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