File manager - Edit - /opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/__pycache__/grains.cpython-310.pyc
Back
o ;j7W � @ s� d Z ddlZddlZddlZddlZddlZddlmZ ddlm Z ddl ZddlZddl ZddlZddlZddlZddlmZ ddlmZ dgZi Zdddd �Zd d� ZdZe�e�Zd d� Zdd� Zdd� Zdd� Z ee eeeeed�Z!dedfdd�Z"dd� Z#d9dd�Z$dd � Z%d:d!d"�Z&d:d#d$�Z'defd%d&�Z(efd'd(�Z)d9d)d*�Z*d;d+d,�Z+d-d.� Z,d<d1d2�Z-efd3d4�Z.dddefd5d6�Z/d7d8� Z0e"Z1dS )=a Return/control aspects of the grains data Grains set or altered with this module are stored in the 'grains' file on the minions. By default, this file is located at: ``/etc/salt/grains`` .. Note:: This does **NOT** override any grains set in the minion config file. � N)�Mapping)�reduce)�DEFAULT_TARGET_DELIM)� SaltException�*�nested)�items�item�setvalc C s t �t�S )N)�collections�defaultdict� _infinitedict� r r �G/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/grains.pyr + s r Z/NonExistentValueMagicNumberSpK3hnufdHfeBUXCfqVKc C s6 t | �}tt�|d ��}d�| d|� d|| �S )z*Replaces the last 1/4 of a string with X'sg �?z{}{}N�X)�len�int�math�floor�format)Zinstr�length�indexr r r �_serial_sanitizer4 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_sanitizerC r r )Zserialnumber�domainZfqdn�id�hostZ localhost�nodename� Tc C s: |du rt }ntjj�tjj�t ��}tjj�|| ||�S )a� 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 :param delimiter: Specify an alternate delimiter to use when traversing a nested dict. This is useful for when the desired key contains a colon. See CLI example below for usage. .. versionadded:: 2014.7.0 :param ordered: Outputs an ordered dict if applicable (default: True) .. versionadded:: 2016.11.0 CLI Example: .. code-block:: bash salt '*' grains.get pkg:apache salt '*' grains.get abc::def|ghi delimiter='|' T)� __grains__�salt�utils�json�loads�dumps�data�traverse_dict_and_list)�key�default� delimiterZordered�grainsr r r �getT s #r1 c C s t jj�t| t�tuS )ad Determine whether a key exists in the grains dictionary. Given a grains dictionary that contains the following structure:: {'pkg': {'apache': 'httpd'}} One would determine if the apache key in the pkg dict exists by:: pkg:apache CLI Example: .. code-block:: bash salt '*' grains.has_value pkg:apache )r&