Your IP : 216.73.216.172


Current Path : /lib/python3/dist-packages/sos/report/plugins/__pycache__/
Upload File :
Current File : //lib/python3/dist-packages/sos/report/plugins/__pycache__/proxmox.cpython-38.pyc

U

-�_g��@s2ddlZddlmZmZmZGdd�dee�ZdS)�N)�Plugin�DebianPlugin�	PluginOptc@s<eZdZdZdZdZdZedddd�gZd	d
�Z	dd�Z
d
S)�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 informationZproxmox)z
proxmox-ve�output-formatsz@List of output formats to use for the commands separated by ":".�text)Zdesc�defaultcsf|�d��d��ddddddd	d
ddd
dg}g}|D]}|�|�|��q4|��fdd�|D��dS)Nr�:zcluster/resourceszcluster/config/nodeszcluster/optionsznodes/:id/statusznodes/:id/storageznodes/:id/networkZpoolsZstoragezstorage/:sidzcluster/ceph/statuszcluster/ceph/metadatazcluster/ceph/flagsc	s8g|]0}�D]&}d|�d|dkr$dnd�d|���qqS)z
pvesh get � rz
--noborder�z --output-format �)�.0�cmd�format�Zoutput_formatsr�</usr/lib/python3/dist-packages/sos/report/plugins/proxmox.py�
<listcomp>;s�z!Proxmox.setup.<locals>.<listcomp>)Z
get_option�split�extend�build_cmd_pathsZadd_cmd_output)�selfZcommandsZ	cmd_pathsZcommandrrr�setup$s(��z
Proxmox.setupc

Cs�|�d�}g}tdd�t|�D�d�}|dk	r�d�|d|��}d�||dd��}|�d|�d��}|dd	kr�t�|d
�}|D](}	|�|�|�d|	d�d|����q�n|�	d�|��|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
        �/css |]\}}|�d�r|VqdS)r	N)�
startswith)r
�i�partrrr�	<genexpr>Os
�z*Proxmox.build_cmd_paths.<locals>.<genexpr>N�z	pvesh ls z --output-format jsonZstatusr�output�name)
r�next�	enumerate�joinZexec_cmd�json�loadsrr�append)
r�	base_path�parts�pathsZid_index�pathZ
trailing_pathZresultsZchildrenZchildrrrrBs&

���zProxmox.build_cmd_pathsN)�__name__�
__module__�__qualname__�__doc__Z
short_descZplugin_nameZpackagesrZoption_listrrrrrrrs��r)r#Zsos.report.pluginsrrrrrrrr�<module>
s