File manager - Edit - /opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/__pycache__/mine.cpython-310.pyc
Back
o ;j� � @ sH d Z ddlZddlZe�e�ZdZdZdZ dd� Z ddd �Zd d� ZdS ) z6 This module contains routines used for the salt mine � NZ__saltmine_acl__� Z__data__c C s8 | � |i �� |g �}|o||v}|rt�d|||� |S )aH Helper function to determine if a ``req_minion`` is not allowed to retrieve ``mine_function``-data from the mine of ``mine_minion``. :param dict minion_acl_cache: Contains minion_id as first level key, and mine function as 2nd level key. Value of 2nd level is a list of minions that are allowed to retrieve the function from the mine of the minion. :param str mine_minion: The minion that the mine value originated from. :param str mine_function: The mine function that is requested. :param str req_minion: The minion that is requesting the mine data. :rtype: bool :return: False if no ACL has been defined for ``mine_minion``, ``mine_function``. False if an ACL has been defined and it grants access. True if an ACL has been defined and does not grant access. z>Salt mine request from %s for function %s on minion %s denied.)�get�log�debug)Zminion_acl_cacheZmine_minion� mine_functionZ req_minionZminion_acl_entry�ret� r �C/opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/mine.py�minion_side_acl_denied s �r c C s. t | tti}|r|�tjj�||d��� |S )a� Helper function to convert an non-ACL mine entry into the new entry which includes ACL data. :param dict function_data: The function data to wrap. :param str allow_tgt: The targeting string that designates which minions can request this mine entry. :param str allow_tgt_type: The type of targeting string. .. seealso:: :ref:`targeting` :rtype: dict :return: Mine entry structured to include ACL data. �� allow_tgt�allow_tgt_type)�MINE_ITEM_ACL_DATA�MINE_ITEM_ACL_ID�MINE_ITEM_ACL_VERSION�update�salt�utils�data� filter_falsey)Z function_datar r �resr r r �wrap_acl_structure. s ���r c C s� d}g }i }i }t | t�r| �dd�}| }n t | t�r6| D ]}t |t�r*|�|� q|�|� q|�dd�}tjj� |�dd�|�dd�d��}||||fS )a@ Helper function to parse the mine_function definition as provided in config, or pillar. :param function_definition: The function definition to parse. :type function_definition: list or dict :rtype: tuple :return: Tuple with function_name, function_args, function_kwargs, minion_acl (dict) Nr r r r ) � isinstance�dict�pop�listr �appendr r r r )Zfunction_definitionZ function_nameZ function_argsZfunction_kwargsZ minion_acl�itemr r r �parse_function_definitionJ s&