
Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­
<!DOCTYPE html>
<html>
3
\¼meúŽ  ã               @   s`  d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlmZ d dl	m
Z
 d dl	mZ d dl	mZ d dl	mZ d dl	mZ d dl	mZ d d	l	mZ d d
l	mZ d dl	mZ d dl	mZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZmZmZm Z m!Z!m"Z" d dl#m$Z$ d dl%m&Z& d dl'm(Z(m)Z)m*Z*m+Z+ dZ,dZ-e(e)e*dœZ.ej/e0ƒZ1dJdd„Z2dd„ Z3dKdd„Z4dd „ Z5d!d"„ Z6ed#œd$d%„Z7d&d'„ Z8dMd*d+„Z9dNee:e;f d-œd.d/„Z<d0d1„ Z=d2d3„ Z>d4d5„ Z?d6d7„ Z@d8d9„ ZAd:d;„ ZBdOd<d=„ZCejDd>œd?d@„ZEdAdB„ ZFdCdD„ ZGdPdEdF„ZHe0dGk�r\dHejIk�rBdIejIdH< eHejJƒZKeK�r\ejLeKƒ dS )Qé    N)ÚTuple)Únetinfo)Úsignal_handler)Úsources)Ústages)Ú
url_helper)Úutil)Úversion)Úwarnings)Ú	reporting)Úatomic_helper)Úread_cfg_paths)Úcc_set_hostname)ÚModules)Úvalidate_cloudconfig_schema)ÚLogExporterÚsetup_basic_loggingÚsetup_loggingÚreset_loggingÚconfigure_root_loggerÚ
DEPRECATED)Úevents)Úload)ÚPER_INSTANCEÚ
PER_ALWAYSÚPER_ONCEÚCLOUD_CONFIGzOCloud-init v. {version} running '{action}' at {timestamp}. Up {uptime} seconds.zcloud_%s_modules)ÚinstanceÚalwaysÚonceÚ c             C   s^   | rt jjd|  ƒ t jjdd ƒ t jjdƒ tjt jd� t jjdd ƒ t jjdƒ d S )Nz%s
ú-é<   Ú
)Úfile)ÚsysÚstderrÚwriteÚ	tracebackÚ	print_exc)Úmsg© r+   ú/usr/lib/python3.6/main.pyr)   H   s    r)   c              C   s    t jƒ rtjƒ } tjd| ƒ d S )NzPID [%s] started cloud-init.)r   Zis_LinuxÚosÚgetppidÚLOGÚinfo)Zppidr+   r+   r,   Úlog_ppidR   s    r1   c             C   s,   |st | ƒ}tjd| ddtd� tƒ  |S )Nz%s
FT)Zconsoler&   Úlog)Úwelcome_formatr   Z	multi_logr/   r1   )Úactionr*   r+   r+   r,   ÚwelcomeX   s
    r5   c             C   s   t jtjƒ tjƒ tjƒ | d�S )N)r	   ÚuptimeZ	timestampr4   )ÚWELCOME_MSG_TPLÚformatr	   Úversion_stringr   r6   Ztime_rfc2822)r4   r+   r+   r,   r3   `   s
    r3   c             C   s2   g }| j r.x"| j D ]}|jtjj|jƒƒ qW |S )N)ÚfilesÚappendr-   ÚpathÚrealpathÚname)ÚargsZfn_cfgsZfhr+   r+   r,   Úextract_fnsi   s
    r@   )Úmodsc             C   sv   t | }| j|ƒ\}}t|ƒt|ƒ }|dkrXd||f }tjjd| ƒ tj|ƒ g S tjdt|ƒt|ƒƒ |S d S )Nr   z)No '%s' modules to run under section '%s'z%s
