| Server IP : 198.38.94.13 / Your IP : 216.73.217.33 Web Server : Apache System : Linux d4744.dxb1.stableserver.net 5.14.0-611.49.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Apr 21 16:39:08 EDT 2026 x86_64 User : revivere ( 1140) PHP Version : 8.2.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/__pycache__/ |
Upload File : |
o
;j� � @ sp d Z zddlmZmZ dZW n ey dZY nw er6ddlZddlZddl Z
ddlZ
G dd� de�ZdS dS )z+
Functions for working with Mako templates
� )�TemplateCollection�TemplateLookupTFNc @ sD e Zd ZdZddd�Zdd� Zdd � Zddd�Zd
d� Zdd� Z d
S )�SaltMakoTemplateLookupa
Look up Mako template files using file:// or salt:// URLs with <%include/>
or <%namespace/>.
(1) Look up mako template files on local file system via files://... URL.
Make sure mako template file is present locally on minion beforehand.
Examples:
<%include file="file:///etc/salt/lib/templates/sls-parts.mako"/>
<%namespace file="file:///etc/salt/lib/templates/utils.mako" import="helper"/>
(2) Look up mako template files on Salt master via salt://... URL.
If URL is a relative path (without an URL scheme) then assume it's relative
to the directory of the salt file that's doing the lookup. If URL is an absolute
path then it's treated as if it has been prefixed with salt://.
Examples::
<%include file="templates/sls-parts.mako"/>
<%include file="salt://lib/templates/sls-parts.mako"/>
<%include file="/lib/templates/sls-parts.mako"/> ##-- treated as salt://
<%namespace file="templates/utils.mako"/>
<%namespace file="salt://lib/templates/utils.mako" import="helper"/>
<%namespace file="/lib/templates/utils.mako" import="helper"/> ##-- treated as salt://
�baseFc C s. || _ || _d | _|| _tdd�| _i | _d S )N�/��directories)�opts�saltenv�_file_client�pillar_rendr �lookup�cache)�selfr r
r � r �C/opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/mako.py�__init__2 s
zSaltMakoTemplateLookup.__init__c C s | j s
tj�| j| j�| _ | j S )z6
Setup and return file_client
)r �saltZ
fileclientZget_file_clientr r )r r r r �file_client: s
�z"SaltMakoTemplateLookup.file_clientc C s@ t j�|�j}|dv r
|S |rtd|� d|� ���| j�||�S )N)r �filezUnsupported URL scheme(z) in )�urllib�parse�urlparse�scheme�
ValueErrorr
�
adjust_uri)r �uri�filenamer r r r r D s z!SaltMakoTemplateLookup.adjust_uriNc C s� |� d�rd}d}|}n2d}| jd dkr| jd | j }n
tj�| jd d| j�g}|� |�r2|ntjj� |�}| �
|� t|d �| _| j�
|t|�d � �S )
Nzfile://r zsalt://r �localZ
file_rootsZcachedir�filesr )�
startswithr r
�os�path�joinr �utils�url�create�
cache_filer r
�get_template�len)r r Z
relativeto�protoZ
searchpathZsalt_urir r r r( L s
�
z#SaltMakoTemplateLookup.get_templatec C s. || j vr| �� �|dd| j�| j |<