File manager - Edit - /opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/__pycache__/parted_partition.cpython-310.pyc
Back
o ;jJU � @ sT d Z ddlZddlZddlZddlZddlZddlZddlZddl m Z e�e�Z dZddd�Zh d�Zh d �Zh d �Zdd� Zd d� Zdd� Zdd� Zd@dd�Zdd� Zdd� Zdd� Zdd� Zdd� Zdd � Zd!d"� Zd#d$� Zd%d&� Z dAd'd(�Z!dAd)d*�Z"d+d,� Z#d-d.� Z$d/d0� Z%d1d2� Z&d3d4� Z'd5d6� Z(d7d8� Z)d9d:� Z*dBd<d=�Z+d>d?� Z,dS )Ca0 Module for managing partitions on POSIX-like systems. :depends: - parted, partprobe, lsblk (usually parted and util-linux packages) Some functions may not be available, depending on your version of parted. Check the manpage for ``parted(8)`` for more information, or the online docs at: http://www.gnu.org/software/parted/manual/html_chapter/parted_2.html In light of parted not directly supporting partition IDs, some of this module has been written to utilize sfdisk instead. For further information, please reference the man page for ``sfdisk(8)``. � N)�CommandExecutionError� partition�set�list)�set_�list_> �chsZMB�B�compactZGiB�s�%ZcylZkBZTBZTiBZMiBZGB> Z pmbr_bootZcylinder_alignmentZimplicit_partition_table> z hp-serviceZraidZlvm�rootZprepZlbaZmsftres�typeZbootZmsftdataZ bios_grubZpaloZatvrecvZlegacy_bootZhiddenZdiagZespZirstZswapc C sJ t jj�� rdS t jj�d�sdS t jj�d�sdS t jj�d�s#dS tS )z� Only work on POSIX-like systems, which have parted and lsblk installed. These are usually provided by the ``parted`` and ``util-linux`` packages. )FzMThe parted execution module failed to load Windows systems are not supported.�parted)FzLThe parted execution module failed to load parted binary is not in the path.Zlsblk)FzKThe parted execution module failed to load lsblk binary is not in the path.Z partprobe)FzOThe parted execution module failed to load partprobe binary is not in the path.)�salt�utils�platformZ is_windows�path�which�__virtualname__� r r �Q/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/parted_partition.py�__virtual__P s r c C s. t j�| �rt �| �j}t�|�rdS td��)a0 Ensure the device name supplied is valid in a manner similar to the `exists` function, but raise errors on invalid input rather than return False. This function only validates a block device, it does not check if the block device is a drive or a partition or a filesystem, etc. Nz*Invalid device passed to partition module.)�osr �exists�stat�st_mode�S_ISBLKr ��device�devr r r �_validate_devices s r! c C sB t | �} t�d| �}|r|�d�}|r|tv rdS td| � d���)z9 Ensure valid partition boundaries are supplied. z^([\d.]+)(\D*)$� Nz$Invalid partition boundary passed: "�")�str�re�search�group�VALID_UNITSr )�boundary�match�unitr r r �_validate_partition_boundary� s r, c G s6 | D ]}t |� qd�d�| ��}td |��� }|S )a� Ask the kernel to update its local partition data. When no args are specified all block devices are tried. Caution: Generally only works on devices with no mounted partitions and may take a long time to return if specified devices are in use. CLI Examples: .. code-block:: bash salt '*' partition.probe salt '*' partition.probe /dev/sda salt '*' partition.probe /dev/sda /dev/sdb zpartprobe -- {}� �cmd.run)r! �format�join�__salt__� splitlines)Zdevicesr �cmd�outr r r �probe� s r5 c C sz t | � |r|tvrtd��d| � d|� d�}nd| � d�}td |��� }i i d�}d}|D ]�}|dv r6q/|�d ��d �}|dkr�dt|� krNdkr~n td��|d |d |d |d |d |d |d d�|d<