Current File : //usr/lib/python3/dist-packages/sos/report/plugins/__pycache__/proxmox.cpython-312.pyc
�

-�_g���8�ddlZddlmZmZmZGd�dee�Zy)�N)�Plugin�DebianPlugin�	PluginOptc�@�eZdZdZdZdZdZeddd��gZd	�Z	d
�Z
y)�Proxmoxz�
    This plugin will capture information about the system's
    Proxmox Virtualization Environment.

    It will collect information about the cluster, nodes, pools and
    storage from the Proxmox API.
    zProxmox cluster information�proxmox)z
proxmox-ve�output-formatsz@List of output formats to use for the commands separated by ":".�text)�desc�defaultc
��|jd�jd�}gd�}g}|D]"}|j|j|���$|j	|D��cgc]}|D]}d|�d|dk(rdnd�d	|�����c}}�ycc}}w)
Nr	�:)zcluster/resourceszcluster/config/nodeszcluster/optionsznodes/:id/statusznodes/:id/storageznodes/:id/network�pools�storagezstorage/:sidzcluster/ceph/statuszcluster/ceph/metadatazcluster/ceph/flagsz
pvesh get � r
z
--noborder�z --output-format )�
get_option�split�extend�build_cmd_paths�add_cmd_output)�self�output_formats�commands�	cmd_paths�command�cmd�formats       �</usr/lib/python3/dist-packages/sos/report/plugins/proxmox.py�setupz
Proxmox.setup$s������)9�:�@�@��E��

���	��	<�G����T�1�1�'�:�;�	<�	
���!�
��(�	
�����Q�v��/?�|�R�H�I�%�h�
(�
�
(�
�	��
s� B
c
���|jd�}g}td�t|�D�d�}|��dj|d|�}dj||dzd�}|j	d|�d��}|ddk(rJtj|d	�}|D]-}	|j|j|�d|	d
�d|�����/|S|jdj|��|S)z�
        Build command paths,
        replacing dynamic attributes with data from the API

        :param base_path: The base path to build from
        :type base_path: str

        :return: A list of paths
        �/c3�HK�|]\}}|jd�r|���y�w)rN)�
startswith)�.0�i�parts   r�	<genexpr>z*Proxmox.build_cmd_paths.<locals>.<genexpr>Os'����2�w�q�$� �O�O�C�0��2�s� "N�z	pvesh ls z --output-format json�statusr�output�name)
r�next�	enumerate�join�exec_cmd�json�loadsrr�append)
r�	base_path�parts�paths�id_index�path�
trailing_path�results�children�childs
          rrzProxmox.build_cmd_pathsBs������$�����2�)�E�*:�2�37�9�����8�8�E�)�8�,�-�D��H�H�U�8�a�<�=�%9�:�M��m�m�i��v�5J�$K�L�G��x� �A�%��:�:�g�h�&7�8��%��E��L�L��,�,�#�f�A�e�F�m�_�A�m�_�E������
�L�L����%��)���N)�__name__�
__module__�__qualname__�__doc__�
short_desc�plugin_name�packagesr�option_listr r�r=rrrs>���/�J��K��H�	�"�<� �	��K��<!r=r)r1�sos.report.pluginsrrrrrFr=r�<module>rHs ���>�>�T�f�l�Tr=