HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.109.1.lve.el8.x86_64 #1 SMP Thu Mar 5 20:23:46 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.30
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/states/__pycache__/blockdev.cpython-310.pyc
o

�N�g#�@s`dZddlZddlZddlZddlZddlZdZe�e	�Z
dd�Zdd�Zdd
d�Z
dd
�ZdS)a8
Management of Block Devices

A state module to manage blockdevices

.. code-block:: yaml


    /dev/sda:
      blockdev.tuned:
        - read-only: True

    master-data:
      blockdev.tuned:
        - name: /dev/vg/master-data
        - read-only: True
        - read-ahead: 1024


.. versionadded:: 2014.7.0
�NZblockdevcCsdtvrtSdd�t�fS)zI
    Only load this module if the disk execution module is available
    �	disk.tuneFz@Cannot load the {} state module: disk execution module not found)�__salt__�__virtualname__�format�rr�H/opt/saltstack/salt/lib/python3.10/site-packages/salt/states/blockdev.py�__virtual__$s��rcKsZid|dd�}ddddd�}tdsd	�|�|d
<|Stdr-d|�d
�|d
<d|d<|Std|�}td|fi|��}i}|D]B}||vr�||}||||kr�t||t�rg||dk}	||dk}
n||}	||}
|dkry|	}	|
}
d|	�d|
��||<qA|r�|r�d|�d�|d
<||d<|Sd|�d�|d
<|Sd|��|d
<d|d<|S)a9
    Manage options of block device

    name
        The name of the block device

    opts:
      - read-ahead
          Read-ahead buffer size

      - filesystem-read-ahead
          Filesystem Read-ahead buffer size

      - read-only
          Set Read-Only

      - read-write
          Set Read-Write
    �T��changes�comment�name�resultZgetraZgetfraZgetro)z
read-aheadzfilesystem-read-aheadz	read-only�
read-writezfile.is_blkdevz5Changes to {} cannot be applied. Not a block device. r�test�Changes to � will be applied Nrz	disk.dumpr�1rz
Changed from z to z
Block device z successfully modified rz already in correct statezFailed to modify block device F)rr�__opts__�
isinstance�bool)r
�kwargs�retZ	kwarg_map�currentrZ	changeset�keyZswitch�old�newrrr�tuned2sT��"����r�ext4FcKsTi|�d|��|dd�}tj�|�s|�d�|d<|St|�}||kr)d|d<|Stjj�d|���s@d	|��|d<d|d<|Std
rRd|�d�|d<d
|d<|Std||fd|i|��t	d�D]9}t
�d|d�t|�}||kr�|�d|��|d<||d�|d<d|d<|S|dkr�t
�d�t�
d�qcd|��|d<d|d<|S)a�
    Manage filesystems of partitions.

    name
        The name of the block device

    fs_type
        The filesystem it should be formatted as

    force
        Force mke2fs to create a filesystem, even if the specified device is
        not a partition on a block special device. This option is only enabled
        for ext and xfs filesystems

        This option is dangerous, use it with caution.

        .. versionadded:: 2016.11.0
    z already formatted with Fr
z does not existrTrzmkfs.zInvalid fs_type: rrrNzdisk.format�force�
z!Check blk fstype attempt %d of 10�z has been formatted with )rrrr	zWaiting 3s before next check�zFailed to format )�os�path�exists�	_checkblk�salt�utils�whichrr�range�log�info�time�sleep)r
Zfs_typerrrZ
current_fs�irrr�	formattedvsH�
r0cCs(tdddddd|gdd�}|sd	S|S)
z=
    Check if the blk exists and return its fstype if ok
    zcmd.runZblkidz-o�valuez-sZTYPET)Zignore_retcoder	)r)r
Zblkrrrr&�s�r&)rF)�__doc__�loggingr#Zos.pathr-Zsalt.utils.pathr'r�	getLogger�__name__r+rrr0r&rrrr�<module>s

DH