zRan %s modules with %s failures)ÚMOD_SECTION_TPLZrun_sectionÚlenr%   r&   r'   r/   Údebug)rA   Úaction_nameZsectionZfull_section_nameÚ	which_ranÚfailuresZtotal_attemptedr*   r+   r+   r,   Úrun_module_sectionv   s    
rH   c             C   s   | j dƒrtj| j dƒƒ d S )Nr   )Úgetr   Zupdate_configuration)Úcfgr+   r+   r,   Úapply_reporting_cfg‰   s    
rK   úcloud-config-urlÚurlc             C   s@   t j| ƒ}x |D ]}||kr||| fS qW td| |f ƒ‚d S )Nz!No keys (%s) found in string '%s')r   Zkeyval_str_to_dictÚKeyError)ÚcmdlineÚnamesÚdataÚkeyr+   r+   r,   Úparse_cmdline_urlŽ   s
    

rS   T)Úreturnc             C   s(  |dkrt jƒ }yt|ƒ\}}W n tk
r:   tjdfS X |jdƒ}|r’tjj	| ƒr’|rxd| |f }tj
}|rŠtj}nd| |f }tj}||fS |ddd	d
œ}|s¨|r¸tj}d|d< ntj}d|d< d}	d}
�ytjf |Ž}d}|jƒ �r´d	}t|tjƒ�rDy|t|jt|
ƒd�ƒ7 }W n tk
�r0   Y nX |j|
ƒ�sVd}n|jj|
ƒ�sVd}|�r‚|dk�r²ttt jdddd	d�ƒfS n0|dk�r”tj}ntj
}|d|› dt|
ƒ› �fS n|d||jf fS ||j }	W n0 tjk
�r } z|d||f fS d}~X nX t j| |	dd� tj
d||| f fS ) a’  Write data from url referenced in command line to path.

    path: a file to write content to if downloaded.
    network: should network access be assumed.
    cmdline: the cmdline to parse for cloud-config-url.

    This is used in MAAS datasource, in "ephemeral" (read-only root)
    environment where the instance netboots to iscsi ro root.
    and the entity that controls the pxe config has to configure
    the maas datasource.

    An attempt is made on network urls even in local datasource
    for case of network set up in initramfs.

    Return value is a tuple of a logger function (logging.DEBUG)
    and a message indicating what happened.
    Nz!No kernel command line url found.úfile://ú/z_file '%s' existed, possibly from local stage download of command line url '%s'. Not re-writing.zafile '%s' existed, possibly from previous boot download of command line url '%s'. Not re-writing.é
   é   T)rM   ZtimeoutZretriesÚstreamé   Zsec_betweengš™™™™™¹?s   #cloud-configó    )Z
chunk_sizeFrM   z!The kernel command line key `url`z22.3zD Please use `cloud-config-url` kernel command line parameter instead)Z
deprecatedZdeprecated_versionZextra_messageZ
return_logzcloud-config-urlzcontents of 'z' did not start with z$url '%s' returned code %s. Ignoring.zretrieving url '%s' failed: %si€  )Úmodez*wrote cloud-config data from %s='%s' to %s)rU   rV   )r   Zget_cmdlinerS   rN   ÚloggingÚDEBUGÚ
startswithr-   r<   ÚexistsÚINFOÚWARNr   Zread_file_or_urlÚokÚ
isinstanceZUrlResponseÚnextZiter_contentrC   ÚStopIterationÚcontentsr   ÚstrZ	deprecateÚcodeZUrlErrorÚ
write_file)r<   ÚnetworkrO   Zcmdline_namerM   Zpath_is_localÚmÚlevelÚkwargsrQ   ÚheaderZrespZsniffed_contentZis_cloud_cfgÚer+   r+   r,   Úattempt_cmdline_url–   s€    






