U
    b}  ã                   @   s¸   U d Z ddlZddlmZ ddlmZ ddlmZmZm	Z	 ddl
mZmZ ddlmZ ddlmZ ed	gƒZd
ZdddeegeedƒgdœZeed< eeƒZ dd„ Zdd„ Zdd„ ZdS )z<Debug: Helper to debug cloud-init *internal* datastructures.é    N)ÚStringIO)Údedent)ÚsafeyamlÚ
type_utilsÚutil)Ú
MetaSchemaÚget_meta_doc)ÚALL_DISTROS)ÚPER_INSTANCEZlog_cfgsa	  This module will enable for outputting various internal information that
cloud-init sources provide to either a file or to the output console/log
location that this cloud-init has been configured with when running.

.. note::
    Log configurations are not output.
Zcc_debugZDebugz4Helper to debug cloud-init *internal* datastructureszc            debug:
              verbose: true
              output: /tmp/my_debug.log
            )ÚidÚnameÚtitleZdescriptionZdistrosZ	frequencyZexamplesÚmetac                 C   sR   t ƒ }| d¡ | d¡ | |  dd¡¡ | d¡ | d¡ | d¡ | ¡ S )NzP--------------------------------------------------------------------------------Ú
éP   ú )r   ÚwriteÚcenterÚgetvalue)ÚtextÚheader© r   ú;/usr/lib/python3/dist-packages/cloudinit/config/cc_debug.pyÚ_make_header0   s    




r   c                 C   s   t j| ddd�}| ¡ S )NF)Zexplicit_startZexplicit_end)r   ÚdumpsÚrstrip)Úobjr   r   r   r   Ú_dumps;   s    r   c                 C   sÈ  t j|ddd�}|r"|d }d}nt  |d¡}|sB| d| ¡ dS t |¡}tD ]}| |d¡ qPt|ƒ}	|	D ]}| d¡rn| |d¡ qnt	ƒ }
|
 
td	ƒ¡ |
 
t|ƒ¡ |
 
d
¡ |
 
tdƒ¡ |
 
t|jjƒ¡ |
 
d
¡ |
 
tdƒ¡ |
 
dt |j¡ ¡ |
 
dt |j¡ ¡ |
 
d| d¡ ¡ |
 
d| ¡  ¡ |
 
d| ¡  ¡ |
 
d|j ¡ |
 ¡ }g }| ¡ D ]}d| }| |¡ �qv|�r®t  |d |¡dd¡ nt jd |¡ddd� dS )z'Handler method activated by cloud-init.)ÚdebugÚverboseT)Údefaultr   )r   Úoutputz3Skipping module named %s, verbose printing disabledNÚ_ZConfigr   ZMetaDataZMisczDatasource: %s
zDistro: %s
zHostname: %s
zInstance ID: %s
zLocale: %s
zLaunch IDX: %s
zci-info: %s
Ú i¤  ÚwF)ZconsoleÚstderr)r   Zget_cfg_by_pathr   ÚcopyÚdeepcopyÚ	SKIP_KEYSÚpopÚlistÚ
startswithr   r   r   r   Z
datasourceZmetadatar   Zobj_nameZdistroZget_hostnameZget_instance_idZ
get_localeZlaunch_indexr   Ú
splitlinesÚappendZ
write_fileÚjoinZ	multi_log)r   ZcfgZcloudÚlogÚargsr   Zout_fileZdump_cfgÚkZall_keysZto_printÚcontentsZcontent_to_fileÚliner   r   r   Úhandle@   sN    



ÿr4   )Ú__doc__r&   Úior   Útextwrapr   Z	cloudinitr   r   r   Zcloudinit.config.schemar   r   Zcloudinit.distrosr	   Zcloudinit.settingsr
   Ú	frozensetr(   ZMODULE_DESCRIPTIONr   Ú__annotations__r   r   r4   r   r   r   r   Ú<module>   s0   

ÿÿù