HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //lib/python3/dist-packages/sos/collector/clusters/__pycache__/pacemaker.cpython-38.pyc
U

i��d:�@s@ddlZddlmZddlmZddlmZGdd�de�ZdS)�N)�Cluster)�
parse_version)�ElementTreec@sHeZdZdZdgZdZdZdddgZdd�Zd	d
�Z	dd�Z
d
d�ZdS)�	pacemakerz+Pacemaker High Availability Cluster Manager)rT)�onlineTzCollect nodes listed as online)�offlineTzCollect nodes listed as offline)�
only-corosyncFz)Only use corosync.conf to enumerate nodesc
Cs�g|_zZ|�d�sPz|��Wn0tk
rN}z|�d|�W5d}~XYnX|js^|��Wn0tk
r�}z|�d|�W5d}~XYnXdd�|jD�}|r�|�dd�|��|jS)NrzJFalling back to sourcing corosync.conf. Could not parse crm_mon output: %sz*Could not determine nodes from cluster: %scSsg|]}d|kr|�qS)�.�)�.0�nr
r
�B/usr/lib/python3/dist-packages/sos/collector/clusters/pacemaker.py�
<listcomp>/sz'pacemaker.get_nodes.<locals>.<listcomp>z�WARNING: Node addresses '%s' may not resolve locally if you are not running on a node in the cluster. Try using option '-c pacemaker.only-corosync' if these connections fail.�,)�nodes�
get_option�get_nodes_from_crm�	Exception�log_warn�get_nodes_from_corosyncZ	log_error�join)�self�errZ_shortsr
r
r
�	get_nodess*
� ��zpacemaker.get_nodescCs~d}|�d�}|ddkrJ|d��d�d�d}t|�td�ksNd	}nd
S|jd|dd
�}|ddkrz|�|d�d
S)zG
        Try to parse crm_mon output for node list and status.
        z--output-as=xmlzcrm_mon --versionZstatusr�output��-z2.0.3z--as-xmlNz crm_mon --one-shot --inactive %sT)Z	need_root)Zexec_primary_cmd�splitr�
parse_crm_xml)rZxmloptZ_verZcverZ_outr
r
r
r9s
�zpacemaker.get_nodes_from_crmcCsvt�|�}|�d�}|D]X}|j}|�d�rJ|ddkrJ|j�|d�q|�d�r|ddkr|j�|d�qdS)zA
        Parse the xml output string provided by crm_mon
        rr�true�namerZfalseN)rZ
fromstring�findZattribrr�append)rZ	xmlstringZ_xmlr�nodeZ_noder
r
r
rMs

zpacemaker.parse_crm_xmlcCsD|�d�|j�d�}t�d|�}|D]}|j�|d���q&dS)z�
        As a fallback measure, read corosync.conf to get the node list. Note
        that this prevents us from separating online nodes from offline nodes.
        z_WARNING: unable to distinguish online nodes from offline nodes when sourcing from corosync.confz/etc/corosync/corosync.confz((\sring0_addr:)(.*))���N)rZprimaryZ	read_file�re�findallrr"�strip)rZccrr#r
r
r
rZs

z!pacemaker.get_nodes_from_corosyncN)�__name__�
__module__�__qualname__Zcluster_nameZsos_pluginsZpackagesZstrict_node_listZoption_listrrrrr
r
r
r
rs�
r)r%Zsos.collector.clustersrZ
sos.utilitiesrZ	xml.etreerrr
r
r
r
�<module>s