a >h @s2ddlZddlmZmZmZGdddeeZdS)N)Plugin DebianPlugin PluginOptc@s<eZdZdZdZdZdZeddddgZd d Z d d 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-veoutput-formatsz@List of output formats to use for the commands separated by ":".text)ZdescdefaultcsR|ddgd}g}|D]}|||q |fdd|DdS)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$dndd|q qS)z pvesh get  rz --noborderz --output-format ).0cmdformatZoutput_formatsr >/usr/lib/python3.9/site-packages/sos/report/plugins/proxmox.py ;s z!Proxmox.setup..)Z get_optionsplitextendbuild_cmd_pathsZadd_cmd_output)selfZcommandsZ cmd_pathsZcommandr rrsetup$sz Proxmox.setupc Cs|d}g}tddt|Dd}|durd|d|}d||dd}|d|d}|dd krt|d }|D](} |||d| d d|qn| 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 |]\}}|dr|VqdS)r N) startswith)r ipartr r r Os  z*Proxmox.build_cmd_paths..Nz pvesh ls z --output-format jsonstatusroutputname) rnext enumeratejoinZexec_cmdjsonloadsrrappend) r base_pathpartspathsZid_indexpathZ trailing_pathresultsZchildrenchildr r rrBs&  zProxmox.build_cmd_pathsN) __name__ __module__ __qualname____doc__Z short_descZ plugin_nameZpackagesrZ option_listrrr r r rrsr)r$Zsos.report.pluginsrrrrr r r r s