rq   c             C   sš   dt jjt jjf }tjj| jjdƒdƒ}tjj	|ƒrlt
|ƒjƒ }||kr–tjdƒ | jdƒ tj||ƒ n*tjj	| jjdƒƒrŠtjdƒ tj||ƒ dS )	zÊPurge the cache if python version changed on us.

    There could be changes not represented in our cache (obj.pkl) after we
    upgrade to a new version of python, so at that point clear the cache
    z%d.%drQ   zpython-versionz-Python version change detected. Purging cacheTZobj_pklzMWriting python-version file. Cache compatibility status is currently unknown.N)r%   Úversion_infoÚmajorÚminorr-   r<   ÚjoinÚpathsÚ	get_cpathr`   ÚopenÚreadr/   rD   Úpurge_cacher   rj   Úget_ipath_curr0   )ÚinitZcurrent_python_versionZpython_version_pathZcached_python_versionr+   r+   r,   Ú$purge_cache_on_python_version_change  s    

r}   c             C   s   t j| jdƒrdS |j S )NZdisable_network_activationF)r   Úget_cfg_option_boolrJ   Úlocal)r|   r?   r+   r+   r,   Ú_should_bring_up_interfaces&  s    r€   c          -   C   s  t jt jg}|jrt jg}ttjjdt dƒ|j d�g}|jsJt	| ƒ}nt	d|  ƒ}t
j||jd�}|jt|ƒƒ d }d }y.|jtjdfƒ tjƒ  tj|j| ƒ\}}W n< tk
ræ   d}tjt|ƒ t|ƒ |jtj|fƒ Y nX |j�r tjdƒ tƒ  t|jƒ t|jƒ t| |d	� x|D ]\}	}tj |	|ƒ �q&W y|j!ƒ  W n" tk
�rn   tjtd
ƒ Y nX |j"}
t#|ƒ |j�rŒt j$nt j%}|t j%k�r¸d}t&j'j(dt)j*ƒ  ƒ nZd}tj+|jddƒ}|�râtjdƒ d}n(|
j,dƒ}tjj-|ƒ�r
tjd|ƒ d}|j.ƒ  t/||ƒ}yB|j0|d� |t j%k�r\|j1j2|k�r\tjd||j1ƒ d g fS W nˆ t j3k
�ræ   |t j$k�rŠtjdƒ ntjtdƒ |j4�sÖ|j5|d� tjd|ƒ |t j$k�rÊd g fS d dgfS ntjd|ƒ Y nX t6|ƒ |j7ƒ }tjd|| ||j8ƒ ƒ |t j$k�r(t9|ddd� |j5|d� |t j$k�rx|j1j2|k�rhtjd||j1ƒ |j1g fS tjd ||j1ƒ |j:ƒ  |j;ƒ  t9|d!d"d� y2|j<ƒ j=d#|j>t?gt?d$�\}}|�sÆ|j>t@ƒ W n* tk
�rò   tjtd%ƒ |j1d%gfS X |j"j,d&ƒ}tjj-|ƒ�r<tjA|ƒjBd'k�r<tCtDtjE|ƒƒddd(d)� n
tjd*ƒ t|jƒ tF|t|ƒ|jd+�}yR|}|}tjG|j| ƒ\}}||k�s”||k�r´tjHd,||ƒ tj|j| ƒ\}}W n" tk
�rØ   tjtd-ƒ Y nX t|jƒ |jIƒ  tJ|j1|jd.� |j1tK|| | ƒfS )/Nz%s.dz91_kernel_cmdline_url.cfg)r<   rk   z%s-local)Úds_depsÚreporterzClosing stdin.z#Failed to setup output redirection!z@Logging being reset, this logger may no longer be active shortly)r*   z0Failed to initialize, likely bad things to come!Útrustz%s
ZcheckZmanual_cache_cleanFz"manual cache clean set from configZmanual_clean_markerz(manual cache clean found from marker: %s)Úexistingz)[%s] Exiting. datasource %s in local modezNo local datasource foundz8No instance datasource found! Likely bad things to come!)Zbring_upz[%s] Exiting without datasourcezNo instance datasource found.z2[%s] barreling on in force mode without datasourcez5[%s] %s will now be targeting instance id: %s. new=%sr   rk   )ÚstageÚretry_stagez.[%s] Exiting. datasource %s not in local mode.z6[%s] %s is in local mode, will apply init modules now.zinit-netzmodules:configÚconsume_data)r?   ZfreqzConsuming user data failed!Zcloud_configr   T)ÚconfigÚstrictZlog_detailsZlog_deprecationsz2Skipping user-data validation. No user-data found.)r‚   z#Stdout, stderr changing to (%s, %s)z'Failed to re-adjust output redirection!)Ú
datasourcerJ   )Lr   ZDEP_FILESYSTEMZDEP_NETWORKr   rq   r-   r<   ru   r   r3   r   ÚInitr‚   Úread_cfgr@   r;   r]   r^   r   Úclose_stdinÚfixup_outputrJ   Ú	ExceptionÚlogexcr/   r)   rb   rD   r   r   rK   r5   r2   Z
initializerv   r}   ZDSMODE_LOCALZDSMODE_NETWORKr%   r&   r'   r   Z
debug_infor~   r{   r`   rz   r€   ÚfetchrŠ   ZdsmodeÚDataSourceNotFoundExceptionÚforceZapply_network_configÚ_maybe_persist_instance_dataZ
instancifyZis_new_instanceÚ_maybe_set_hostnameZsetup_datasourceÚupdateÚcloudifyZrunr‡   r   r   ÚstatÚst_sizer   r   Ú	load_filer   Zget_output_cfgÚwarningZactivate_datasourceÚdi_report_warnrH   )r>   r?   ZdepsZ
early_logsÚw_msgr|   ZoutfmtZerrfmtr*   ZlvlZpath_helperr\   r„   ZmcfgZmfileZbring_up_interfacesZiidZranZ_resultsZcloud_cfg_pathrA   Zoutfmt_origZerrfmt_origr+   r+   r,   Ú	main_init,  s
   








 



