ó ¡ôXc@sddlZddlZddlZddlmZddlmZddlm Z ddl m Z ddl m Z mZmZddlZddlZddlmZmZddlmZdd lmZdd lmZd eeee fd „ƒYZdS( iÿÿÿÿN(tArg(t ClientError(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ƒƒ|jdbootstrap 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 ƒƒ|jjd tƒsŸtj|ƒnit‡fd †|jDƒƒd 6i|d6|d6fd6S(Nt destinationtprefixsbundle-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 sstpartsR0R1t manifests(RRR2R3tjointexiststmkdirR R R!tget_bundle_key_prefixtensure_dest_bucket_existstcreate_and_upload_bundletbuild_manifesttformattopent dump_to_fileR4tupload_bundle_filetFalsetremovettuplet image_parts( R't path_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 ƒtjd tƒ\} } |jjd tƒs;tjd tƒ\} } 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__t DESCRIPTIONRtinttARGSRRQRUR?(((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.utilR R (((sR/usr/lib/python2.7/site-packages/euca2ools/commands/bundle/bundleanduploadimage.pyts