404

[ Avaa Bypassed ]




Upload:

Command:

elspacio@18.119.19.206: ~ $
3

\�me�A�@sddlZddlZddlZddlmZmZmZddlmZddl	m	Z	ddl
mZmZm
Z
ddlmZmZmZmZeje�ZGdd�de�ZGd	d
�d
�ZGdd�d�ZGd
d�d�Zdd�ZGdd�d�ZGdd�d�ZGdd�d�ZGdd�d�ZGdd�dej �Z!Gdd�de�Z"dS)�N)�
NoOptionError�NoSectionError�RawConfigParser)�StringIO)�time)�persistence�
type_utils�util)�CFG_ENV_NAME�
PER_ALWAYS�PER_INSTANCE�PER_ONCEc@seZdZdS)�LockFailureN)�__name__�
__module__�__qualname__�rr�/usr/lib/python3.6/helpers.pyrsrc@seZdZdS)�	DummyLockN)rrrrrrrrsrc@s4eZdZdd�Zejddd��Zdd�Zdd	�Zd
S)�DummySemaphorescCsdS)Nr)�selfrrr�__init__!szDummySemaphores.__init__Fccst�VdS)N)r)r�_name�_freqZ_clear_on_failrrr�lock$szDummySemaphores.lockcCsdS)NFr)rrrrrr�has_run(szDummySemaphores.has_runcCsdS)NTr)rrrrrr�clear+szDummySemaphores.clearN)F)	rrrr�
contextlib�contextmanagerrrrrrrrr s
rc@seZdZdd�Zdd�ZdS)�FileLockcCs
||_dS)N)�fn)rr rrrr0szFileLock.__init__cCsdtj|�|jfS)Nz<%s using file %r>)rZobj_namer )rrrr�__str__3szFileLock.__str__N)rrrrr!rrrrr/srcCs|jdd�S)N�-�_)�replace)�namerrr�canon_sem_name7sr&c@sDeZdZdd�Zejddd��Zdd�Zdd	�Zd
d�Z	dd
�Z
dS)�FileSemaphorescCs
||_dS)N)�sem_path)rr(rrrr<szFileSemaphores.__init__FccsFt|�}y|j||�VWn&tk
r@|r:|j||��YnXdS)N)r&�_acquire�	Exceptionr)rr%�freq�
clear_on_failrrrr?szFileSemaphores.lockcCsNt|�}|j||�}ytj|�Wn&ttfk
rHtjtd|�dSXdS)NzFailed deleting semaphore %sFT)r&�	_get_pathr	Zdel_file�IOError�OSError�logexc�LOG)rr%r+�sem_filerrrrIszFileSemaphores.clearcCsn|j||�rdS|j||�}dtj�t�f}ytj||�Wn&ttfk
rdtj	t
d|�dSXt|�S)Nz%s: %s
z Failed writing semaphore file %s)rr-�os�getpidrr	Z
write_filer.r/r0r1r)rr%r+r2�contentsrrrr)SszFileSemaphores._acquirecCsh|s|tkrdSt|�}|j||�}tjj|�r6dS||krdtjj|j||��rdtjd||�dSdS)NFTz�%s has run without canonicalized name [%s].
likely the migrator has not yet run. It will run next boot.
run manually with: cloud-init single --name=migrator)rr&r-r3�path�existsr1�warning)rr%r+Zcnamer2rrrrcszFileSemaphores.has_runcCs<|j}|s|tkr"tjj||�Stjj|d||f�SdS)Nz%s.%s)r(rr3r6�join)rr%r+r(rrrr-}szFileSemaphores._get_pathN)F)rrrrrrrrr)rr-rrrrr';s	
r'c@s&eZdZdd�Zdd�Zd	dd�ZdS)
�RunnerscCs||_i|_dS)N)�paths�sems)rr;rrrr�szRunners.__init__cCsj|tks|rdSd}|tkr,|jjd�}n|tkr@|jjd�}|sHdS||jkr`t|�|j|<|j|S)N�sem)rrr;�	get_ipathr
�	get_cpathr<r')rr+r(rrr�_get_sem�s
zRunners._get_semNFc	Cs�|j|�}|st�}|sg}|j||�r:tjd||�dS|j|||��L}|s\td|��n4tjd||�t|t�r�|f|�}n||�}d|fSWdQRXdS)Nz%s already ran (freq=%s)FzFailed to acquire lock for %szRunning %s using lock (%s)T)FN)	r@rrr1�debugrr�
isinstance�dict)	rr%Zfunctor�argsr+r,r=Zlk�resultsrrr�run�s 

zRunners.run)NF)rrrrr@rFrrrrr:�sr:c@sHeZdZddd�Zdd�Zdd�Zd	d
�Zed�dd
�Ze	dd��Z
dS)�ConfigMergerNTcCs(||_||_||_||_||_d|_dS)N)�_paths�_ds�_fns�	_base_cfg�_include_vendor�_cfg)rr;�
datasourceZadditional_fnsZbase_cfgZinclude_vendorrrrr�szConfigMerger.__init__cCsZg}|jrVy&|jj�}|r.t|t�r.|j|�Wn$tk
rTtjtd|j�YnX|S)Nz2Failed loading of datasource config object from %s)	rIZget_config_objrBrC�appendr*r	r0r1)rZd_cfgsZds_cfgrrr�_get_datasource_configs�s
z$ConfigMerger._get_datasource_configscCsTg}ttjkrPtjt}y|jtj|��Wn"tk
rNtjtd|�YnX|S)Nz%Failed loading of env. config from %s)	r
r3�environrOr	�	read_confr*r0r1)rZe_cfgsZe_fnrrr�_get_env_configs�s

zConfigMerger._get_env_configscCs�g}|js|Sdg}|jr.|jd�|jd�x~|D]v}|jj|�}|r4tjj|�r4y|jtj|��Wq4t	k
r�t
jd|�Yq4tk
r�tj
t
d|�Yq4Xq4W|S)N�cloud_config�vendor2_cloud_config�vendor_cloud_configz5Skipped loading cloud-config from %s due to non-root.z&Failed loading of cloud-config from %s)rHrLrO�
get_ipath_curr3r6�isfiler	rR�PermissionErrorr1rAr*r0)rZi_cfgsZcc_pathsZcc_pZcc_fnrrr�_get_instance_configs�s(



z"ConfigMerger._get_instance_configs)�returncCs�g}|jrRxF|jD]<}y|jtj|��Wqtk
rLtjtd|�YqXqW|j|j��|j|j	��|j|j
��|jr�|j|j�tj|�S)Nz'Failed loading of configuration from %s)
rJrOr	rRr*r0r1�extendrSrZrPrKZ
mergemanydict)r�cfgsZc_fnrrr�	_read_cfg�szConfigMerger._read_cfgcCs|jdkr|j�|_|jS)N)rMr^)rrrr�cfgs

zConfigMerger.cfg)NNNNT)rrrrrPrSrZrCr^�propertyr_rrrrrG�s


 rGc@sFeZdZdd�Zdd�Zdd�Zdd�Zddd�Zd
d�Zdd�Z	dS)�ContentHandlerscCsi|_g|_dS)N)�
registered�initialized)rrrrrszContentHandlers.__init__cCs
|j|�S)N)�
is_registered)r�itemrrr�__contains__!szContentHandlers.__contains__cCs
|j|�S)N)�_get_handler)r�keyrrr�__getitem__$szContentHandlers.__getitem__cCs
||jkS)N)rb)r�content_typerrrrd'szContentHandlers.is_registeredFTcCsrt�}x4|j�D](}|r$|j|�q|j|�s|j|�qWx|D]}||j|<qBW|rn||jkrn|jj|�|S)N)�setZ
list_types�addrdrbrcrO)r�modrcZ	overwrite�types�trrr�register*s

zContentHandlers.registercCs
|j|S)N)rb)rrjrrrrg8szContentHandlers._get_handlercCst|jj��S)N)�listrb�items)rrrrrr;szContentHandlers.itemsN)FT)
rrrrrfrirdrprgrrrrrrras
rac@sreZdZdZded�dd�Zedd�dd�Zdd	d
�Zddd�Z	dd
d�Z
ddd�Zded�dd�Z
ddd�ZdS)�Paths�N)�	path_cfgscCs�||_|jdd�|_|jdd�|_tjj|jd�|_tjj|jd�|_tjj|jd�|_	|jdd	�}tjj|d
�|_
ddd
ddddddddddddddddddd d!d"�|_||_dS)#N�	cloud_dirz/var/lib/cloud�run_dirz/run/cloud-init�instancez
boot-finishedZseedZ
templates_dirz/etc/cloud/templates/z%s.tmpl�	boothookszcloud-config.txt�data�handlerszinstance-data.jsonzinstance-data-sensitive.jsonzcombined-cloud-config.jsonznetwork-config.jsonz.instance-idzmanual-cleanzobj.pkl�scriptsr=zuser-data.txt.iz
user-data.txtzvendor-data.txt.izvendor-data2.txt.izvendor-data2.txtzvendor-data.txtzvendor2-cloud-config.txtzvendor-cloud-config.txtzscripts/vendor�warnings)ryrTrzr{�
instance_data�instance_data_sensitive�combined_cloud_configZnetwork_configZinstance_idZmanual_clean_markerZobj_pklr|r=ZuserdataZuserdata_rawZ
vendordataZvendordata2Zvendordata2_rawZvendordata_rawrUrVZvendor_scriptsr})
r]�getrvrwr3r6r9�
instance_linkZ
boot_finishedZseed_dirZtemplate_tpl�lookupsrN)rru�dsZtemplate_dirrrrrBsD
zPaths.__init__)�ci_pkl_versionr[cCs^t|d�st|j|jd�j|_d|jkr2d|jd<d|jkrFd|jd<d|jkrZd|jd<d	S)
z(Perform deserialization fixes for Paths.rw)rur�r~zinstance-data.jsonrzinstance-data-sensitive.jsonr�zcombined-cloud-config.jsonN)�hasattrrsr]rNrwr�)rr�rrr�	_unpicklers





zPaths._unpicklecCs|j|j|�S)N)r-r�)rr%rrrrW�szPaths.get_ipath_curcCs|j|j|�S)N)r-rv)rr%rrrr?�szPaths.get_cpathcCsf|js
dS|jj�}|dkr dSt|�jtjd�}tjj|jd|�}|j	j
|�}|rbtjj||�}|S)Nr#Z	instances)rNZget_instance_id�strr$r3�sepr6r9rvr�r�)rr%ZiidZ
path_safe_iid�ipathZadd_onrrr�
_get_ipath�s
zPaths._get_ipathcCs$|j|�}|stjd�dS|SdS)Nz?No per instance data available, is there an datasource/iid set?)r�r1r8)rr%r�rrrr>�s
zPaths.get_ipath)�basecCs |dkr|Stjj||j|�S)N)r3r6r9r�)rr�r%rrrr-�szPaths._get_pathcCs|j|j|�S)N)r-rw)rr%rrr�get_runpath�szPaths.get_runpath)N)N)N)N)N)N)N)rrrZ_ci_pkl_versionrCr�intr�rWr?r�r>r�r-r�rrrrrs?s0



rsc@sXeZdZdZdZdZdZdd�Zddd�Zd	d
�Z	dd�Z
d
d�Zdd�Zddd�Z
dS)�DefaultingConfigParserrgFNcCsD|j}ytj|||�}Wn&tk
r,Yntk
r>YnX|S)N)�DEF_BASErr�rr)r�section�option�valuerrrr��szDefaultingConfigParser.getcCs6|j|�r"|j�dkr"|j|�tj||||�dS)N�default)Zhas_section�lowerZadd_sectionrrk)rr�r�r�rrrrk�s
zDefaultingConfigParser.setcCs|j||�rtj|||�dS)N)�
has_optionr�
remove_option)rr�r�rrrr��sz$DefaultingConfigParser.remove_optioncCs |j||�s|jStj|||�S)N)r��DEF_BOOLEANr�
getboolean)rr�r�rrrr��sz!DefaultingConfigParser.getbooleancCs |j||�s|jStj|||�S)N)r��	DEF_FLOATr�getfloat)rr�r�rrrr��szDefaultingConfigParser.getfloatcCs |j||�s|jStj|||�S)N)r��DEF_INTr�getint)rr�r�rrrr��szDefaultingConfigParser.getintcCs<d}t�}|j|�|j�|j�}|r8dj||dg�}|S)N��
)r�write�flush�getvaluer9)r�headerr5Zoutputstreamrrr�	stringify�s
z DefaultingConfigParser.stringify)N)N)rrrr�r�r�r�r�rkr�r�r�r�r�rrrrr��s

r�)#rZloggingr3Zconfigparserrrr�iorrZ	cloudinitrrr	Zcloudinit.settingsr
rrr
Z	getLoggerrr1r*rrrrr&r'r:rGraZCloudInitPickleMixinrsr�rrrr�<module>s(
J-j#

Filemanager

Name Type Size Permission Actions
__init__.cpython-36.opt-1.pyc File 113 B 0644
__init__.cpython-36.pyc File 113 B 0644
apport.cpython-36.opt-1.pyc File 5.92 KB 0644
apport.cpython-36.pyc File 5.96 KB 0644
atomic_helper.cpython-36.opt-1.pyc File 2.05 KB 0644
atomic_helper.cpython-36.pyc File 2.05 KB 0644
cloud.cpython-36.opt-1.pyc File 3.08 KB 0644
cloud.cpython-36.pyc File 3.08 KB 0644
dmi.cpython-36.opt-1.pyc File 5.32 KB 0644
dmi.cpython-36.pyc File 5.32 KB 0644
event.cpython-36.opt-1.pyc File 1.97 KB 0644
event.cpython-36.pyc File 1.97 KB 0644
features.cpython-36.opt-1.pyc File 1.47 KB 0644
features.cpython-36.pyc File 1.47 KB 0644
gpg.cpython-36.opt-1.pyc File 3.76 KB 0644
gpg.cpython-36.pyc File 3.76 KB 0644
helpers.cpython-36.opt-1.pyc File 13.31 KB 0644
helpers.cpython-36.pyc File 13.31 KB 0644
importer.cpython-36.opt-1.pyc File 1.68 KB 0644
importer.cpython-36.pyc File 1.68 KB 0644
log.cpython-36.opt-1.pyc File 4.61 KB 0644
log.cpython-36.pyc File 4.61 KB 0644
netinfo.cpython-36.opt-1.pyc File 12.67 KB 0644
netinfo.cpython-36.pyc File 12.67 KB 0644
persistence.cpython-36.opt-1.pyc File 2.82 KB 0644
persistence.cpython-36.pyc File 2.82 KB 0644
registry.cpython-36.opt-1.pyc File 1.38 KB 0644
registry.cpython-36.pyc File 1.38 KB 0644
safeyaml.cpython-36.opt-1.pyc File 8 KB 0644
safeyaml.cpython-36.pyc File 8 KB 0644
settings.cpython-36.opt-1.pyc File 1.14 KB 0644
settings.cpython-36.pyc File 1.14 KB 0644
signal_handler.cpython-36.opt-1.pyc File 1.58 KB 0644
signal_handler.cpython-36.pyc File 1.58 KB 0644
simpletable.cpython-36.opt-1.pyc File 2.53 KB 0644
simpletable.cpython-36.pyc File 2.53 KB 0644
ssh_util.cpython-36.opt-1.pyc File 15.36 KB 0644
ssh_util.cpython-36.pyc File 15.36 KB 0644
stages.cpython-36.opt-1.pyc File 25.15 KB 0644
stages.cpython-36.pyc File 25.15 KB 0644
subp.cpython-36.opt-1.pyc File 9.97 KB 0644
subp.cpython-36.pyc File 9.97 KB 0644
temp_utils.cpython-36.opt-1.pyc File 2.81 KB 0644
temp_utils.cpython-36.pyc File 2.81 KB 0644
templater.cpython-36.opt-1.pyc File 4.55 KB 0644
templater.cpython-36.pyc File 4.55 KB 0644
type_utils.cpython-36.opt-1.pyc File 437 B 0644
type_utils.cpython-36.pyc File 437 B 0644
url_helper.cpython-36.opt-1.pyc File 21.03 KB 0644
url_helper.cpython-36.pyc File 21.03 KB 0644
user_data.cpython-36.opt-1.pyc File 8.25 KB 0644
user_data.cpython-36.pyc File 8.25 KB 0644
util.cpython-36.opt-1.pyc File 73.64 KB 0644
util.cpython-36.pyc File 73.64 KB 0644
version.cpython-36.opt-1.pyc File 429 B 0644
version.cpython-36.pyc File 429 B 0644
warnings.cpython-36.opt-1.pyc File 3.25 KB 0644
warnings.cpython-36.pyc File 3.25 KB 0644