File manager - Edit - /opt/saltstack/salt/lib/python3.10/site-packages/salt/renderers/__pycache__/stateconf.cpython-310.pyc
Back
o ;j�M � @ sb d Z ddlZddlZddlZddlZddlZddlZddlmZ ddl Z ddlZ ddlm Z dgZe�e�Zdddd d �Zd aadd � Zej�e�Ze d�e��Zd5dd�Zdd� Zdd� Zdd� Zdd� Z dd� Z!d6dd�Z"d6dd�Z#e$dd g�fd!d"�Z%d#Z&d7d%d&�Z'd'Z(d(Z)i Z*i Z+d)d*� Z,d+d,� Z-d-d.� Z.d/d0� Z/G d1d2� d2e0�Z1i Z2i Z3d7d3d4�Z4dS )8z� A flexible renderer that takes a templating engine and a data format :maintainer: Jack Kuan <kjkuan@gmail.com> :maturity: new :platform: all � N)�chain)�SaltRenderError�renderz!#\s*-+\s*end of state config\s*-+z.startz.goalz stateconf.set)�stateconf_end_marker�stateconf_start_state�stateconf_goal_state�stateconf_state_func� c C s t d atjddd�d ad S )Nr �.� )�maxsplitr )�__opts__� STATE_FUNC�split� STATE_NAME)�opts� r �L/opt/saltstack/salt/lib/python3.10/site-packages/salt/renderers/stateconf.py�__init__B s r a� Invalid use of {0} renderer! Usage: #!{0} [-GoSp] [<data_renderer> [options] . <template_renderer> [options]] where an example <data_renderer> would be yaml and a <template_renderer> might be jinja. Each renderer can be passed its renderer specific options. Options(for this renderer): -G Do not generate the goal state that requires all other states in the sls. -o Indirectly order the states by adding requires such that they will be executed in the order they are defined in the sls. Implies using yaml -o. -s Generate the start state that gets inserted as the first state in the sls. This only makes sense if your high state data dict is ordered. -p Assume high state input. This option allows you to pipe high state data through this renderer. With this option, the use of stateconf.set state in the sls will have no effect, but other features of the renderer still apply. �basec sR d� d�d�d ������ � �fdd� }� ��� �fdd���d }t � |�� d�\}}|r3d�|�nd }d |v r;d�d|v rAd�d |v rGd� d|v rR�| dd�} n�dd� t�d|d�D �}z1|d d �dd�\} �|| ��r~| dkrzd� �ntd��|d d �dd�\} � || �W n ty� } ztd|� d���d }~w ty� t�w t| t �r�t jj� | d��}t jj�|�� �} W d � n1 s�w Y n t jj�| �� �} t�td | �}|r�|| d |�� � dd� t�rt�� }|�r�d ��fdd�|�� D �}ni }|| |�} t�tj��r'dd l}t�d|�| �� | S )!NFc s� d�v rt j���dt jj��n�}t|r|ndd�}|r"|�|� �t�| ���f|�� � d�� ��}�|���� � d�}�||�S )Nr )�sls_dir)�context�argline)r ) �os�path�dirname�replace�sep�dict�update�io�StringIO�strip)�datar �extractr �ctxZtmplout�high)�kws�process_high_data� rd_argline�render_data�render_template� rt_argline�saltenv�slsr r �process_sls_dataj s $ ��� z render.<locals>.process_sls_datac s� t �| �}z:t|� t|��� |s%�r%t|�}|r!td�|���t|� � r,t|�� |s4�s4t |� t |�� t|� W |S tyG � tyu } z#t �d�|� ddlm} |t�}|�| �}|rmtd�|���td��d }~ww )Nz�'names' declaration(found in state id: {}) is not supported with implicitly ordered states! You should generate the states in a template for-loop instead.z5Error found while pre-processing the salt file %s: %sr )�State� z#sls preprocessing/rendering failed!)�copy�deepcopy�#rewrite_single_shorthand_state_decl�rewrite_sls_includes_excludes�has_names_declsr �format�add_implicit_requires�add_start_state�add_goal_state�rename_state_ids�extract_state_confs� Exception�log� exceptionZ salt.stater0 r Zverify_high�join)r&