Viewing File: /usr/lib/python2.7/site-packages/euca2ools/commands/bundle/unbundle.pyc

ó
¡ôXc@sâddlZddlZddlZddlmZddlmZddlmZddl	m
Z
mZddlm
Z
ddlZddlmZddlmZmZmZdd	lmZd
ee
efd„ƒYZdS(iÿÿÿÿN(tArg(tBaseCommand(t
ArgumentError(tFileTransferProgressBarMixintRegionConfigurableMixin(t	Euca2ools(tBundleManifest(t
close_all_fdstopen_pipe_fileobjstwaitpid_in_thread(tUnbundleStreamtUnbundlecBs¶eZdZeZedddedddeddƒed	d
dddd
ddƒedddddd
ddƒeddddddƒgZd„Z	d„Z
d„Zd„ZRS(sRecreate an image from its bundled parts

The key used to unbundle the image must match a certificate that was used to bundle it.s-ms
--manifestttypetmetavartFILEtrequiredthelps%the bundle's manifest file (required)s-ss--sourcetDIRtdefaultt.sYdirectory containing the bundled image parts (default:
                current directory)s-ds
--destinationsOwhere to place the unbundled image (default: current
                directory)s-ks--privatekeys˜file containing
                the private key to decrypt the bundle with.  This must match
                a certificate used when bundling the image.cCsdtj|ƒ|jƒ|jjdƒsª|jjdƒ}|jjdƒr]||jd<qªdtjkr…tj	dƒ|jd<qª|r›||jd<qªt
dƒ‚ntjjtjj
|jdƒƒ|jd<tjj|jdƒst
dj|jdƒƒ‚ntjj|jdƒsFt
dj|jdƒƒ‚n|jjd|jdƒtjj|jjd	d
ƒƒs t
dj|jd	ƒƒ‚ntjj|jjd	d
ƒƒsàt
dj|jd	ƒƒ‚ntjj|jjd
d
ƒƒs t
dj|jd
ƒƒ‚ntjj|jjd
d
ƒƒs`t
dj|jd
ƒƒ‚ndS(Nt
privatekeysprivate-keyt
userregiontEC2_PRIVATE_KEYs.missing private key; please supply one with -ks%private key file '{0}' does not exists$private key file '{0}' is not a filesprivate key: %stsourceRs4argument -s/--source: directory '{0}' does not exists.argument -s/--source: '{0}' is not a directorytdestinations9argument -d/--destination: directory '{0}' does not exists3argument -d/--destination: '{0}' is not a directory(Rt	configuretupdate_config_viewtargstgettconfigtget_user_optiontostenvirontgetenvRtpatht
expandusert
expandvarstexiststformattisfiletlogtdebugtisdir(tselftconfig_privatekey((sF/usr/lib/python2.7/site-packages/euca2ools/commands/bundle/unbundle.pyR?sB

		!	!	!	!	c	
Cstd|gƒx|jD]÷}|jjd|jƒtjƒ}t|jƒ¾}xJtr |j	t
jƒ}|rœ|j|ƒ|j
|ƒ|jƒqWPqWWt|jƒdƒ}t|jdƒ}||kr|jjd||ƒtdj|j||ƒƒ‚nWdQXqWdS(Nt
except_fdssopening part '%s' for readingisGrejecting unbundle due to part SHA1 mismatch (expected: %x, actual: %x)sLbundle part '{0}' appears to be corrupt (expected SHA1: {1:x}, actual: {2:x}(Rtimage_partsR(R)tfilenamethashlibtsha1topentTruetreadt	euca2oolstBUFSIZEtupdatetwritetflushtintt	hexdigestterrortRuntimeErrorR&(	R+tmanifesttoutfiletparttdigestt	part_filetchunkt
actual_digesttexpected_digest((sF/usr/lib/python2.7/site-packages/euca2ools/commands/bundle/unbundle.pyt__read_bundle_partshs(	



c
Cs“tj|jdd|jdƒ}xƒ|jD]x}tjj|jd|jƒ}x|jdƒrq|d}qUWtjj	|ƒr||_q-t
dj|ƒƒ‚q-Wtƒ\}}t
jd|jd	||fƒ}|jƒ|jƒt|jƒtjj|jd
|jƒ}t|dƒe}tj|d|d|d
|jd|jd|jd|jd|jjdtƒƒ}	|	jƒWdQX|S(NR>tprivkey_filenameRRs./isdbundle part '{0}' does not exist; you may need to use -s to specify where to find the bundle's partsttargetRRtwtdesttenc_keytenc_ivt
image_sizetsha1_digestt
show_progress(Rtread_from_fileobjRR.RR"tjoinR/t
startswithR%R=R&RtmultiprocessingtProcesst_Unbundle__read_bundle_partststarttcloseR	tpidt
image_nameR2R
t
from_otherRKRLRMtimage_digestRtFalsetmain(
R+R>R@t	part_pathtpart_reader_out_rtpart_reader_out_wtpart_readertimage_filenametimagetunbundlestream((sF/usr/lib/python2.7/site-packages/euca2ools/commands/bundle/unbundle.pyR]s:		


		cCs
dG|GHdS(NtWrote((R+Rb((sF/usr/lib/python2.7/site-packages/euca2ools/commands/bundle/unbundle.pytprint_result¦s(
t__name__t
__module__tDESCRIPTIONRtSUITERR2R3tARGSRRUR]Rf(((sF/usr/lib/python2.7/site-packages/euca2ools/commands/bundle/unbundle.pyR,s	)		%(R0RSRtrequestbuilderRtrequestbuilder.commandRtrequestbuilder.exceptionsRtrequestbuilder.mixinsRRteuca2ools.commandsRteuca2ools.bundle.pipesR5teuca2ools.bundle.manifestRteuca2ools.bundle.utilRRR	t(euca2ools.commands.bundle.unbundlestreamR
R(((sF/usr/lib/python2.7/site-packages/euca2ools/commands/bundle/unbundle.pyt<module>s	
Back to Directory File Manager