rž   c             C   sü   d|krt jdƒ d S |d }|d kr4t jdƒ d S t|tƒsNt jd|ƒ d S |jdƒ}|d krnt jdƒ d S t|tƒsˆt jd|ƒ d S | jjdƒd	 }|j	t
jƒr¸|tt
jƒd … }nt jd
| |ƒ ||krât jd| ||ƒ d S tjd||t|ƒd� d S )NZ	di_reportzno di_report found in config.zdi_report was None.z%di_report config not a dictionary: %sZdatasource_listz(no 'datasource_list' found in di_report.z(di_report/datasource_list not a list: %sÚ.rX   z1Datasource '%s' came from unexpected module '%s'.z:used datasource '%s' from '%s' was in di_report's list: %sZdsid_missing_source)ÚsourceÚdslist)r/   rD   rd   Údictr›   rI   ÚlistÚ
__module__Ú
rpartitionr_   r   Z	DS_PREFIXrC   r
   Zshow_warningrh   )rŠ   rJ   Zdicfgr¡   Úmodnamer+   r+   r,   rœ     sB    





rœ   c             C   s(  |j }td| |f ƒ}tjg |jd�}|jt|ƒƒ y|jdd� W n> tj	k
r‚   d| }t
jt|ƒ t|ƒ |js~|gS Y nX t|ƒ t|t|ƒ|jd�}y$tjdƒ t
jƒ  t
j|j|ƒ W n  tk
rä   t
jtdƒ Y nX |jrütjd	ƒ tƒ  t|jƒ t|jƒ t||d
� t|||ƒS )Nz%s:%s)r�   r‚   rƒ   )r„   zGCan not apply stage %s, no datasource found! Likely bad things to come!)r‚   zClosing stdinz#Failed to setup output redirection!z@Logging being reset, this logger may no longer be active shortly)r*   )r\   r3   r   r‹   r‚   rŒ   r@   r‘   r   r’   r   r�   r/   r)   r“   r”   r   rD   r�   rŽ   rJ   r�   r   r   rK   r5   rH   )rE   r?   r>   r�   r|   r*   rA   r+   r+   r,   Úmain_modules>  s:    


r§   c       
      C   sŠ  |j }t| ƒ}tjg |jd�}|jt|ƒƒ y|jdd� W n4 tj	k
rp   t
jtdƒ tdƒ |jsldS Y nX t|ƒ t|t|ƒ|jd�}|j}|r¤tjd|ƒ |j}|rÄtjd|ƒ tj|ƒ}y$tjd	ƒ t
jƒ  t
j|jd ƒ W n" tk
�r
   t
