403Webshell
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/modules/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/jinja.py
"""
Module for checking jinja maps and verifying the result of loading JSON/YAML
files

.. versionadded:: 3000
"""

import functools
import logging
import textwrap

import salt.loader
import salt.template
import salt.utils.json

log = logging.getLogger(__name__)


def _strip_odict(wrapped):
    """
    dump to json and load it again, replaces OrderedDicts with regular ones
    """

    @functools.wraps(wrapped)
    def strip(*args):
        return salt.utils.json.loads(salt.utils.json.dumps(wrapped(*args)))

    return strip


@_strip_odict
def load_map(path, value):
    """
    Loads the map at the specified path, and returns the specified value from
    that map.

    CLI Example:

    .. code-block:: bash

        # Assuming the map is loaded in your formula SLS as follows:
        #
        # {% from "myformula/map.jinja" import myformula with context %}
        #
        # the following syntax can be used to load the map and check the
        # results:
        salt myminion jinja.load_map myformula/map.jinja myformula
    """
    tmplstr = textwrap.dedent(
        """\
        {{% from "{path}" import {value} with context %}}
        {{{{ {value} | tojson }}}}
        """.format(
            path=path, value=value
        )
    )
    return salt.template.compile_template_str(
        tmplstr,
        salt.loader.render(__opts__, __salt__),
        __opts__["renderer"],
        __opts__["renderer_blacklist"],
        __opts__["renderer_whitelist"],
    )


@_strip_odict
def import_yaml(path):
    """
    Loads YAML data from the specified path

    CLI Example:

    .. code-block:: bash

        salt myminion jinja.import_yaml myformula/foo.yaml
    """
    tmplstr = textwrap.dedent(
        """\
        {{% import_yaml "{path}" as imported %}}
        {{{{ imported | tojson }}}}
        """.format(
            path=path
        )
    )
    return salt.template.compile_template_str(
        tmplstr,
        salt.loader.render(__opts__, __salt__),
        __opts__["renderer"],
        __opts__["renderer_blacklist"],
        __opts__["renderer_whitelist"],
    )


@_strip_odict
def import_json(path):
    """
    Loads JSON data from the specified path

    CLI Example:

    .. code-block:: bash

        salt myminion jinja.import_json myformula/foo.json
    """
    tmplstr = textwrap.dedent(
        """\
        {{% import_json "{path}" as imported %}}
        {{{{ imported | tojson }}}}
        """.format(
            path=path
        )
    )
    return salt.template.compile_template_str(
        tmplstr,
        salt.loader.render(__opts__, __salt__),
        __opts__["renderer"],
        __opts__["renderer_blacklist"],
        __opts__["renderer_whitelist"],
    )

Youez - 2016 - github.com/yon3zu
LinuXploit