Sindbad~EG File Manager

Current Path : /lib/python3.6/site-packages/sos/report/plugins/__pycache__/
Upload File :
Current File : //lib/python3.6/site-packages/sos/report/plugins/__pycache__/proxmox.cpython-36.opt-1.pyc

3

�f��@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�
proxmox-ve�output_formatsz@List of output formats to use for the commands separated by ":".�text)Zdesc�defaultcsj|jd�jd��ddddddd	d
ddd
dg}g}x|D]}|j|j|��q6W|j�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)rr
�/usr/lib/python3.6/proxmox.py�
<listcomp><sz!Proxmox.setup.<locals>.<listcomp>)Z
get_option�split�extend�build_cmd_pathsZadd_cmd_output)�selfZcommandsZ	cmd_pathsZcommandr
)rr�setup$s&

z
Proxmox.setupc
Cs�|jd�}g}tdd�t|�D�d�}|dk	r�dj|d|��}dj||dd��}|jd|�d��}|dd	kr�tj|d
�}xB|D](}	|j|j|�d|	d�d|����q�Wn|j	dj|��|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 |]\}}|jd�r|VqdS)r
N)�
startswith)r�i�partr
r
r�	<genexpr>Osz*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_path�resultsZchildrenZchildr
r
rrBs 

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

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists