![]() Server : Apache/2.4.52 (Ubuntu) System : Linux webserver 6.8.0-49-generic #49~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Nov 6 17:42:15 UTC 2 x86_64 User : www-data ( 33) PHP Version : 8.1.2-1ubuntu2.21 Disable Function : NONE Directory : /lib/python3/dist-packages/cloudinit/cmd/devel/__pycache__/ |
o }��f� � @ s� d Z ddlZddlZddlZddlZddlmZ ddlmZm Z m Z mZ dZe� j Ze�e�Zddd�Zdd d �Zdd� Zed krNe�eee� �� �� dS dS )z,Debug jinja template rendering of user-data.� N)�read_cfg_paths)�JinjaLoadError�JinjaSyntaxParsingException� NotJinjaError�render_jinja_payload_from_file�renderc C sR | s t jttd�} | jdtdd� | jddtdt� �d� | jdd d ddd � | S )a Build 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-dataz6Optional path to instance-data.json file. Defaults to z-dz--debug� store_trueFz+Add verbose messages during template render)�action�defaultr )�argparse�ArgumentParser�NAME�__doc__�add_argument�str�CLOUDINIT_RUN_DIR)�parser� r �</usr/lib/python3/dist-packages/cloudinit/cmd/devel/render.py� get_parser s* ��� �r Fc C s| |r|}n't � }t�� }|�d�}|dkr*|�d�}tj�|�s)t�d||� |}n|}tj�|�s:t�d|� dS zt | ��}|� � }W d � n1 sNw Y W n tyd t�d| � Y dS w zt|| ||rnd nd d�} W n8 t tfy� } zt�dt| �� W Y d} ~ dS d} ~ w ty� } zt�d | t| �� W Y d} ~ dS d} ~ ww | s�t�d| � dS tj�| � dS )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�IOErrorr r r �reprr r �sys�stdout�write)�user_data_path�instance_data_pathr! �instance_data_fn�paths�uid�redacted_data_fn�streamr �rendered_payload�er r r �render_template: sn �� ��� ������r: c C s t |j|j|j�S �N)r: r r r! )�_name�argsr r r �handle_argsv s r>