ó ¡ôXc@s¿ddlZddlmZmZddlmZddlmZddlm Z ddl m Z ddl m Z ddlmZdd lmZdd lmZd ee fd „ƒYZdS( iÿÿÿÿN(tArgtMutuallyExclusiveArgList(t ArgumentError(t EC2Request(tDescribeConversionTasks(t S3AccessMixin(tImportManifest(t DeleteObject(t GetObject(tAWSErrortDeleteDiskImagecBsteZdZeeddddƒeddddƒƒjƒedd d dd ƒgZd „Zd „Zd„Z RS(s+Delete a disk image used for an import tasks-ts--taskthelps'ID of the task to delete the image froms-us--manifest-urlslocation of the import manifests--ignore-active-tasktactiont store_trues^delete the image even if the import task is active (only works with -t/--task)cCsOtj|ƒ|jƒ|jjdƒrK|jjdƒ rKtdƒ‚ndS(Ntignore_active_taskttasks<argument --ignore-active-task my only be used with -t/--task(Rt configuretconfigure_s3_accesstargstgetR(tself((sJ/usr/lib/python2.7/site-packages/euca2ools/commands/ec2/deletediskimage.pyR5s  %c Cs¢|jjdƒr"|jd}n|jjdƒrÃtj|d|jdgƒ}|jƒdd}|d|jdks„t‚|jdƒr |d}n|dd d}|d d }n|jd j|ƒ\}}}d j||fƒ}|j|ƒ} x\| j D]Q} t j|d|jd d|jddd j|| j fƒƒ} | jƒqWt j|d|jd d|jdd|ƒ} | jƒdS(Nt manifest_urlRtConversionTaskIdtconversionTasksitconversionTaskIdt importVolumetimportInstancetvolumestimagetimportManifestUrlt s3_servicet/tservicetauthts3_authtpath( RRRt from_othertmaintAssertionErrortresolve_url_to_locationtjoint#_DeleteDiskImage__download_manifestt image_partsRtkey( RRt desc_convRt vol_containert_tbucketR+tmanifest_s3pathtmanifesttpartt delete_req((sJ/usr/lib/python2.7/site-packages/euca2ools/commands/ec2/deletediskimage.pyR%<s0  (  cCsÂtjddƒª}tj|d|jdd|jdd|d|d tƒ}y|jƒWn=tk r}|jd kr—t d j |ƒƒ‚n‚nX|j d ƒt j |ƒSWdQXdS( Ntmax_sizei R RR!R"tsourcetdestt show_progressi”s$import manifest "{0}" does not existi(ttempfiletSpooledTemporaryFileRR$RtFalseR%R t status_codeRtformattseekRtread_from_fileobj(Rts3pathtmanifest_destfiletget_reqterr((sJ/usr/lib/python2.7/site-packages/euca2ools/commands/ec2/deletediskimage.pyt__download_manifestXs  ( t__name__t __module__t DESCRIPTIONRRtrequiredtARGSRR%R)(((sJ/usr/lib/python2.7/site-packages/euca2ools/commands/ec2/deletediskimage.pyR )s     (R8trequestbuilderRRtrequestbuilder.exceptionsRteuca2ools.commands.ec2Rt.euca2ools.commands.ec2.describeconversiontasksRteuca2ools.commands.ec2.mixinsRt!euca2ools.commands.ec2.structuresRt"euca2ools.commands.s3.deleteobjectRteuca2ools.commands.s3.getobjectRteuca2ools.exceptionsR R (((sJ/usr/lib/python2.7/site-packages/euca2ools/commands/ec2/deletediskimage.pyts