jtd
ƒ Y nX |j�r$tjdƒ tƒ  t|jƒ t|jƒ t| |d� |j|||ƒ\}}	|	�rltjd|ƒ dS |�s‚tjd|ƒ dS dS d S )N)r�   r‚   rƒ   )r„   z;Failed to fetch your datasource, likely bad things to come!rZ   )r‚   zUsing passed in arguments %szUsing passed in frequency %szClosing stdinz#Failed to setup output redirection!z@Logging being reset, this logger may no longer be active shortly)r*   zRan %s but it failed!zDid not run %s, does it exist?r   ) r>   r3   r   r‹   r‚   rŒ   r@   r‘   r   r’   r   r�   r/   r)   r“   r”   r   Úmodule_argsrD   Z	frequencyÚFREQ_SHORT_NAMESrI   r�   rŽ   rJ   r�   r   r   rK   r5   Z
run_singler›   )
r>   r?   Zmod_namer�   r|   rA   Zmod_argsZmod_freqrF   rG   r+   r+   r,   Úmain_singleu  sV    	




rª   c             C   s`  |d krt ƒ }|jdƒ}|d kr,tjjdƒ}tjj|dƒ}tjj|dƒ}tjj|dƒ}tjj|dƒ}tjƒ }	tj	||fƒ |j
\}
}| dkrž|jr˜d}q¾d}n | dkr²d|j }ntd	|  ƒ‚d}||krØtdj|ƒƒ‚d }|dk�rxL||||fD ]}tj|ƒ qôW n,ytjtj|ƒƒ}W n tk
�r2   Y nX g d d dœ}|d k�r^di i}d |d d< x,|D ]$}||d k�rd|jƒ |d |< �qdW |d }||d< tjƒ || d< ttdd„ |	jƒƒjƒ || d< tj||ƒ tjtjj||ƒ|dd� yR|| |ƒ}|d k�r(|\}}|d k	�r,t|ƒ|d< n|}dd„ |D ƒ|| d< W nP tk
�r” } z2tjt d|ƒ t!d| ƒ t|ƒg|| d< W Y d d }~X nX tjƒ || d< d |d< ttdd„ |	jƒƒjƒ || d< tj||ƒ |dk�rPg }x2|D ]*}|| d �rî|j"|| j#dg ƒƒ �qîW tj|d|d |dœiƒ tjtjj||ƒ|dd� t$|| d ƒS )!NrQ   z/run/cloud-initzstatus.jsonzresult.jsonr|   ú
init-localÚmodulesz
modules-%szunknown name: %súmodules-configúmodules-finalz'Invalid cloud init mode specified '{0}')ÚerrorsÚstartÚfinishedÚv1rŠ   r…   r°   c             S   s
   t | tƒS )N)rd   r   )Úhr+   r+   r,   Ú<lambda>  s    z status_wrapper.<locals>.<lambda>Zrecoverable_errorsT)r“   c             S   s   g | ]}t |ƒ‘qS r+   )rh   )Ú.0rp   r+   r+   r,   ú
<listcomp>  s    z"status_wrapper.<locals>.<listcomp>r¯   zfailed stage %szfailed run of stage %sr±   c             S   s
   t | tƒS )N)rd   r   )r³   r+   r+   r,   r´   !  s    )rŠ   r¯   )r|   r«   r­   r®   )r|   r«   )%r   rw   r-   r<   Únormpathru   r]   Ú	getLoggerr   Zensure_dirsr4   r   r\   Ú
ValueErrorr8   Zdel_fileÚjsonÚloadsrš   r�   ÚcopyÚtimere   ÚfilterZhandlersZexport_logsr   Z
write_jsonZsym_linkÚrelpathrh   r�   r/   r)   ÚextendrI   rC   )r>   r?   Zdata_dZlink_drv   Zstatus_pathZstatus_linkZresult_pathZresult_linkZroot_loggerÚ_nameÚfunctorr\   ZmodesÚstatusÚfZ
nullstatusrl   r²   ÚretrŠ   r¯   rp   r+   r+   r,   Ústatus_wrapper¼  s¢    

   





$

rÆ   )r|   c             C   s6   | j r2| jr2| jjdƒ}tjj|ƒs2| j jdd� dS )zCWrite instance-data.json file if absent and datasource is restored.Zinstance_dataF)Zwrite_cacheN)rŠ   Zds_restoredrv   Zget_runpathr-   r<   r`   Zpersist_instance_data)r|   Zinstance_data_filer+   r+   r,   r”   7  s    r”   c             C   sx   | j ƒ }tj| j|dd�\}}}|rtytjd| j|dƒ W n8 tjk
rr } ztjd||t	|ƒƒ W Y dd}~X nX dS )zâCall set_hostname if metadata, vendordata or userdata provides it.

    @param stage: String representing current stage in which we are running.
    @param retry_stage: String represented logs upon error setting hostname.
    T)Zmetadata_onlyZset_hostnameNzGFailed setting hostname in %s stage. Will retry in %s stage. Error: %s.)
