Current File : //usr/lib/python2.7/site-packages/euca2ools/commands/bundle/bundleanduploadimage.pyo
�
��Xc@sddlZddlZddlZddlmZddlmZddlm	Z	ddl
mZddlm
Z
mZmZddlZddlZddlmZmZddlmZdd	lmZdd
lmZdeeee	fd��YZdS(
i����N(tArg(tClientError(tFileTransferProgressBarMixin(tcreate_bundle_pipeline(tcreate_bundle_part_deletertcreate_bundle_part_writertcreate_mpconn_aggregator(tBundleCreatingMixintBundleUploadingMixin(tBootstrapRequest(t	S3Request(tmkdtemp_for_large_filestBundleAndUploadImagec	BsheZdZeddddd�eddedd	dd
�gZd�Zd�Zd
�Zd�Z	RS(s0Prepare and upload an image for use in the clouds--preserve-bundletactiont
store_truethelps0do not delete the bundle as it is being uploadeds--max-pending-partsttypetdefaultisvpause the bundling process when more than this number
                of parts are waiting to be uploaded (default: 2)cCs�|j�tj|�yNtjj|jd|jjd��|jd<tj	j|j
�|jd<Wn'tk
r�|jj
ddt�nX|j�|j�|j�|j�dS(Nturlt
bootstrap_urltbootstrap_servicetbootstrap_auths>bootstrap setup failed; auto cert fetching will be unavailabletexc_info(tconfigure_bundle_upload_authR
t	configureR	t
SERVICE_CLASSt
from_othertservicetargstgett
AUTH_CLASStauthRtlogtdebugtTruetconfigure_bundle_credstconfigure_bundle_propertiestconfigure_bundle_outputtgenerate_encryption_keys(tself((sR/usr/lib/python2.7/site-packages/euca2ools/commands/bundle/bundleanduploadimage.pyR:s

	% 



c	
s�|jjd�rhtjj|jd|jd�}tjj|jd�s�tj|jd�q�n+tdd�}tjj||jd�}|jj	d|�|j
��|j�|j|��\}}|j
||�}dj|�}t|d��<}|j||jjd�|jjd�|jd	�WdQX�tjj|�}|j||d
|jjd
��|jjdt�s�tj|�nit�fd�|jD��d
6i|d6|d6fd6S(Ntdestinationtprefixsbundle-sbundle path prefix: %ss{0}.manifest.xmltwt
privatekeytcerttec2certt
show_progresstpreserve_bundlec3s9|]/}i|jd6�tjj|j�d6VqdS(tfilenametkeyN(R0tostpathtbasename(t.0tpart(t
key_prefix(sR/usr/lib/python2.7/site-packages/euca2ools/commands/bundle/bundleanduploadimage.pys	<genexpr>sstpartsR0R1t	manifests(RRR2R3tjointexiststmkdirRR R!tget_bundle_key_prefixtensure_dest_bucket_existstcreate_and_upload_bundletbuild_manifesttformattopentdump_to_fileR4tupload_bundle_filetFalsetremovettupletimage_parts(	R'tpath_prefixttempdirtdigesttpartinfotmanifesttmanifest_filenamet
manifest_filet
manifest_dest((R7sR/usr/lib/python2.7/site-packages/euca2ools/commands/bundle/bundleanduploadimage.pytmainRs4
	#
cCsb|jr.x"|dD]}dG|dGHqWn|ddddk	r^dG|dddGHndS(NR8tUploadedR1R9i(R!tNone(R'tresultR6((sR/usr/lib/python2.7/site-packages/euca2ools/commands/bundle/bundleanduploadimage.pytprint_resultzs
	c
CsNtjtd|jd��}tj|jd�}|jd|_tjj	j
�\}}t|jd||jd|jd|d|j�}|j
�t|||jd	d
|d|j�}|j
�tjdt�\}	}
|jjdt�s;tjdt�\}}t|	d
|�|	j
�|j
�n|	}t|d|j�}
|j
�z2|j||d|
d
|d|jjd��Wd|j�XzVy|j�}|
j�}Wn3tk
r�|jjddt�td��nXWd|j
�|
j
�X|jjdt|�|jd�|jjd|�||fS(Nitmax_pending_partsR)t
image_sizetimagetenc_keytenc_ivR!t	part_sizetpart_write_semtduplexR/t
out_mpconntpartinfo_out_mpconnR.s!EOFError from reading bundle infoRs.corrupt bundle: bundle process was interrupteds%i bundle parts uploaded to %stbucketsbundle digest: %s(tmultiprocessingt	SemaphoretmaxRttarfiletTarInfotsizet	euca2oolstbundletutiltopen_pipe_fileobjsRR!tcloseRtPipeRERRRtupload_bundle_partstreleasetrecvtEOFErrorR R"tRuntimeErrortinfotlen(R'RIR7R\ttarinfotpartwriter_in_rtpartwriter_in_wtdigest_result_mpconntbundle_partinfo_mpconntuploaded_partinfo_mpconn_rtuploaded_partinfo_mpconn_wtdeleted_partinfo_mpconn_rtdeleted_partinfo_mpconn_wt bundle_partinfo_aggregate_mpconnRKRL((sR/usr/lib/python2.7/site-packages/euca2ools/commands/bundle/bundleanduploadimage.pyR?�sZ

	


	

(
t__name__t
__module__tDESCRIPTIONRtinttARGSRRQRUR?(((sR/usr/lib/python2.7/site-packages/euca2ools/commands/bundle/bundleanduploadimage.pyR/s		(	(Ratos.pathR2RdtrequestbuilderRtrequestbuilder.exceptionsRtrequestbuilder.mixinsRteuca2ools.bundle.pipes.coreRteuca2ools.bundle.pipes.fittingsRRRteuca2ools.bundle.manifestRgteuca2ools.bundle.utilt euca2ools.commands.bundle.mixinsRRteuca2ools.commands.bootstrapR	teuca2ools.commands.s3R
teuca2ools.utilRR(((sR/usr/lib/python2.7/site-packages/euca2ools/commands/bundle/bundleanduploadimage.pyt<module>s