File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/__pycache__/varnish.cpython-310.pyc
o
�N�gU � @ sr d Z ddlZddlZddlZe�e�ZdZdd� Z ddd�Z
d d
� Zdd� Zd
d� Z
dd� Zdd� Zddd�ZdS )z�
Support for Varnish
.. versionadded:: 2014.7.0
.. note::
These functions are designed to work with all implementations of Varnish
from 3.x onwards
� NZvarnishc C s$ t jj�d�rt jj�d�rtS dS )z6
Only load the module if varnish is installed
�varnishd�
varnishadm)Fz^The varnish execution module failed to load: either varnishd or varnishadm is not in the path.)�salt�utils�path�which�__virtualname__� r r �H/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/varnish.py�__virtual__ s r r c K sF d| g} | � dd� |D �� t�dd�| �� td | fddi|��S ) a
Execute varnishadm command
return the output of the command
cmd
The command to run in varnishadm
params
Any additional args to add to the command line
kwargs
Additional options to pass to the salt cmd.run_all function
r c S s g | ]}|d ur|�qS �Nr )�.0�paramr r r
�
<listcomp>3 s z#_run_varnishadm.<locals>.<listcomp>z
Executing: %s� zcmd.run_all�python_shellF)�extend�log�debug�join�__salt__)�cmd�params�kwargsr r r
�_run_varnishadm$ s r c C s. ddg} t d | dd�}t�d|��d�}|S )z~
Return server version from varnishd -V
CLI Example:
.. code-block:: bash
salt '*' varnish.version
r z-Vzcmd.runF)r z\(varnish-([^\)]+)\)� )r �re�search�group)r �out�retr r r
�version8 s
r! c C s t d| g�d dkS )z
Add ban to the varnish cache
CLI Example:
.. code-block:: bash
salt '*' varnish.ban ban_expression
�ban�retcoder )r )Zban_expressionr r r
r"