o
    O6uf¶  ã                   @   s0   d dl mZmZmZmZ G dd„ deeeƒZdS )é    )ÚPluginÚRedHatPluginÚUbuntuPluginÚ	PluginOptc                   @   s\   e Zd ZdZdZdZdZdZedddd	d
�eddddd
�edddd�gZ	dd„ Z
dd„ ZdS )ÚPodmana<  Podman is a daemonless container management engine, and this plugin is
    meant to provide diagnostic information for both the engine and the
    containers that podman is managing.

    General status information will be collected from podman commands, while
    detailed inspections of certain components will provide more insight
    into specific container problems. This detailed inspection is provided for
    containers, images, networks, and volumes. Per-entity inspections will be
    recorded in subdirs within sos_commands/podman/ for each of those types.
    zPodman containersÚpodman)Ú	container)r   ÚallFz0collect for all containers, even terminated oneszÌEnable collection for all containers that exist on the system regardless of their running state. This may cause a significant increase in sos archive size, especially when combined with the 'logs' option.)ÚdefaultÚdescÚ	long_descÚlogsz)collect stdout/stderr logs for containerszÃCapture 'podman logs' output for discovered containers. This may be useful or not depending on how/if the container produces stdout/stderr output. Use cautiously when also using the 'all' option.Úsizez!collect image sizes for podman ps)r
   r   c                 C   s’  |   g d¢¡ |  dddœ¡ g d¢}|  dd„ |D ƒ¡ |  d¡r)| jd	d
d� |  ddg¡ | jddd�}|d dkrYdd„ |d  ¡ dd … D ƒ}| jdd„ |D ƒddd� dd„ | jd|  d¡d�D ƒ}| jdd�}| jdd�}|D ]}| jd|› �d d!d� qv|D ]}|\}	}
d"|	vr’|	n|
}| jd|› �d#d$d� q†|D ]}| jd%|› �d&d'd� q¢|  d(¡rÅ|D ]}| jd)|› �d d*d+� q·d S d S ),N)Ú
HTTP_PROXYÚHTTPS_PROXYÚNO_PROXYÚ	ALL_PROXYÚpodman_list_imagesÚpodman_list_containers)zpodman imagesz	podman ps)
ÚinfoÚimageszimages --digestszpod psz
port --allÚpszps -azstats --no-stream --allÚversionz	volume lsc                 S   ó   g | ]}d |› �‘qS )zpodman © )Ú.0Úsr   r   ú;/usr/lib/python3/dist-packages/sos/report/plugins/podman.pyÚ
<listcomp>L   s    z Podman.setup.<locals>.<listcomp>r   zpodman ps -aséd   )Úpriorityzls -alhR /etc/cnizls -alhR /etc/containerszpodman network lsÚpodman_list_networks)ÚtagsÚstatusr   c                 S   s   g | ]}|  ¡ d  ‘qS ©r   )Úsplit)r   Úpnr   r   r   r   Z   s    Úoutputé   c                 S   r   )zpodman network inspect r   )r   Únetr   r   r   r   [   s    
ÿÚnetworksÚpodman_network_inspect)Úsubdirr"   c                 S   s   g | ]}|d  ‘qS r$   r   )r   Úcr   r   r   r   _   s    ÿr   r	   )ÚruntimeÚget_all)r.   zpodman inspect Ú
containersÚpodman_container_inspectÚnoner   Úpodman_image_inspectzpodman volume inspect ÚvolumesÚpodman_volume_inspectr   zpodman logs -t é2   )r,   r    )	Úadd_env_varÚadd_cmd_tagsÚadd_cmd_outputÚ
get_optionÚcollect_cmd_outputÚ
splitlinesÚget_containersÚget_container_imagesÚget_container_volumes)ÚselfÚsubcmdsÚpnetsÚnetsr0   r   r4   r   ÚimgÚnameÚimg_idÚinspÚvolÚconr   r   r   Úsetup2   sj   þ
þÿ
ÿþÿÿþÿþ
ÿþzPodman.setupc                 C   s   d}|   d|d¡ d S )Nz=(?P<var>(pass|key|secret|PASS|KEY|SECRET).*?)=(?P<value>.*?)"z	*inspect*z\g<var>=********")Údo_cmd_output_sub)r@   Ú
env_regexpr   r   r   Úpostproc{   s   ÿzPodman.postprocN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú
short_descÚplugin_nameÚprofilesÚpackagesr   Úoption_listrJ   rM   r   r   r   r   r      s(    ýýÿñIr   N)Úsos.report.pluginsr   r   r   r   r   r   r   r   r   Ú<module>   s   
