Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
Size: Mime:
ó
±EYc@sÀdZddlZddlZddlZddlZddlmZddlmZ	ddl
mZddlmZ
ddlmZddlmZddlmZddlmZdd	lmZddlZdd
lmZddlZddlmZddlmZdd
lmZddlm Z ej!j"Z"ej#e$ƒZ%da'e(a)d„Z*d„Zd„Z+d„Z,d„Z-d„Z.d„Z/d„Z0d„Z1de2fd„ƒYZ3dS(s4
Handles all requests relating to volumes + cinder.
iÿÿÿÿN(tclient(t
exceptions(tloading(tlog(tencodeutils(texcutils(tstrutils(tavailability_zones(t	exception(t_(t_LE(t_LWcCs
dadS(s%Testing method to reset globals.
    N(tNonet_SESSION(((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/volume/cinder.pyt
reset_globals5sc
Cs4ts'tjttjjjjƒand}d}|j
ƒ}tjjjdƒ\}}}i|d6|d6|d6tjj
d6}tjjr°tjj|jƒ}|}ntj||}tj|ƒ}|dkrtrtdƒ}	tj|	ƒtantj|dtd	|d
|dtjj|S(Nt:tservice_typetservice_namet	interfacetregion_namet1s«Cinder V1 API is deprecated as of the Juno release, and Nova is still configured to use it. Enable the V2 API in Cinder and set cinder.catalog_info in nova.conf to use it.tsessiontauthtendpoint_overridetconnect_retries(R
t
ks_loadingtload_session_from_conf_optionstCONFtnovatconftcindertcinder_grouptnameRtget_auth_plugintcatalog_infotsplittos_region_nametendpoint_templatetto_dicttget_endpointt
cinder_clienttget_volume_api_from_urlt_V1_ERROR_RAISEDRtLOGtwarningtTruetClientthttp_retries(
tcontextturlRRRRRtservice_parameterstversiontmsg((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/volume/cinder.pytcinderclient<s4
	
		cCs×i}|j|d<|j|d<|j|d<|j|d<|j|d<d|d<d|d<t|d	tƒ|d	<|jrótj	ƒ|d
<xY|jD]N}ii|j
dƒd6|j
dƒd6|d
6}|d
j|jƒƒq”Wd|d<n
d|d<t
|dƒr)|j|d<|j|d<n|j|d<|j|d<|j|d<|j|d<tj|jƒ|d<i|d<x+|jjƒD]\}}||d|<qWt
|dƒrÓtj|jƒ|d<n|S(s#Maps keys for volumes summary view.tidtstatustsizetavailability_zonet
created_atttattach_timet
mountpointtmultiattachtattachmentst
attachment_idtdevicet	server_idtattachedt
attach_statustdetachedtdisplay_nametdisplay_descriptiontvolume_type_idtsnapshot_idtbootabletvolume_metadatatvolume_image_metadata(R6R7R8R9R:tgetattrtFalseR?tcollectionstOrderedDicttgettupdatetitemsthasattrRFRGR tdescriptiontvolume_typeRIRtbool_from_stringRJtmetadatatcopytdeepcopyRL(R0tvoltdt
attachmenttatkeytvalue((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/volume/cinder.pyt _untranslate_volume_summary_viewjs@






	







cCs¸i}|j|d<|j|d<|j|d<|j|d<|j|d<t|dƒrs|j|d<|j|d<n|j|d<|j	|d<|j
|d<|j|d	<|j|d
<|S(s%Maps keys for snapshots summary view.R6R7tprogressR8R:RFRGt	volume_idt
project_idtvolume_size(R6R7RbR8R:RTRFRGR RURcRd(R0tsnapshotR\((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/volume/cinder.pyt"_untranslate_snapshot_summary_views










cs"tjˆƒ‡fd†ƒ}|S(s=Transforms a cinder exception but keeps its traceback intact.csçyˆ||||Ž}WnÇtjtjfk
r_}tj|ƒ}ttjd|ƒƒn„tjtjfk
r¢}tj|ƒ}ttj	d|ƒƒnAtj
tj
fk
râ}tj|ƒ}ttj
|ƒƒnX|S(Ntreason(tcinder_exceptiontConnectionErrortkeystone_exceptionRtexception_to_unicodet_reraiseRtCinderConnectionFailedt
BadRequesttInvalidInputt	Forbidden(tselftctxtargstkwargstrestexcterr_msg(tmethod(sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/volume/cinder.pytwrapper¹s(t	functoolstwraps(RyRz((RysG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/volume/cinder.pyttranslate_cinder_exception·scs‡fd†}t|ƒS(sLTransforms the exception for the volume but keeps its traceback intact.
    csyˆ|||||Ž}Wn\tjtjfk
rQttjd|ƒƒn*tjk
rzttjddƒƒnX|S(NRctoverstvolumes(RktNotFoundRiRmRtVolumeNotFoundt	OverLimitt	OverQuota(RrRsRcRtRuRv(Ry(sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/volume/cinder.pyRzÐs(R}(RyRz((RysG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/volume/cinder.pyttranslate_volume_exceptionÍscs‡fd†}t|ƒS(sUTransforms the exception for the snapshot but keeps its traceback
       intact.
    csVyˆ|||||Ž}Wn3tjtjfk
rQttjd|ƒƒnX|S(NRI(RkR€RiRmRtSnapshotNotFound(RrRsRIRtRuRv(Ry(sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/volume/cinder.pyRzßs
(R}(RyRz((RysG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/volume/cinder.pyttranslate_snapshot_exceptionÛscs‡fd†}t|ƒS(sDTransforms exceptions that can come from both volumes and snapshots.csyˆ|||||Ž}Wn\tjtjfk
rQttjd|ƒƒn*tjk
rzttjddƒƒnX|S(NRcR~t	snapshots(RkR€RiRmRRR‚Rƒ(RrRstres_idRtRuRv(Ry(sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/volume/cinder.pyRzês(R}(RyRz((RysG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/volume/cinder.pyttranslate_mixed_exceptionsèscCs'tjt|ƒ|tjƒdƒdS(Ni(tsixtreraisettypetsystexc_info(tdesired_exc((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/volume/cinder.pyRmõstAPIcBs”eZdZed„ƒZedd„ƒZd„Zdd„Z	dd„Z
dd„Zed„ƒZed„ƒZ
ed	„ƒZed
„ƒZedd„ƒZeddd
„ƒZed„ƒZed„ƒZeed„ƒZedddddd„ƒZed„ƒZed„ƒZed„ƒZed„ƒZed„ƒZed„ƒZed„ƒZed„ƒZ ed„ƒZ!RS(s,API for interacting with the volume manager.cCs%t|ƒjj|ƒ}t||ƒS(N(R5RRQRa(RrR0Rctitem((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/volume/cinder.pyRQüscCs^|p	i}t|ƒjjdtd|ƒ}g}x$|D]}|jt||ƒƒq:W|S(Ntdetailedtsearch_opts(R5RtlistR-tappendRa(RrR0R“RStrvalR‘((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/volume/cinder.pytget_alls	
cCsO|ddkrKtdƒi|dd6|dd6}tjd|ƒ‚ndS(NR7sin-usesJvolume '%(vol)s' status must be 'in-use'. Currently in '%(status)s' statusR6R[Rh(R	Rt
InvalidVolume(RrR0tvolumeR4((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/volume/cinder.pytcheck_attacheds
	cCs›|ddkrKtdƒi|dd6|dd6}tjd|ƒ‚n|ddkr„td	ƒ|d}tjd|ƒ‚n|j|||ƒdS(
NR7t	availablesFvolume '%(vol)s' status must be 'available'. Currently in '%(status)s'R6R[RhRDRCsvolume %s already attached(R	RR˜tcheck_availability_zone(RrR0R™tinstanceR4((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/volume/cinder.pytcheck_attachs	cCs‰|r…tjjr…tj||ƒ}||dkr…tdƒi|dd6|dd6|d6|dd6}tjd|ƒ‚q…nd	S(
s.Ensure that the availability zone is the same.R9s†Instance %(instance)s and volume %(vol)s are not in the same availability_zone. Instance is in %(ins_zone)s. Volume is in %(vol_zone)sR6RR[tins_zonetvol_zoneRhN(RRtcross_az_attachtaztget_instance_availability_zoneR	RR˜(RrR0R™Rtinstance_azR4((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/volume/cinder.pyRœ"s	cCs¦|ddkr9tdƒ|d}tjd|ƒ‚n|ddkrjtdƒ}tjd|ƒ‚n|dk	r¢|j|d	kr¢tjd
|dƒ‚ndS(NR7R›svolume %s already detachedR6RhRDREs+Volume must be attached in order to detach.R?Rc(R	RR˜RtuuidtVolumeUnattached(RrR0R™RR4((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/volume/cinder.pytcheck_detach3scCst|ƒjj|ƒdS(N(R5Rtreserve(RrR0Rc((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/volume/cinder.pytreserve_volumeEscCst|ƒjj|ƒdS(N(R5Rt	unreserve(RrR0Rc((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/volume/cinder.pytunreserve_volumeIscCst|ƒjj|ƒdS(N(R5Rtbegin_detaching(RrR0Rc((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/volume/cinder.pyR¬MscCst|ƒjj|ƒdS(N(R5Rtroll_detaching(RrR0Rc((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/volume/cinder.pyR­QstrwcCs&t|ƒjj|||d|ƒdS(Ntmode(R5Rtattach(RrR0Rct
instance_uuidR=R¯((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/volume/cinder.pyR°UscCsôt|ƒ}|jdkr/|jj|ƒdS|dkrÝ|j||ƒ}|drÝ|jdiƒ}|rº|j|iƒjdƒ}|s×tjtdƒi|d6|d6ƒq×qÚtjtdƒi|d6ƒqÝn|jj||ƒdS(	NRR>R?R@sÙattachment_id couldn't be retrieved for volume %(volume_id)s with instance_uuid %(instance_id)s. The volume has the 'multiattach' flag enabled, without the attachment_id Cinder most probably cannot perform the detach.Rctinstance_ids¶attachment_id couldn't be retrieved for volume %(volume_id)s. The volume has the 'multiattach' flag enabled, without the attachment_id Cinder most probably cannot perform the detach.(	R5R3RtdetachRRQR+R,R(RrR0RcR±R@RR™R?((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/volume/cinder.pyR³Zs$
	
c
Cs-y-t|ƒjj||ƒ}||d<|SWnùtjk
r(}tjƒÕtjt	dƒi|d6|j
dƒd6tj|ƒd6|j
d6ƒy|j|||ƒWnotk
r}tjt	dƒi|d6|j
dƒd6tj|ƒd6t|dƒr|j
ndd6ƒnXWdQXnXdS(Nt	connectors„Initialize connection failed for volume %(vol)s on host %(host)s. Error: %(msg)s Code: %(code)s. Attempting to terminate connection.R[thostR4tcodesÛConnection between volume %(vol)s and host %(host)s might have succeeded, but attempt to terminate connection has failed. Validate the connection and determine if manual cleanup is needed. Error: %(msg)s Code: %(code)s.(R5Rtinitialize_connectionRitClientExceptionRtsave_and_reraise_exceptionR+terrorR
RQRŠt	text_typeR¶tterminate_connectiont	ExceptionRTR(RrR0RcR´tconnection_infotexRw((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/volume/cinder.pyR·}s(



cCst|ƒjj||ƒS(N(R5RR¼(RrR0RcR´((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/volume/cinder.pyR¼scCst|ƒjj|||ƒS(N(R5Rtmigrate_volume_completion(RrR0t
old_volume_idt
new_volume_idRº((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/volume/cinder.pyRÀ¢sc
CsÃt|ƒ}
|dk	r%|d}nd}td|d|d|jd|jd|	d|d|ƒ}t|
tjƒr||d	<||d
<n||d<||d<|
jj	||}
t
||
ƒS(
NR6RIRVtuser_idRdR9RXtimageRefRFRGR RU(R5RtdictRÃRdt
isinstancet	v1_clientR.RtcreateRa(RrR0R8R RURftimage_idRVRXR9RRIRuR‘((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/volume/cinder.pyRȨs$
			



cCst|ƒjj|ƒdS(N(R5Rtdelete(RrR0Rc((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/volume/cinder.pyRÊÅscCs
tƒ‚dS(N(tNotImplementedError(RrR0Rctfields((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/volume/cinder.pyRRÉscCs%t|ƒjj|ƒ}t||ƒS(N(R5tvolume_snapshotsRQRg(RrR0RIR‘((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/volume/cinder.pytget_snapshotÍscCsLt|ƒjjdtƒ}g}x$|D]}|jt||ƒƒq(W|S(NR’(R5RÍR”R-R•Rg(RrR0RStrvalsR‘((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/volume/cinder.pytget_all_snapshotsÒs

cCs.t|ƒjj|t||ƒ}t||ƒS(N(R5RÍRÈRNRg(RrR0RcR RUR‘((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/volume/cinder.pytcreate_snapshotÜs
	cCs.t|ƒjj|t||ƒ}t||ƒS(N(R5RÍRÈR-Rg(RrR0RcR RUR‘((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/volume/cinder.pytcreate_snapshot_forceäs
	cCst|ƒjj|ƒdS(N(R5RÍRÊ(RrR0RI((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/volume/cinder.pytdelete_snapshotíscCst|ƒjj|ƒS(N(R5Rtget_encryption_metadata(RrR0Rc((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/volume/cinder.pytget_volume_encryption_metadatañscCs1t|ƒj}|j|i|d6dd6ƒdS(NR7s90%Rb(R5RÍtupdate_snapshot_status(RrR0RIR7tvs((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/volume/cinder.pyRÖõs

N("t__name__t
__module__t__doc__R„RQR}RR—RšRžRœR§R©R«R¬R­R°R³R·R¼RNRÀRÈRÊRRR†RÎRÐR‰RÑRÒRÓRÕRÖ(((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/volume/cinder.pyRùsD	
! 	
	(4RÚRORYR{RR5RR(RRitcinderclient.v1RÇt
keystoneauth1RkRRtoslo_logRtloggingt
oslo_utilsRRRRŠRRR¢t	nova.confRt	nova.i18nR	R
RRRt	getLoggerRØR+RR
RNR*RRaRgR}R„R†R‰RmtobjectR(((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/volume/cinder.pyt<module>sD		.	3