File manager - Edit - /opt/saltstack/salt/lib/python3.10/site-packages/salt/client/ssh/wrapper/__pycache__/grains.cpython-310.pyc
Back
o ;j� � @ s� d Z ddlZddlZddlZddlZddlmZ i Zdd� Z dd� Z dd � Zd d� Ze ee e eeed�Z d edfdd�Zdd� Zddd�Zdd� Zdd� Zddd�ZdS ) z+ Return/control aspects of the grains data � N)�DEFAULT_TARGET_DELIMc C s6 t | �}tt�|d ��}d�| d|� d|| �S )z4 Replaces the last 1/4 of a string with X's g �?z{}{}N�X)�len�int�math�floor�format)Zinstr�length�index� r �R/opt/saltstack/salt/lib/python3.10/site-packages/salt/client/ssh/wrapper/grains.py�_serial_sanitizer s r c C � dS )NzMINION.DOMAINNAMEr ��xr r r �_fqdn_sanitizer � r c C r )NZMINIONr r r r r �_hostname_sanitizer r r c C r )NZ DOMAINNAMEr r r r r �_domainname_sanitizer! r r )Zserialnumber�domainZfqdn�id�hostZ localhost�nodename� Tc C sB |du r t �� }ntjj�tjj�t �� ��}tjj�|| ||�S )a2 Attempt to retrieve the named value from grains, if the named value is not available return the passed default. The default return is an empty string. The value can also represent a value in a nested dict using a ":" delimiter for the dict. This means that if a dict in grains looks like this:: {'pkg': {'apache': 'httpd'}} To retrieve the value associated with the apache key in the pkg dict this key can be passed:: pkg:apache CLI Example: .. code-block:: bash salt '*' grains.get pkg:apache T) � __grains__�value�salt�utils�json�loads�dumps�data�traverse_dict_and_list)�key�default� delimiterZorderedZgrainsr r r �get2 s r&