Viewing File: /usr/lib/python2.7/site-packages/euca2ools/util.pyc

ó
¡ôXc@sddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
ZddlZddl
Zd„Zdddd„Zd„Zd„Zd„Zd	„Zd
„Zdd„Zd„Zd
„Zd„ZdS(iÿÿÿÿNcCs€t|ƒdkrdSt|ƒdkr,dStd„|Dƒƒ}d}|jd|dttt|ƒƒƒdt|ƒƒSdS(	Niis{fname}css'|]}ttjj|ƒƒVqdS(N(tlentostpathtbasename(t.0tfname((s2/usr/lib/python2.7/site-packages/euca2ools/util.pys	<genexpr>0ss1{{fname:<{maxlen}}} ({{index:>{lenlen}}}/{total})tmaxlentlenlenttotal(RtNonetmaxtformattstr(tfnamest
max_fname_lentfmt_template((s2/usr/lib/python2.7/site-packages/euca2ools/util.pyt build_progressbar_label_template*stttmpc
Cs^|dkrBtjdƒp<tjdƒp<tjdƒp<d}ntjd|d|d|ƒS(	s¯
    Like tempfile.mkdtemp, but using /var/tmp as a last resort instead of /tmp.

    This is meant for utilities that create large files, as /tmp is often a
    ramdisk.
    tTMPDIRtTEMPtTMPs/var/tmptsuffixtprefixtdirN(R	Rtgetenvttempfiletmkdtemp(RRR((s2/usr/lib/python2.7/site-packages/euca2ools/util.pytmkdtemp_for_large_files8s-	cCsUtjddƒ}tjddƒ}||kr4|StjddtjƒtƒSdS(NtpromptsNew password: sRetype new password: serror: passwords do not matchtfile(tgetpasstsixtprint_tsyststderrtprompt_for_password(tpass1tpass2((s2/usr/lib/python2.7/site-packages/euca2ools/util.pyR$GscCsQg|D]}|dkr|^q}t|ƒdkrI||dpHiS|SdS(NtResponseMetadataii(R(t
response_dicttkeytuseful_keys((s2/usr/lib/python2.7/site-packages/euca2ools/util.pytstrip_response_metadataQs%cCssigd6}x_|pgD]Q}tjjƒjdƒ}i|d6|d6|d6|d6}|dj|ƒqW|S(Nt	StatementsStmt%Y%m%d%H%M%S%ftSidtEffecttActiontResource(tdatetimetutcnowtstrftimetappend(teffectt	resourcestactionstpolicytresourcetsidt	statement((s2/usr/lib/python2.7/site-packages/euca2ools/util.pytbuild_iam_policyYs

cCsÈtj|ƒj}tj|ƒrdtj|tjƒ}ztj|dtjƒSWdtj|ƒXnTt	tj
|ƒtj|ƒtj|ƒtj
|ƒfƒr¸tdj|ƒƒ‚ntjj|ƒS(Nis&'{0}' does not have a usable file size(Rtstattst_modetS_ISBLKtopentO_RDONLYtlseektSEEK_ENDtclosetanytS_ISCHRtS_ISFIFOtS_ISSOCKtS_ISDIRt	TypeErrorRRtgetsize(tfilenametmodetblock_fd((s2/usr/lib/python2.7/site-packages/euca2ools/util.pytget_filesizecs'	cCsut|ƒdkr*tdj|ƒƒ‚nt|dƒd}tjd|jdƒƒ}|dd@dkr™|jd	d
ƒtjd|jdƒƒ}nWdQXd|dkrÇtdj|ƒƒ‚n|d
d
@dkrótdj|ƒƒ‚n|d
d@dkrtdj|ƒƒ‚n|drAtdj|ƒƒ‚n|ddkritdj|ƒƒ‚nd|dS(Nis8File {0} is to small to be a valid Stream Optimized VMDKtrbs<iiiqqqqiqqq?bbbbh433cii	lÿÿÿÿiiüÿÿiiKDMVs'File {0} is not a Stream Optimized VMDKis*File {0} does not contain compressed partsis'File {0} does not have all data presentis%File {0} marked with unclean shutdowniis/File {0} uses unsupported compression algorithmi(ROt
ValueErrorRR@tstructtunpacktreadtseek(RLtdisktdata((s2/usr/lib/python2.7/site-packages/euca2ools/util.pytget_vmdk_image_sizets0	$			
		cCszt|tƒs'tdj|ƒƒ‚n|rvt|jƒƒt|ƒ}|rvtdj|dj|ƒƒƒ‚qvndS(Ns{0} must be a dicts!unrecognized {0} argument(s): {1}s, (t
isinstancetdictRQRtsettkeystjoin(tdict_terr_contextt	whitelisttdifferences((s2/usr/lib/python2.7/site-packages/euca2ools/util.pytcheck_dict_whitelist•s	cCsNi}xA|jƒD]3\}}||kr<||||<q|||<qW|S(N(t	iteritems(R^ttransformation_dictttransformedR)tval((s2/usr/lib/python2.7/site-packages/euca2ools/util.pyttransform_dictŸscCsT|jdkrPtjdƒrPdjtjƒƒ|_|jjd|jƒndS(sˆ
    If no name for a region is otherwise defined (i.e. service.region_name
    is None and the AWS_AUTH_REGION environment variable is not set),
    log a notice and add a fake region name so HmacV4Auth has something
    to work with.  This works because eucalyptus doesn't care what name
    one chooses for a region.

    Setups that use eucarc files against AWS will still be broken.
    tAWS_AUTH_REGIONs
undefined-{0}sadded fake region name %sN(tregion_nameR	RRRtgetpidtlogtnotice(tservice((s2/usr/lib/python2.7/site-packages/euca2ools/util.pytadd_fake_region_name©scCsÌidd6dd6}x±tjtjjtjjdƒD]\}}}t|ddƒ}xitj|ƒD]X\}}tj	|ƒrhtj
|ƒ|krht|tj
jƒrh|j||j<qhqhWq7W|S(sˆ
    Generate a dict with keys for each service and values for those
    services' corresponding URL environment variables, if any.
    tEUCA_PROPERTIES_URLt
propertiestEUCA_REPORTING_URLt	reportingt.tfromlisttdummy(tpkgutiltiter_modulest	euca2oolstcommandst__path__t__name__t
__import__tinspectt
getmemberstisclasst	getmodulet
issubclasstrequestbuilderRmtBaseServicet
URL_ENVVARtNAME(tservicest_tmodnametmoduletobj((s2/usr/lib/python2.7/site-packages/euca2ools/util.pytgenerate_service_names¹s

	)$(R1RR}tos.pathRRvR=RRR"Rtrequestbuilder.serviceR‚R teuca2ools.commandsRxRR	RR$R+R<RORXRbRgRnR‹(((s2/usr/lib/python2.7/site-packages/euca2ools/util.pyt<module>s,		
		
		!
	
	
Back to Directory File Manager