o
    id                     @   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 oneszEnable 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 containerszCapture '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+ qd 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 %s ).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 -asd   )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 %sr   )r   netr   r   r   r   [       networkspodman_network_inspect)subdirr"   c                 S   s   g | ]}|d  qS r$   r   )r   cr   r   r   r   _   r*   r   r	   )runtimeget_all)r/   zpodman inspect %s
containerspodman_container_inspectnoner   podman_image_inspectzpodman volume inspect %svolumespodman_volume_inspectr   zpodman logs -t %s2   )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netsr1   r   r5   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)rA   
env_regexpr   r   r   postproc{   s   zPodman.postprocN)__name__
__module____qualname____doc__
short_descplugin_nameprofilespackagesr   option_listrK   rN   r   r   r   r   r      s(    Ir   N)sos.report.pluginsr   r   r   r   r   r   r   r   r   <module>   s   
