o
    x[h
  ã                
   @   s¶   U d Z ddlZddlmZmZ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 eZd
egeg dœZeed< e e¡ZdZdede	dededdf
dd„ZdS )z@Final Message: Output final message when cloud-init has finishedé    N)Ú	templaterÚutilÚversion)ÚCloud)ÚConfig)Ú
MetaSchema)ÚALL_DISTROS)Úlog_util)Ú
PER_ALWAYSÚcc_final_message)ÚidÚdistrosÚ	frequencyÚactivate_by_schema_keysÚmetazy## template: jinja
Cloud-init v. {{version}} finished at {{timestamp}}. Datasource {{datasource}}.  Up {{uptime}} secondsÚnameÚcfgÚcloudÚargsÚreturnc              
   C   sv  d}|rt |d ƒ}nt |dd¡}| ¡ }|st}t ¡ }t ¡ }t ¡ }z)|||t |j	ƒdœ}| 
tdd„ | ¡ D ƒƒ¡ tjdt ||¡ dd	td
� W n* tjyk }	 zt tdt |	ƒ¡ W Y d }	~	nd }	~	w tyy   t td¡ Y nw |jj}
zd|||f }tj|
|dd� W n tyŸ   t td|
¡ Y nw |j	jdkr·|j	j d¡dgkr¹t d¡ d S d S d S )NÚ r   Úfinal_message)ÚuptimeÚ	timestampr   Ú
datasourcec                 S   s   g | ]
\}}|  ¡ |f‘qS © )Úupper)Ú.0ÚkÚvr   r   úC/usr/lib/python3/dist-packages/cloudinit/config/cc_final_message.pyÚ
<listcomp><   s    zhandle.<locals>.<listcomp>z%s
FT)ÚconsoleÚstderrÚlogz,Failed to render templated final message: %sz'Failed to render final message templatez%s - %s - v. %s
)Úensure_dir_existsz%Failed to write boot finished file %sÚNoneÚdatasource_listzUsed fallback datasource)Ústrr   Úget_cfg_option_strÚstripÚFINAL_MESSAGE_DEFr   Útime_rfc2822r   Úversion_stringr   ÚupdateÚdictÚitemsr	   Ú	multi_logr   Úrender_stringÚLOGÚJinjaSyntaxParsingExceptionÚlogexcÚ	ExceptionÚpathsÚboot_finishedÚ
write_fileÚdsnameÚsys_cfgÚgetÚwarning)r   r   r   r   Úmsg_inr   ÚtsÚcverÚsubsÚeÚboot_fin_fnÚcontentsr   r   r    Úhandle&   sV   ü
ü
ÿ€ÿÿþrE   )Ú__doc__ÚloggingÚ	cloudinitr   r   r   Úcloudinit.cloudr   Úcloudinit.configr   Úcloudinit.config.schemar   Úcloudinit.distrosr   Úcloudinit.logr	   Úcloudinit.settingsr
   r   r   Ú__annotations__Ú	getLoggerÚ__name__r3   r+   r(   ÚlistrE   r   r   r   r    Ú<module>   s&   ü
ÿ"