File manager - Edit - /opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/__pycache__/salt_proxy.cpython-310.pyc
Back
o ;jc � @ sl d Z ddlZddlZddlZddlZddlZe�e�Z dd� Z dd� Zdd� Zd d � Z ddd �Zdd� ZdS )z~ Salt proxy module .. versionadded:: 2015.8.3 Module to deploy and manage salt-proxy processes on a minion. � Nc C s� d� | �}t�d� | rBt�d� tjj�| d��}|�tjj � d� td ��� W d � n1 s3w Y d| � �}t�|� |S ) z write to file z;Invalid value for proxy file provided!, Supplied value = {}z#Salt Proxy Module: write proxy confzWriting proxy conf file�wz master: {}ZmasterNzWrote proxy file )�format�logZtrace�debug�salt�utils�filesZfopen�writeZstringutilsZto_strZ __grains__)� proxyfile�msgZ proxy_conf� r �K/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/salt_proxy.py�_write_proxy_conf s � �� r c C s� g }g }d}t j�| �sQz|s|�t| �� d| � �}nd| � �}W n# tyE } zd}d|� �}t�|� |�|� W Y d}~nd}~ww |�|� t�|� nd| � d�}|�|� t�|� |||fS ) z/ Check if proxy conf exists and update TzSalt Proxy: Wrote proxy conf z*Salt Proxy: Update required to proxy conf Fz%Salt Proxy: Error writing proxy file NzSalt Proxy: z already exists, skipping) �os�path�exists�appendr �OSErrorr �errorr )r �test�changes_old�changes_new�successr �errr r r �_proxy_conf_file* s. � �� r c C s2 d� t�| ��}td |ddd�}|d sdS dS )z1 Check if proxy for this name is running z5ps ax | grep "salt-proxy --proxyid={}" | grep -v grep�cmd.run_all� T)�timeoutZpython_shell�stdoutF)r �shlex�quote�__salt__)� proxyname�cmdZcmdoutr r r �_is_proxy_runningF s �r$ c C sr g }g }t | �s,|s"td dt�| �� d�dd� |�d| � �� n|�d| � d�� n|�d | � �� d ||fS )z) Check and execute proxy process r zsalt-proxy --proxyid=z -l info -dr )r z&Salt Proxy: Started proxy process for zSalt Proxy: process z will be startedz Salt Proxy: already running for T)r$ r! r r r )r"