�
oB�]c@s�dZddlZddlmZddlmZddlmZddlmZedg�Z d�Z
d �Zd
�ZdS(sQ
Debug
-----
**Summary:** helper to debug cloud-init *internal* datastructures.
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.
**Internal name:** ``cc_debug``
**Module frequency:** per instance
**Supported distros:** all
**Config keys**::
debug:
verbose: true/false (defaulting to true)
output: (location to write output, defaulting to console + log)
i����N(tStringIO(t
type_utils(tutil(tsafeyamltlog_cfgscCsut�}|jdd�|jd�|j|jdd��|jd�|jdd�|jd�|j�S(Nt-iPs
t (Rtwritetcentertgetvalue(ttexttheader((s=/usr/lib/python2.7/site-packages/cloudinit/config/cc_debug.pyt_make_header)s
cCs%tj|dtdt�}|j�S(Ntexplicit_starttexplicit_end(RtdumpstFalsetrstrip(tobjR
((s=/usr/lib/python2.7/site-packages/cloudinit/config/cc_debug.pyt_dumps4scCsxtj|ddt�}|r1|d}t}ntj|d�}|s]|jd|�dStj|�}xtD]}|j|d�qsWt |�} x0| D](}|j
d�r�|j|d�q�q�Wt�}
|
jt
d ��|
jt|��|
jd
�|
jt
d��|
jt|jj��|
jd
�|
jt
d��|
jd
tj|j��|
jdtj|j��|
jd|jt��|
jd|j��|
jd|j��|
jd|j�|
j�}g}x+|j�D]}
d|
}
|j|
�q W|rRtj|dj|�dd�n"tjdj|�dtdt�dS(s'Handler method activated by cloud-init.tdebugtverbosetdefaultitoutputs3Skipping module named %s, verbose printing disabledNt_tConfigs
tMetaDatatMiscsDatasource: %s
sDistro: %s
s
Hostname: %s
sInstance ID: %s
sLocale: %s
sLaunch IDX: %s
sci-info: %s
ti�twtconsoletstderr(sdebugsverbose(sdebugsoutput(Rtget_cfg_by_pathtTrueRtcopytdeepcopyt SKIP_KEYStpoptNonetlistt
startswithRRRRt
datasourcetmetadataRtobj_nametdistrotget_hostnametget_instance_idt
get_localetlaunch_indexR t
splitlinestappendt
write_filetjoint multi_logR(tnametcfgtcloudtlogtargsRtout_filetdump_cfgtktall_keystto_printtcontentstcontent_to_filetline((s=/usr/lib/python2.7/site-packages/cloudinit/config/cc_debug.pythandle9sN
"(
t__doc__R"tsixRt cloudinitRRRt frozensetR$RRRC(((s=/usr/lib/python2.7/site-packages/cloudinit/config/cc_debug.pyt<module>s |