HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.104.1.lve.el8.x86_64 #1 SMP Tue Feb 10 20:07:30 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.29
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/__pycache__/drbd.cpython-310.pyc
o

�N�g��@s�dZddlZe�e�Zdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�Zdd�Z
dd�Zgaiadaddd�ZdS)z
DRBD administration module
�NcCsPd|vr|�d�d|�d�dfSd|vr$|�d�d|�d�dfS|dfS)z*
    Split the field in drbd-overview
    �(r�/��)�split)�content�r�E/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/drbd.py�_analyse_overview_field
s
r
cCsD|�d�d��dkr
dSd}|D]}|��r|d7}q|SdS)z?
    Count the number of spaces before the first character
    �#rrNr)r�strip�isspace)�line�spaces�irrr	�_count_spaces_startswiths
�rcCsht|�}|dur
dSddddd�ddid	�}|�|d
�}t|t�r#|S|D]}||vr1||Sq%d
S)z3
    Figure out the sections in drbdadm status
    Nr�RESOURCE�	LOCALDISK�PEERNODE)z disk:z role:z connection:z peer-disk:�PEERDISK)r���UNKNOWN)r�get�
isinstance�str)rr�switch�ret�xrrr	�_analyse_status_type's
�
�rcCsT|����}trt�t�ia|dtd<|d�d�dtd<gtd<gtd<dS)	zB
    Analyse the line of local resource of ``drbdadm status``
    rz
resource namer�:�
local role�
local volumes�
peer nodesN)rr�resourcer�append)r�fieldsrrr	�_add_resBs
r'cCsft|�}|����}i}|D]}|�d�d||�d�d<q|dkr,td�|�dSt�|�dS)z;
    Analyse the line of volumes of ``drbdadm status``
    r rrrr"N)rrrr$r%�lastpnodevolumes)r�sectionr&Zvolume�fieldrrr	�_add_volumeSsr+cCsb|����}i}|d|d<|d�d�d||d�d�d<g|d<td�|�|dadS)z>
    Analyse the line of peer nodes of ``drbdadm status``
    rz
peernode namerr zpeer volumesr#N)rrr$r%r()rr&Zpeernoderrr	�
_add_peernodees$r,cCsdS)z4
    Action of empty line of ``drbdadm status``
    Nr)Zdummyrrr	�_emptyvsr-cCsd|iadS)z:
    Action of unsupported line of ``drbdadm status``
    zUnknown parserN)r)rrrr	�_unknown_parser|sr.cCs<t|�}|����}tttttd�}|�|t�}||�dS)z)
    Call action for different lines
    )rrrrrN)	rrrr-r'r,r+rr.)rr)r&r�funcrrr	�_line_parser�s�r0cCsBd}td|���D]�}i}|����}|d�d�d}|d�d�d}t|d�\}}t|d�\}}	t|d�\}
}|
�d�r�|�d�r�t|�d	krw|d
}|d	}
|d}|d}|d
}|d}|||||	|
|||
||||d�
}q
|||||	|
|d�}q
|d
}|d}|d}||}|||||	|
|||d�	}q
|S)z�
    Show status of the DRBD devices, support two nodes only.
    drbd-overview is removed since drbd-utils-9.6.0,
    use status instead.

    CLI Example:

    .. code-block:: bash

        salt '*' drbd.overview
    z
drbd-overview�cmd.runrr rr�ZUpTo�r����	)
�minor number�device�connection stater!�partner role�local disk state�partner disk state�
mountpoint�fsz
total size�usedZremains�percent)r8r9r:r!r;r<r=)	r8r9r:r!r;r<r=zsynchronisation: Zsynched)�__salt__�
splitlinesrrr
�
startswith�len)�cmdrrr&Zminnumr9Z	connstate�_Z	localroleZpartnerroleZlocaldiskstateZpartnerdiskstater>Z
fs_mountedZ	totalsizeZusedsizeZ
remainsize�percZsyncbarZsyncedZsyncedbytes�syncrrr	�overview�sp

��
��rJ�allcCsJgaiaddg}|�|�td|���D]}t|�qtr#t�t�tS)a�
    Using drbdadm to show status of the DRBD devices,
    available in the latest drbd9.
    Support multiple nodes, multiple volumes.

    :type name: str
    :param name:
        Resource name.

    :return: drbd status of resource.
    :rtype: list(dict(res))

    CLI Example:

    .. code-block:: bash

        salt '*' drbd.status
        salt '*' drbd.status name=<resource name>
    Zdrbdadm�statusr1)rr$r%rBrCr0)�namerFrrrr	rL�s


rL)rK)�__doc__�logging�	getLogger�__name__�logr
rrr'r+r,r-r.r0rJrr$r(rLrrrr	�<module>s"
K