
    -_g                     8    d dl Z d dlmZmZmZ  G d dee      Zy)    N)PluginDebianPlugin	PluginOptc                   @    e Zd ZdZdZdZdZ eddd      gZd	 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.
    zProxmox cluster informationproxmox)z
proxmox-veoutput-formatsz@List of output formats to use for the commands separated by ":".text)descdefaultc                    | j                  d      j                  d      }g d}g }|D ]"  }|j                  | j                  |             $ | j	                  |D cg c]  }|D ]  }d| d|dk(  rdnd d	|   c}}       y c c}}w )
Nr	   :)zcluster/resourceszcluster/config/nodeszcluster/optionsznodes/:id/statusznodes/:id/storageznodes/:id/networkpoolsstoragezstorage/:sidzcluster/ceph/statuszcluster/ceph/metadatazcluster/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':;	< 	 !
 (	
  Qv/?|RH I%h(
(
 	 
s    B
c           
         |j                  d      }g }t        d t        |      D        d      }|dj                  |d|       }dj                  ||dz   d       }| j	                  d| d      }|d   dk(  rJt        j                  |d	         }|D ]-  }	|j                  | j                  | d|	d
    d|              / |S |j                  dj                  |             |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
        /c              3   H   K   | ]  \  }}|j                  d       r|  yw)r   N)
startswith).0iparts      r   	<genexpr>z*Proxmox.build_cmd_paths.<locals>.<genexpr>O   s'      2wq$ OOC0  2s    "N   z	pvesh ls z --output-format jsonstatusr   outputname)
r   next	enumeratejoinexec_cmdjsonloadsr   r   append)
r   	base_pathpartspathsid_indexpathtrailing_pathresultschildrenchilds
             r   r   zProxmox.build_cmd_pathsB   s    $ 2)E*: 2379 88E)8,-DHHU8a<=%9:Mmmiv5J$KLGx A%::gh&78% ELL,,#fAeFm_Am_E  LL%)    N)__name__
__module____qualname____doc__
short_descplugin_namepackagesr   option_listr    r    r=   r   r   r      s>     /JKH 	"< 	K<!r=   r   )r1   sos.report.pluginsr   r   r   r   rF   r=   r   <module>rH      s      > >Tfl Tr=   