File manager - Edit - /opt/saltstack/salt/lib/python3.10/site-packages/salt/beacons/__pycache__/avahi_announce.cpython-310.pyc
Back
o ;j�! � @ s d Z ddlZddlZddlZddlZzddlZdZW n ey% dZY nw z-ddl Z ddl m Z e �� Ze � e�ejej�ej�Ze � e�eje�� �ej�ZdZW n eefy` dZY n e yj dZY nw e�e�ZdZi add� Zd d � Zdd� Zd d� Z dS )z� Beacon to announce via avahi (zeroconf) .. versionadded:: 2016.11.0 Dependencies ============ - python-avahi - dbus-python � NTF)� DBusExceptionZavahi_announcec C s@ t rtrtS d} t�dt| � d| fS d} t�dt| � d| fS )Nz(The 'python-dbus' dependency is missing.zUnable to load %s beacon: %sFz)The 'python-avahi' dependency is missing.)�HAS_PYAVAHI�HAS_DBUS�__virtualname__�log�error)�err_msg� r �O/opt/saltstack/salt/lib/python3.10/site-packages/salt/beacons/avahi_announce.py�__virtual__5 s r c s: t jj�| �� t| t�sdS t� fdd�dD ��sdS dS )z+ Validate the beacon configuration )Fz7Configuration for avahi_announce beacon must be a list.c 3 s � | ]}|� v V qd S )Nr )�.0�x�Z_configr r � <genexpr>L s � zvalidate.<locals>.<genexpr>)�servicetype�port�txt)FzUConfiguration for avahi_announce beacon must contain servicetype, port and txt items.)TzValid beacon configuration.)�salt�utils�beacons�list_to_dict� isinstance�list�all)�configr r r �validateB s r c C s4 t | �t |� d dkr|ddt | � � d S |S )a� Enforces the TXT record maximum length of 255 characters. TXT record length includes key, value, and '='. :param str key: Key of the TXT record :param str value: Value of the TXT record :rtype: str :return: The value of the TXT record. It may be truncated if it exceeds the maximum permitted length. In case of truncation, '...' is appended to indicate that the entire value is not present. � � N� z...)�len)�key�valuer r r �_enforce_txt_record_maxlenT s r"