HOME


Mini Shell 1.0
DIR: /usr/lib/python3/dist-packages/cloudinit/cmd/__pycache__/
Upload File :
Current File : //usr/lib/python3/dist-packages/cloudinit/cmd/__pycache__/main.cpython-312.pyc
�

\�`fڐ���ddlZddlZddlZddlZddlZddlZddlZddlmZddl	m
Z
ddl	mZddl	mZddl	m
Z
ddl	mZddl	mZdd	l	mZdd
l	mZddl	mZddl	mZdd
lmZddlmZddlmZddlmZddl	mZddlmZddlm Z ddl!m"Z"m#Z#m$Z$m%Z%dZ&dZ'e"e#e$d�Z(ejRe*�Z+d2d�Z,d�Z-d3d�Z.d�Z/d�Z0defd�Z1d�Z2d4d �Z3d5d!ee4e5ffd"�Z6d#�Z7d$�Z8d%�Z9d&�Z:d'�Z;d(�Z<d6d)�Z=d*e
j|fd+�Z?d,�Z@d-�ZAd3d.�ZBe*d/k(rEd0ej�vrd1ej�d0<eBej��ZEeErej�eE�yyy)7�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)�log)�events)�load)�PER_INSTANCE�
PER_ALWAYS�PER_ONCE�CLOUD_CONFIGzOCloud-init v. {version} running '{action}' at {timestamp}. Up {uptime} seconds.zcloud_%s_modules)�instance�always�oncec��|r"tjjd|z�tjjd�tjjd�tjtj��tjjd�tjjd�y)N�%s
z<------------------------------------------------------------�
)�file)�sys�stderr�write�	traceback�	print_exc��msgs �4/usr/lib/python3/dist-packages/cloudinit/cmd/main.pyr$r$Asu��
��
�
����3��(��J�J���X���J�J���T��
���S�Z�Z�(��J�J���X���J�J���T��c��tj�r+tj�}tjd|�yy)NzPID [%s] started cloud-init.)r	�is_Linux�os�getppid�LOG�info)�ppids r'�log_ppidr0Ks*���}�}���z�z�|�����/��6�r(c�t�|st|�}tjd|zddt��t	�|S)NrFT)�consoler!r)�welcome_formatr	�	multi_logr-r0)�actionr&s  r'�welcomer6Qs/����V�$���N�N�6�S�>�5��3�G��J��Jr(c��tjtj�t	j
�t	j�|��S)N)r
�uptime�	timestampr5)�WELCOME_MSG_TPL�formatr
�version_stringr	r8�time_rfc2822�r5s r'r3r3Ys>���!�!��&�&�(��{�{�}��#�#�%��	"��r(c��g}|jrI|jD]:}|jtjj	|j
���<|S�N)�files�appendr+�path�realpath�name)�args�fn_cfgs�fhs   r'�extract_fnsrIbsK���G��z�z��*�*�	6�B�
�N�N�2�7�7�+�+�B�G�G�4�5�	6��Nr(�modsc�N�t|z}|j|�\}}t|�t|�z}|dk(rBd|�d|�d�}tjjd|z�tj|�gStjdt|�t|��|S)NrzNo 'z ' modules to run under section '�'rzRan %s modules with %s failures)�MOD_SECTION_TPL�run_section�lenr r!r"r-�debug)rJ�action_name�section�full_section_name�	which_ran�failures�total_attemptedr&s        r'�run_module_sectionrWos���'�7�3�� �,�,�->�?��Y���)�n�s�8�}�4�O��!����
��	�
�
����3��(��	�	�#���	��	�	�-�s�9�~�s�8�}�	
��r(c�p�|jd�r%tj|jd��yy)Nr)�getr�update_configuration)�cfgs r'�apply_reporting_cfgr\�s*��
�w�w�{���&�&�s�w�w�{�';�<�r(c�x�tj|�}|D]}||vs�|||fcStd|�d|�d���)Nz	No keys (z) found in string 'rL)r	�keyval_str_to_dict�KeyError)�cmdline�names�data�keys    r'�parse_cmdline_urlrd�sH���"�"�7�+�D��"���$�;���S�	�>�!�"��'�5�I�
J�Jr(�returnc	�B�|�tj�}	t|�\}}|j
d�}|rmtjj|�rN|r/d|�d|�d�}tj}|rtj
}||fSd|�d|�d�}tj}||fS|dd	d
d�}|s|rtj}d|d
<ntj
}d|d
<d}	d}
	tjd%i|��}d}|j�r�d
}
t|tj �r<	|t#|j%t'|
����z
}|j
|
�s d}
n|j*j
|
�sd}
|
r7|dk(r�t,j.t1tj2dddd
���fS|dk(rtj}ntj}|d|�dt1|
���fS|d|�d|j4�d�fS||j*z}	tj8||	d �!�tjd"|�d#|�d$|��fS#t$rtj
dfcYSwxYw#t($rY��'wxYw#tj6$r}|d|�d|��fcYd}~Sd}~wwxYw)&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.)zfile://�/zfile 'zC' existed, possibly from local stage download of command line url 'z'. Not re-writing.zE' existed, possibly from previous boot download of command line url '�
�T)�url�timeout�retries�stream��sec_betweeng�������?s
#cloud-configr()�
chunk_sizeFrjz!The kernel command line key `url`z22.3zD Please use `cloud-config-url` kernel command line parameter instead)�
deprecated�deprecated_version�
extra_message�
return_log�cloud-config-urlz
contents of 'z' did not start with zurl 'z' returned code z. Ignoring.zretrieving url 'z
' failed: i�)�modezwrote cloud-config data from z='z' to �)r	�get_cmdlinerdr_�logging�DEBUG�
startswithr+rC�exists�INFO�WARNr�read_file_or_url�ok�
isinstance�UrlResponse�next�iter_contentrO�
StopIteration�contentsr�
DEPRECATED�str�	deprecate�code�UrlError�
write_file)rC�networkr`�cmdline_namerj�
path_is_local�m�level�kwargsrb�header�resp�sniffed_content�is_cloud_cfg�es               r'�attempt_cmdline_urlr��s���&���"�"�$��D�-�g�6���c��N�N�#3�4�M��������-��AE�c�K�
��L�L�E���
�
���q�z���AE�c�K�
��L�L�E��q�z���R�A��
F�F��-����� !��}���
�
�� #��}���D�
�F�/D��*�*�4�V�4�����7�7�9��L��$�
� 6� 6�7��#�t��)�)�S��[�)�A�(��O�
'�1�1�&�9�#(�L��]�]�-�-�f�5�$����5�(����� �N�N�+N�39�/H�+/����� �#5�5�#�L�L�E�#�L�L�E��#�C�5�(=�c�&�k�]�K����:=�t�y�y�I��
�����.��
	�O�O�D�$�U�+������d�	$����g�D��
�
�B�C�C�D��V%�����H���D��3��B�C�C��D�sg�I�!AI7�%'I'�A)I7�68I7�/I7�I7�I$�#I$�'	I4�0I7�3I4�4I7�7J�
	J�J�Jc��dtjjtjjfz}tj
j
|jjd�d�}tj
j|�r\t|�j�}||k7r=tjd�|jd�tj ||�yytj
j|jj#d��rtj%d�tj ||�y)	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.%drbzpython-versionz-Python version change detected. Purging cacheT�obj_pklzMWriting python-version file. Cache compatibility status is currently unknown.N)r �version_info�major�minorr+rC�join�paths�	get_cpathr|�open�readr-rP�purge_cacher	r��
get_ipath_curr.)�init�current_python_version�python_version_path�cached_python_versions    r'�$purge_cache_on_python_version_changer�s��%�����������(����'�'�,�,��
�
���V�$�&6���
�w�w�~�~�)�*� $�%8� 9� >� >� @��!�$:�:��I�I�E�F����T�"��O�O�/�1G�H�;�
�7�7�>�>�$�*�*�2�2�9�=�>��H�H�C�
�	
���+�-C�Dr(c�^�tj|jd�ry|jS)N�disable_network_activationF)r	�get_cfg_option_boolr[�local)r�rFs  r'�_should_bring_up_interfacesr�s&��������*F�G���z�z�>�r(c�l�tjtjg}|jrtjg}t	t
jjdtzd�|j��g}|jst|�}ntd|z�}tj||j��}|jt|��d}d}	|jt j"df�t%j&�t%j(|j*|�\}}|j6r)t0j7d�t9j:�t9j<|j*�t?|j*�tA||�	�|D]\}	}t0j9|	|��	|jC�|jD}
tG|�|jrtjHntjJ}|tjJk(r7d}tLjNjQdtSjT�z�n�d
}t%jV|j*dd�}
|
rt0j7d�d}nH|
jYd�}t
jj[|�rt0j7d|�d}|j]�t_||�}	|ja|��|tjJk(r>|jbjd|k7r%t0j7d||jb�dgfStm|�|jo�}t0j7d||||jq��|tjHk(rts|dd��|jk|��|tjHk(ri|jbjd|k7r/t0j7d||jb�|jbgfSt0j7d ||jb�|ju�|jw�ts|d!d"��	|jy�j{d#|j|t~gt~�$�\}}|s|j}t��|jDjYd&�}t
jj[|�rNtj�|�j�d'k7r,t�t�t%j�|��ddd(�)�nt0j7d*�t?|j*�t�|t|�|j�+�}	|}|}t%j�|j*|�\}}||k7s||k7r:t0j�d,||�t%j(|j*|�\}}t9j<|j*�|j��t�|jb|j*�.�|jbt�|||�fS#t,$rLd}t%j.t0|�t3|�|jt j4|f�Y���wxYw#t,$rt%j.t0d
�Y��(wxYw#tjf$r�|tjHk(rt0j7d�nt%j.t0d�|jhsH|jk|��t0j7d|�|tjHk(rdgfcYSddgfcYSt0j7d|�Y��]wxYw#t,$r,t%j.t0d%�|jbd%gfcYSwxYw#t,$rt%j.t0d-�Y��wxYw)/Nz%s.dz91_kernel_cmdline_url.cfg)rCr�z%s-local��ds_deps�reporterzClosing stdin.�#Failed to setup output redirection!�@Logging being reset, this logger may no longer be active shortlyr%z0Failed to initialize, likely bad things to come!�trustr�check�manual_cache_cleanFz"manual cache clean set from config�manual_clean_markerz(manual cache clean found from marker: %s��existingz)[%s] Exiting. datasource %s in local modezNo local datasource foundz8No instance datasource found! Likely bad things to come!)�bring_upz[%s] Exiting without datasourcezNo instance datasource found.z2[%s] barreling on in force mode without datasourcez5[%s] %s will now be targeting instance id: %s. new=%sr�r�)�stage�retry_stagez.[%s] Exiting. datasource %s not in local mode.z6[%s] %s is in local mode, will apply init modules now.zinit-netzmodules:config�consume_data)rF�freqzConsuming user data failed!�cloud_configrT)�config�strict�log_details�log_deprecationsz2Skipping user-data validation. No user-data found.�r�z#Stdout, stderr changing to (%s, %s)z'Failed to re-adjust output redirection!)�
datasourcer[)Lr�DEP_FILESYSTEM�DEP_NETWORKr�r�r+rCr�rr3r�Initr��read_cfgrIrBryrzr	�close_stdin�fixup_outputr[�	Exception�logexcr-r$r~rPr�
reset_logging�
setup_loggingr\r6�
initializer�r��DSMODE_LOCAL�DSMODE_NETWORKr r!r"r�
debug_infor�r�r|r�r��fetchr��dsmode�DataSourceNotFoundException�force�apply_network_config�_maybe_persist_instance_data�
instancify�is_new_instance�_maybe_set_hostname�setup_datasource�update�cloudify�runr�rr�stat�st_sizerr�load_text_filer�get_output_cfg�warning�activate_datasource�di_report_warnrW)rErF�deps�
early_logs�w_msgr��outfmt�errfmtr&�lvl�path_helperrvr��mcfg�mfile�bring_up_interfaces�iid�ran�_results�cloud_cfg_pathrJ�outfmt_orig�errfmt_origs                       r'�	main_initr�%s����"�"�G�$7�$7�8�D��z�z��&�&�'��	��������%�'B���
�
�N�		
��J�,�:�:��t�$���z�T�2�3���;�;�t�d�m�m�<�D��M�M�+�d�#�$�
�F�
�F�/����7�=�=�*:�;�<������,�,�T�X�X�t�<�����z�z��	�	�N�	
�	�������d�h�h������!�
�D�e������S�����S���M������*�*�K�(��.�#'�:�:�7���7�3I�3I�D��w�%�%�%����
�
����7�#5�#5�#7�8�9����'�'����2F��N����I�I�:�;��H��-�-�.C�D�E��w�w�~�~�e�$��	�	�D�e�L�"������6�d�D�A����
�
�H�
�%��7�)�)�)�d�o�o�.D�.D��.L��I�I�;�����
�
�"�:��.!��&�
�/�/�
�C��I�I�?����������w�#�#�#�	�D��Y�G����':��;��w�#�#�#��?�?�!�!�T�)��I�I�@�����
�
�O�O�R�(�(��I�I�H�����
�	�����K�K�M���J�<L�M�B��-�-�/�-�-��������	.�
���h��
���j�)��Z�Z�-�-�n�=�N�	�w�w�~�~�n�%�"�'�'�.�*A�*I�*I�Q�*N�#���+�+�N�;�<���!�		
�	�	�	�F�G�����!��4��T�*�T�]�]�C�D�D������.�.�t�x�x��>�����&� �K�6�$9��K�K�=�v�v�N�#�0�0����4�@��V�V����d�h�h��	�����d�o�o�4�8�8�<�
�O�O�/��d�D�A�B�B��i�/�3�����C����#�����7�<�<��-�.�	/��4�M����C�K�L�M��J�.�.���7�'�'�'��I�I�1�2��K�K��O�
��z�z��%�%�/B�%�C��I�I�7��>��w�+�+�+��b�z�!��>�?�@�@��I�I�D�d�
�%��^�B����C�6�7����"?�!@�A�A�B��8�D����C�B�C�D�sl�"AZ�[#�A"\
�A_�7A+`�A[ �[ �##\
�	\
�
B!_�0_�7_�_�2`	�`	�#`3�2`3c��d|vrtjd�y|d}|�tjd�yt|t�stj	d|�y|jd�}|�tj	d�yt|t�stj	d|�y|jjd�d	}|jtj�r|ttj�d}ntj	d
||�||vrtjd|||�ytjd||t|��
�y)N�	di_reportzno di_report found in config.zdi_report was None.z%di_report config not a dictionary: %s�datasource_listz(no 'datasource_list' found in di_report.z(di_report/datasource_list not a list: %s�.riz1Datasource '%s' came from unexpected module '%s'.z:used datasource '%s' from '%s' was in di_report's list: %s�dsid_missing_source)�source�dslist)r-rPr��dictr�rY�list�
__module__�
rpartitionr{r�	DS_PREFIXrOr�show_warningr�)r�r[�dicfgr�modnames     r'r�r�s7���#���	�	�1�2�����E��}�	�	�	�'�(���e�T�"����;�U�C��
�Y�Y�(�
)�F�
�~����>�?��
���
%����>��G���#�#�.�.�s�3�A�6�G����'�+�+�,��#�g�/�/�0�2�3�����?���	
��&���	�	�H����		
�	�����s�7�3�v�;�r(c���|j}t|�d|���}tjg|j��}|jt
|��	|jd��t|�t!|t
|�|j��}	tj#d�tj$�tj&|j(|�|j"r)tj#d	�t-j.�t-j0|j(�t3|j(�t5||�
�t7|||�S#tj$r?d|z}tjt|�t|�|js|gcYSY��JwxYw#t*$rtjtd�Y��wxYw)N�:r�r�r�zGCan not apply stage %s, no datasource found! Likely bad things to come!r��
Closing stdinr�r�r%)rvr3rr�r�r�rIr�rr�r	r�r-r$r�r�rrPr�r�r[r�rr�r�r\r6rW)rQrFrEr�r�r&rJs       r'�main_modulesr7s}���9�9�D�
�k�4�8�9�E��;�;�r�D�M�M�:�D��M�M�+�d�#�$���
�
�G�
�$�!��&��4��T�*�T�]�]�C�D�@��	�	�/�"��������$�(�(�D�)��z�z��	�	�N�	
�	�������d�h�h������!��D�e���d�D�$�/�/��C�.�.�	�
� $�
%�	�	
���C����#���z�z��7�N��	��$�@����C�>�?�@�s&�E$�A	F9�$AF6�5F6�9#G�Gc���|j}t|�}tjg|j��}|jt
|��	|jd��t|�t!|t
|�|j��}|j"}|rtj%d|�|j&}|r+tj%d|�t(j+|�}	tj%d	�tj,�tj.|j0d�|j$r)tj%d�t5j6�t5j8|j0�t;|j0�t=||��|j?|||�\}}	|	rtjAd
|�y|stjAd|�yy#tj$r7tjtd�td�|jsYyY���wxYw#t2$rtjtd
�Y��2wxYw)Nr�r�r�z;Failed to fetch your datasource, likely bad things to come!rnr�zUsing passed in arguments %szUsing passed in frequency %srr�r�r%zRan %s but it failed!zDid not run %s, does it exist?r)!rEr3rr�r�r�rIr�rr�r	r�r-r$r�r�r�module_argsrP�	frequency�FREQ_SHORT_NAMESrYr�r�r[r�rr�r�r\r6�
run_singler�)
rErF�mod_namer�r�rJ�mod_args�mod_freqrTrUs
          r'�main_singlerns����y�y�H��4� �E��;�;�r�D�M�M�:�D��M�M�+�d�#�$�
��
�
�G�
�$�!��&��4��T�*�T�]�]�C�D����H���	�	�0�(�;��~�~�H���	�	�0�(�;�#�'�'��1��@��	�	�/�"��������$�(�(�D�)��z�z��	�	�N�	
�	�������d�h�h������!��D�e��!�O�O�H�h��I��Y������+�X�6��
����4�h�?����g�.�.��	
����N�	
�	�I�	
��z�z�����6�@����C�>�?�@�s&�G8�0A	I�8AI�I�#I,�+I,c�l�|�t�}|jd�}|�tjj	d�}tjj|d�}tjj|d�}tjj|d�}tjj|d�}t
j�}	tj||f�|j\}
}|dk(r|jrd}n&d}n#|dk(rd|jz}ntd	|z��d
}
||
vrtdj|���d}|dk(r!||||fD]}tj|��n)	t!j"tj$|��}gddd�}|�d
ii}d|d
d<|
D] }||d
vs�|j)�|d
|<�"|d
}||d<t+j*�||d<t-t/d�|	j0��j3�||d<t5j6||�tj8tjj;||�|d��	|||�}|dvr|\}}|�t=|�|d<n|}|D�cgc]
}t=|���c}||d<t+j*�||d<d|d<t-t/d�|	j0��j3�||d<t5j6||�|dk(r�g}|
D]/}||ds�|jE||jGdg���1t5j6|d
|d|d�i�tj8tjj;||�|d��tI||d�S#t&$rY��7wxYwcc}w#t&$rF}tj>t@d|�tCd|z�t=|�g||d<Yd}~��hd}~wwxYw)Nrbz/run/cloud-initzstatus.jsonzresult.jsonr��
init-local�modules�
modules-%szunknown name: %s)r�rzmodules-config�
modules-finalz'Invalid cloud init mode specified '{0}')�errors�start�finished�v1r�r�rc�6�t|tj�Sr@�r�r�LogExporter��hs r'�<lambda>z status_wrapper.<locals>.<lambda>�����A�s���7�r(�recoverable_errorsT)r�)r�rrzfailed stage %szfailed run of stage %src�6�t|tj�Sr@r r"s r'r$z status_wrapper.<locals>.<lambda>r%r(r)r�r)%rr�r+rC�normpathr�ry�	getLoggerr	�ensure_dirsr5r�rv�
ValueErrorr;�del_file�json�loadsr�r��copy�timer��filter�handlers�export_logsr
�
write_json�sym_link�relpathr�r�r-r$�extendrYrO)rErF�data_d�link_dr��status_path�status_link�result_path�result_link�root_logger�_name�functorrv�modes�status�f�
nullstatusr�r�retr�rr�s                       r'�status_wrapperrF�s��
�~�� ������(��
�~����!�!�"3�4���'�'�,�,�v�}�5�K��'�'�,�,�v�}�5�K��'�'�,�,�v�}�5�K��'�'�,�,�v�}�5�K��#�#�%�K������	
���{�{��U�G��v�~��:�:��D��D�	
��	��d�i�i�'���+�d�2�3�3�
�E��5���5�<�<�T�B�
�	
��F��|���{�K��E�	�A��M�M�!��	�	��Z�Z�� 3� 3�K� @�A�F�
����J��~�����%)��t��\�"�
�0���F�4�L� �(�o�o�/�F�4�L��O�0�
���B��B�w�K��	�	��B�t�H�W��%)��7��9M�9M�N�&��k�m��t�H�
!�"�
���[�&�1��M�M�
������V�,�k���&��d�D�!���)�)�#&� �Z���%�#&�z�?��<� ��F�.4�5��c�!�f�5��4���� �9�9�;�B�t�H�Z���B�w�K�&*��7��9M�9M�N�&��k�m��t�H�
!�"����[�&�1�������	7�A��!�u�X���
�
�b��e�i�i��"�5�6�	7�	� � ��
�"�\�"2�f�E�F�	
�	
�
�
��G�G�O�O�K��0�+�T�	
��r�$�x��!�"�"��M�	��	��N6���&����C�*�D�1��*�T�1�2�!�!�f�X��4�����&�s<�<(O�)O$�+O�=	O$�	O�O�O$�$	P3�-;P.�.P3r�c���|jre|jrX|jjd�}tj
j
|�s|jjd��yyyy)zCWrite instance-data.json file if absent and datasource is restored.�
instance_dataF)�write_cacheN)r��ds_restoredr��get_runpathr+rCr|�persist_instance_data)r��instance_data_files  r'r�r�0sX�����4�+�+�!�Z�Z�3�3�O�D���w�w�~�~�0�1��O�O�1�1�e�1�D�2�,�r(c	�>�|j�}tj|j|d��\}}}|r$	t	j
d|j|d�yy#tj$r+}tjd||t|��Yd}~yd}~wwxYw)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)�
metadata_only�set_hostnameNzGFailed setting hostname in %s stage. Will retry in %s stage. Error: %s.)
r�r	�get_hostname_fqdnr[r�handle�SetHostnameErrorr-rPr�)r�r�r��cloud�hostname�_fqdn�_r�s        r'r�r�8s���
�M�M�O�E��1�1����%�t���X�u�a��		��"�"�>�4�8�8�U�D�I����/�/�	��I�I�1����A��
�
��	�s�"A�B�1!B�Bc��tjjdjt	t
j��dz�y)Nr)r �stdoutr"r��sortedr
�FEATURES)rErFs  r'�
main_featuresr\Os-���J�J���T�Y�Y�v�g�&6�&6�7�8�4�?�@r(c
���tj�|stj}t	j
|j
d���}|jddddtj�zd��|jd	d
ddd
��|jddddd
��|jd��|jdd��}d|_|jdd��}|jddddd
��|jddd d!d"t	jd#��$�|jdtf�%�|jd&d'��}|jd(d)d*d+d,d-�.�|jddd d!d"t	jd#��$�|jd&t f�%�|jd/d0��}|jd1d2d*d3d�4�|jd5d*d6d
t#t$j'���7�|jd8dd9d
�4�|jd:d;d<d=�>�|jddd d!d"t	jd#��$�|jd/t(f�%�|jd?d@��}|jdAdB��}|jdAt*f�%�|jdCdD��}|jdEdF��}	|jdGdH��}
|jdIdJ��}|jdKdL��}|jdMdN��}
|�rt-dO�|D�d�}|dCk(rddPlm}||�n�|dEk(rddPlm}||	�n�|dGk(r%ddQlm}m}||
�|
jdG|f�%�n�|dIk(r%ddRlm}m}||�|jdI|f�%�n}|d?k(r%ddSlm}m}||�|jdT|f�%�nS|dMk(r%ddUl m}m!}||
�|
jdM|f�%�n)|dKk(r$ddVl"m}m#}||�|jdK|f�%�|jI|�W�}|jJ\}}|dXvr@tjL|jNrtPjRntPjT�n |jNrtjL�tWjX�d|k(sd&|k(rd|jZk7rt\}d}d}|dk(r|j^rdY\}} ncdZ\}} n]|d&k(rd[|jZzd\|jZz} }n9|d/k(r+d]|j`zd^|j`z} }|jb}n	|}d_|z} d
}tejf|| |�`�|_4|jh5tkjltnjNda|zd|||f�b�}!ddd�tqjr�!S#1swY�xYw)cNr)�progz	--versionz-vr
z	%(prog)s z'Show program's version number and exit.)r5r
�helpz--debugz-d�
store_truez:Show additional pre-action logging (default: %(default)s).F)r5r_�defaultz--forcezDForce running even if no datasource is found (use at your own risk).r�)r5r_�destrar��Subcommands�
subcommand)�titlerbTr�z2Initialize cloud-init and perform initial modules.)r_z--localz-lz+Start in local mode (default: %(default)s).z--filez-frBrAz(Use additional yaml configuration files.�rb)r5rbr_�typer>rz1Activate modules using a given configuration key.z--modez-m�storez8Module configuration name to use (default: %(default)s).r�)r�r��final)r5r_ra�choices�singlezRun a single module.z--namez-nzModule name to run.)r5r_�requiredz--frequencyzModule frequency for this run.)r5r_rlrjz--reportzEnable reporting.r�*�argumentz0Any additional arguments to pass to this module.)�nargs�metavarr_�queryz;Query standardized instance metadata from the command line.�featureszList defined features.�analyzez-Devel tool: Analyze cloud-init logs and data.�develzRun development tools.zcollect-logsz*Collect and tar all cloud-init debug info.�cleanz3Remove logs and artifacts so cloud-init can re-run.rBz/Report cloud-init status or wait on completion.�schemaz-Validate cloud-config files using jsonschema.c3�DK�|]}|jd�r�|���y�w)�-N)r{)�.0�posargs  r'�	<genexpr>zmain.<locals>.<genexpr>�s����J��6�3D�3D�S�3I�V�J�s� � )�
get_parser)r|�handle_collect_logs_args)r|�handle_clean_args)r|�handle_args�render)r|�handle_schema_args)r|�handle_status_args)rF)r�r)rzsearching for local datasources)zinit-networkz!searching for network datasourcesrzrunning modules for %sz	single/%szrunning single module %szrunning 'cloud-init %s')�reporting_enabledzcloud-init mode '%s')�logfuncr&�
get_uptime�funcrF):r�configure_root_loggerr �argv�argparse�ArgumentParser�pop�add_argumentr
r<�set_defaults�add_subparsersrl�
add_parser�FileTyper�rrr�keysrr\r��cloudinit.analyzer|�cloudinit.cmd.devel.parser�cloudinit.cmd.devel.logsr}�cloudinit.cmd.cleanr~�cloudinit.cmd.queryr�cloudinit.config.schemar��cloudinit.cmd.statusr��
parse_argsr5�setup_basic_loggingrPryrz�WARNINGr�attach_handlersrvrFr�rE�reportr�ReportEventStackr�r	�log_timer-r�flush_events)"�	sysv_args�parser�
subparsers�parser_init�
parser_mod�
parser_single�parser_query�parser_features�parser_analyze�parser_devel�parser_collect_logs�parser_clean�
parser_status�
parser_schemard�analyze_parser�devel_parser�logs_parserr}�clean_parserr~�query_parser�handle_query_args�
schema_parserr��
status_parserr�rFrEr@�rname�	report_on�rdesc�retvals"                                  r'�mainr�Ss���������H�H�	�
�
$�
$�)�-�-��*:�
;�F��������w�5�5�7�8�
6���������
I���������
-����	������&��&�&�]��&�N�J��J���'�'��I�(��K�������
:����������
�
7�
�
�
�t�
$�
�����V�Y�$7��8��&�&��K�'��J�������
G��+�
��������
�
7�
�
�
�t�
$�
�����I�|�#<��=��)�)��-�*��M�������
"���������
-���%�*�*�,�-��������
 ��	��������
?�	��������
�
7�
�
�
�t�
$�
�����x��&=��>��(�(��
J�)��L�
!�+�+��1�,��O�� � ��]�(C� �D��*�*��G�+��N��(�(��.�)��L�%�/�/��I�0����(�(��K�)��L��)�)��H�*��M��)�)��F�*��M���J�)�J��
�
���"�F�
�>�*�
�7�
"�M�
��&�
�>�
)�
�

�+�,��,�,�&�(@�A�
-�
��7�
"�
�

��&��%�%�g�7H�-I�%�J�
�7�
"�
�

��&��%�%�h�8I�-J�%�K�
�8�
#�
�

�-�(��&�&�x�9K�.L�&�M�
�8�
#�
�

�-�(��&�&�x�9K�.L�&�M����)��,�D��k�k�O�T�7��&�&����!�Z�Z�G�M�M�W�_�_�	
�
������!��"�"�$�
��~�)�t�+��$�)�)�0C� ���E��I��v�~��:�:�L�L�E�5��L�E�5�
��	��4�9�9�$�$�t�y�y�0���
��	��$�)�)�#�&����2����K�K�	���)�D�0���	��+�+�
�u�	��D�M�
���
�����I�I�&��-������
��
������M�
�
�s�
.W�W�__main__�TZz:/etc/localtime)�r@))rurj)TN)NN)Gr�r-r+r r0r#ry�typingr�	cloudinitrrrrrr	r
rrr
�cloudinit.cmd.develr�cloudinit.configr�cloudinit.config.modulesrr�rr�cloudinit.reportingr�cloudinit.safeyamlr�cloudinit.settingsrrrrr:rMrr)�__name__r-r$r0r6r3rIrWr\rd�intr�r�r�r�r�r�rrrFr�r�r�r\r��environr��return_value�exitrwr(r'�<module>r�st����	�
������$��� �����#�.�,�,�?��&�#�O�O�(��%��
������g����!��
�7���
��W��&=�
K�o�U�3��8�_�o�dE�<�]C�@/�d40�nD�Nx#�vE�v�{�{�E��.A�W�t�z���2�:�:��,��
�
�4������>�L���������	r(