r—   r   Zget_hostname_fqdnrJ   r   ZhandleZSetHostnameErrorr/   rD   rh   )r|   r…   r†   ZcloudZhostnameZ_fqdnÚ_rp   r+   r+   r,   r•   ?  s    r•   c             C   s    t jjdjttjƒƒd ƒ d S )Nr#   )r%   Ústdoutr'   ru   Úsortedr	   ZFEATURES)r>   r?   r+   r+   r,   Úmain_featuresV  s    rÊ   c       "      C   s˜  t ƒ  | stj} tj| jdƒd�}|jddddtjƒ  dd� |jd	d
dddtj	dƒd� |jdddddd� |jdddddd� |j
d d� |jddd�}d|_|jdd d!�}|jd"d#dd$dd� |j
dtfd%� |jd&d'd!�}|jd(d)d*d+d,dcd.� |j
d&tfd%� |jd/d0d!�}|jd1d2d*d3dd4� |jd5d*d6dttjƒ ƒd7� |jd8dd9dd4� |jd:d;d<d=d>� |j
d/tfd%� |jd?d@d!�}|jdAdBd!�}|j
dAtfd%� |jdCdDd!�}|jdEdFd!�}	|jdGdHd!�}
|jdIdJd!�}|jdKdLd!�}|jdMdNd!�}| �rN| d }|dCk�r*ddOlm} ||ƒ �n$|dEk�rLddOlm} ||	ƒ �n|dGk�r€ddPlm}m} ||
ƒ |
j
dG|fd%� nÎ|dIk�r´ddQlm}m} ||ƒ |j
dI|fd%� nš|d?k�rèddRlm}m} ||ƒ |j
dS|fd%� nf|dMk�rddTlm}m} ||ƒ |j
dM|fd%� n2|dKk�rNddUl m}m!} ||ƒ |j
dK|fd%� |j"| dV�}|j#\}}|ddk�rˆt$|j%�r~t&j'nt&j(ƒ n|j%�r–t$ƒ  t)j*ƒ  d|k�s¾d&|k�rÂd|j+k�rÂt,}d }d}|dk�rð|j-�ræde\}} ndf\}} nZ|d&k�rd[|j+ d\|j+  }} n8|d/k�r:d]|j. d^|j.  }} |j/}n|}d_| } d}t0j1|| |d`�|_2|j2�$ t3j4t5j%da| d|||fdb�}!W d Q R X t6j7ƒ  |!S )gNr   )Úprogz	--versionz-vr	   z	%(prog)s z'Show program's version number and exit.)r4   r	   Úhelpz--filez-fr;   r:   z(Use additional yaml configuration files.Úrb)r4   ÚdestrÌ   Útypez--debugz-dÚ
store_truez:Show additional pre-action logging (default: %(default)s).F)r4   rÌ   Údefaultz--forcezDForce running even if no datasource is found (use at your own risk).r“   )r4   rÌ   rÎ   rÑ   )r‚   ZSubcommandsÚ
subcommand)ÚtitlerÎ   Tr|   z2Initialize cloud-init and perform initial modules.)rÌ   z--localz-lz+Start in local mode (default: %(default)s).)r4   r¬   z1Activate modules using a given configuration key.z--modez-mZstorez8Module configuration name to use (default: %(default)s).rˆ   Úfinal)r4   rÌ   rÑ   ÚchoicesZsinglezRun a single module.z--namez-nzModule name to run.)r4   rÌ   Úrequiredz--frequencyzModule frequency for this run.)r4   rÌ   rÖ   rÕ   z--reportzEnable reporting.r¨   Ú*Zargumentz0Any additional arguments to pass to this module.)ÚnargsÚmetavarrÌ   Zqueryz;Query standardized instance metadata from the command line.ZfeatureszList defined features.Zanalyzez-Devel tool: Analyze cloud-init logs and data.ZdevelzRun development tools.zcollect-logsz*Collect and tar all cloud-init debug info.Zcleanz3Remove logs and artifacts so cloud-init can re-run.rÃ   z/Report cloud-init status or wait on completion.Zschemaz-Validate cloud-config files using jsonschema.)Ú
get_parser)rÚ   Úhandle_collect_logs_args)rÚ   Úhandle_clean_args)rÚ   Úhandle_argsZrender)rÚ   Úhandle_schema_args)rÚ   Úhandle_status_args)r?   ú
init-localúsearching for local datasourcesúinit-networkú!searching for network datasourcesz
modules-%szrunning modules for %sz	single/%szrunning single module %szrunning 'cloud-init %s')Zreporting_enabledzcloud-init mode '%s')Zlogfuncr*   Z
get_uptimeÚfuncr?   )r|   rˆ   rÔ   )r|   r¬   )rà   rá   )râ   rã   )8r   r%   ÚargvÚargparseÚArgumentParserÚpopÚadd_argumentr	   r9   ZFileTypeZset_defaultsZadd_subparsersrÖ   Z
add_parserrž   r§   r£   r©   Úkeysrª   rÊ   Zcloudinit.analyzerÚ   Zcloudinit.cmd.devel.parserZcloudinit.cmd.devel.logsrÛ   Zcloudinit.cmd.cleanrÜ   Zcloudinit.cmd.queryrÝ   Úcloudinit.config.schemarÞ   Zcloudinit.cmd.statusrß   Ú
parse_argsr4   r   rD   r]   r^   ZWARNINGr   Zattach_handlersr\   rÆ   r   r>   Zreportr   ZReportEventStackr‚   r   Zlog_timer/   r   Zflush_events)"Z	sysv_argsÚparserZ
subparsersZparser_initZ
parser_modZparser_singleZparser_queryZparser_featuresZparser_analyzeZparser_develZparser_collect_logsZparser_cleanZparser_statusZparser_schemarÒ   Zanalyze_parserZdevel_parserZlogs_parserrÛ   Zclean_parserrÜ   Zquery_parserZhandle_query_argsZschema_parserrÞ   Zstatus_parserrß   r?   r>   rÂ   ZrnameZ	report_onZrdescZretvalr+   r+   r,   ÚmainZ  s@   



















 

 


rî   Ú__main__ZTZz:/etc/localtime)r    )N©rL   rM   )rð   )TN)NN)N)Mræ   rº   r-   r%   r½   r(   r]   Ztypingr   Z	cloudinitr   r   r   r   r   r   r	   r
   r   r   Zcloudinit.cmd.develr   Zcloudinit.configr   Zcloudinit.config.modulesr   rë   r   Zcloudinit.logr   r   r   r   r   r   Zcloudinit.reportingr   Zcloudinit.safeyamlr   Zcloudinit.settingsr   r   r   r   r7   rB   r©   r¸   Ú__name__r/   r)   r1   r5   r3   r@   rH   rK   rS   Úintrh   rq   r}   r€   rž   rœ   r§   rª   rÆ   r‹   r”   r•   rÊ   rî   Úenvironrå   Zreturn_valueÚexitr+   r+   r+   r,   Ú<module>   sx    



	
r a27G
{
  


