Current File : //usr/lib/python2.7/site-packages/euca2ools/util.pyo
�
��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,		
		
		!