HOME


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

�f�����dZddlZddlZddlZddlZddlmZddlmZm	Z	m
Z
mZdZeje�Zd
d�Zdd�Zd�Zed	k(r-ej&eee�j)���yy)z,Debug jinja template rendering of user-data.�N)�read_cfg_paths)�JinjaLoadError�JinjaSyntaxParsingException�
NotJinjaError�render_jinja_payload_from_file�renderc���|stjtt��}|j	dt
d��|j	ddt
d��|j	dd	d
dd�
�|S)aBuild or extend and arg parser for jinja render utility.

    @param parser: Optional existing ArgumentParser instance representing the
        subcommand which will be extended to support the args of this utility.

    @returns: ArgumentParser with proper argument configuration.
    )�prog�description�	user_dataz$Path to the user-data file to render)�type�helpz-iz--instance-datazXOptional path to instance-data.json file. Defaults to /run/cloud-init/instance-data.jsonz-dz--debug�
store_trueFz+Add verbose messages during template render)�action�defaultr)�argparse�ArgumentParser�NAME�__doc__�add_argument�str)�parsers �</usr/lib/python3/dist-packages/cloudinit/cmd/devel/render.py�
get_parserrs�����(�(�d��H��
����#�$J��������
�
2����������
:����M�c��|r|}n�t�}tj�}|jd�}|dk(rJ|jd�}tjj|�stjd||�|}n|}tjj|�stjd|�y	t|�5}|j�}ddd�	t|||rd	nd
��}	|	stjd|�yt$j&j)|	�y#1swY�VxYw#t$rtjd|�YywxYw#ttf$r)}
tjdt|
��Yd}
~
yd}
~
wt $r*}
tjd
|t#|
��Yd}
~
yd}
~
wwxYw)z�Render the provided user-data template file using instance-data values.

    Also setup CLI log handlers to report to stderr since this is a development
    utility which should be run by a human on the CLI.

    @return 0 on success, 1 on failure.
    �
instance_datar�instance_data_sensitivez4Missing root-readable %s. Using redacted %s instead.z#Missing instance-data.json file: %s�NzMissing user-data file: %sTF)�payload�
payload_fn�instance_data_file�debugz5Cannot render from instance data due to exception: %sz2Failed to render templated user-data file '%s'. %sz#Unable to render user-data file: %s)r�os�getuid�get_runpath�path�exists�LOG�warning�error�open�read�IOErrorrrr�reprrr�sys�stdout�write)�user_data_path�instance_data_pathr#�instance_data_fn�paths�uid�redacted_data_fn�streamr�rendered_payload�es           r�render_templater<9s����-��� ���i�i�k�� �,�,�_�=���!�8�$�0�0�1J�K���7�7�>�>�"2�3����J�$�$��
$4� �/��
�7�7�>�>�*�+��	�	�7�9I�J���
�.�
!�	&�V����
�I�	&�
�9��%�/��$�U�	
��$��	�	�7��H���J�J���%�&��9	&�	&�����	�	�.��?����
�M�*���	�	�C�T�!�W�	
���&���	�	�@����F�	
�
��
�sN�=D:�D.�D:�"E�.D7�3D:�:E�E�G�.F�G� G�Gc�X�t|j|j|j�S�N)r<rrr#)�_name�argss  r�handle_argsrAus���4�>�>�4�+=�+=�t�z�z�J�Jr�__main__r>)NF)rr�loggingr$r0�cloudinit.cmd.develr�!cloudinit.handlers.jinja_templaterrrrr�	getLogger�__name__r)rr<rA�exit�
parse_args�rr�<module>rKs}��
3���	�
�.������g����!���@9
�xK��z���C�H�H�[��z�|�6�6�8�
9�:�r