File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/states/__pycache__/disk.cpython-310.pyc
o
�N�g� � @ sF d Z ddlmZ dgZddd�Zdd � Zd
d� Zdd
� Zddd�ZdS )a�
Disk monitoring state
Monitor the state of disk resources.
The ``disk.status`` function can be used to report that the used space of a
filesystem is within the specified limits.
.. code-block:: sls
used_space:
disk.status:
- name: /dev/xda1
- maximum: 79%
- minimum: 11%
It can be used with an ``onfail`` requisite, for example, to take additional
action in response to or in preparation for other states.
.. code-block:: sls
storage_threshold:
disk.status:
- name: /dev/xda1
- maximum: 97%
clear_cache:
cmd.run:
- name: rm -r /var/cache/app
- onfail:
- disk: storage_threshold
To use kilobytes (KB) for ``minimum`` and ``maximum`` rather than percents,
specify the ``absolute`` flag:
.. code-block:: sls
used_space:
disk.status:
- name: /dev/xda1
- minimum: 1024 KB
- maximum: 1048576 KB
- absolute: True
� )�path�status� �%c C s� d}zt |t�r|�d| �}t|�}W n ttfy) || � d�7 }Y ||fS w t|�dkrD||d k s<||d krD|d�| |�7 }||fS )zp
Validate the named integer within the supplied limits inclusive and
strip supplied unit characters
� � z must be an integer � r � z*{0} must be in the range [{1[0]}, {1[1]}] )�
isinstance�str�strip�int� TypeError�
ValueError�len�format)�name�valueZlimitsr �commentr r �D/opt/saltstack/salt/lib/python3.10/site-packages/salt/states/disk.py�
_validate_int5 s
��r c C sd |rt || d �}t || d �}nt || d �d��}d| }|| |d<