File manager - Edit - /opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/__pycache__/master.cpython-310.pyc
Back
o ;j�v � @ sZ d Z ddlZddlZddlZddlmZmZ ddlZddl Zddl ZddlZddlZddl ZddlZddlZddlZddlZddlZddlmZ ddlmZ ddlmZ ddlmZ e�e�Zdd � Zd d� Z dd � Z!G dd� d�Z"G dd� de�Z#G dd� de�Z$G dd� de�Z%dd� Z&ddd�Z'dd� Z(edkr�ej)�*d�Z+e%e+�Z,e,�-� dS dS ) ze salt.utils.master ----------------- Utilities that can only be used on a salt master. � N)�Event�Thread)� SaltException)�CacheCli)�Process)�zmqc C s� g }t j�| d d�}t j�|�s|S t �|�D ](}t j�||�}zt|| �}|dur0|�|� W q ty@ t� d|� Y qw |S )z0 Return the running jobs on this minion �cachedir�procNz.%s removed during processing by master process) �os�path�join�isdir�listdir�_read_proc_file�append�OSError�logZtrace)�opts�retZproc_dirZfn_r �data� r �E/opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/master.py�get_running_jobs! s ��r c C s< t jj�| d��9}|�� }|�� |rt j�|�}n zt� | � W n t y0 t�d| � Y nw W d � dS W d � n1 sDw Y t |t�sPdS t jj�|d �srzt� | � W dS t yq t�d| � Y dS w t|�s�|�d�}|r�t�d|� zt� | � W dS t y� t�d| � Y dS w |S )z0 Return a dict of JID metadata, or None �rbzUnable to remove proc file %s.N�pidz7PID %s exists but does not appear to be a salt process.)�salt�utils�files�fopen�read�close�payload�loadsr �remover r �debug� isinstance�dict�processZ os_is_running�_check_cmdline�get�warning)r r �fp_�bufr r r r r r 8 sH ��� �� ��r c C s� t jj�� sdS | �d�}|sdS tj�d�sdS tj�d|� d��}tj� |�s+dS z"t jj �|d��}d|�� v W d � W S 1 sFw Y W d S t yW Y dS w ) a9 In some cases where there are an insane number of processes being created on a system a PID can get recycled or assigned to a non-Salt process. On Linux this fn checks to make sure the PID we are checking on is actually a Salt process. For non-Linux systems we punt and just return True Tr Fz/procz/proc/z/cmdliner s saltN)r r �platformZis_linuxr) r r r r �isfiler r r r )r r r r+ r r r r( ` s"