U
    -_g                     @   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descZ	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  |  ddddg | ddd dd	d
ddddddddg}| dd |D  | drh| jddd | jddgdd | jddd}|d  d!krd"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/d0d( q|D ]L}|\}	}
d1|	krB|	n|
}| jd.| d
d2d( | jd3| d4d5d( q(|D ]}| jd6| d7d8d( qz| d9r|D ]}| jd:| d/d;d< qd S )=NZ
HTTP_PROXYZHTTPS_PROXYZNO_PROXYZ	ALL_PROXYZpodman_list_imagesZpodman_list_containers)zpodman imagesz	podman psinfozimage trust showimageszimages --digestszpod psz
port --allZpszps -azstats --no-stream --allversionz	volume lsc                 S   s   g | ]}d | qS )zpodman  ).0sr   r   ;/usr/lib/python3/dist-packages/sos/report/plugins/podman.py
<listcomp>M   s     z Podman.setup.<locals>.<listcomp>r   zpodman ps -asd   )priorityz/etc/cniz/etc/containersT)	recursivezpodman network lsZpodman_list_networks)tagsZstatusr   c                 S   s   g | ]}|  d  qS r   )split)r   Zpnr   r   r   r   [   s     output   c                 S   s   g | ]}d | qS )zpodman network inspect r   )r   Znetr   r   r   r   \   s    ZnetworksZpodman_network_inspect)subdirr   c                 S   s   g | ]}|d  qS r   r   )r   cr   r   r   r   `   s    r   r	   )runtimeZget_all)r    zpodman inspect 
containersZpodman_container_inspectZnoneZpodman_image_inspectzpodman image tree zimages/treeZpodman_image_treezpodman volume inspect volumesZpodman_volume_inspectr   zpodman logs -t 2   )r   r   )
Zadd_env_varZadd_cmd_tagsZadd_cmd_outputZ
get_optionZadd_dir_listingZcollect_cmd_output
splitlinesZget_containersZget_container_imagesZget_container_volumes)selfZsubcmdsZpnetsZnetsr!   r   r"   r   ZimgnameZimg_idZinspZvolZconr   r   r   setup2   s    

 


 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>=********")Zdo_cmd_output_sub)r%   Z
env_regexpr   r   r   postproc   s    zPodman.postprocN)__name__
__module____qualname____doc__Z
short_descZplugin_nameZprofilesZpackagesr   Zoption_listr'   r(   r   r   r   r   r      s&   Or   N)Zsos.report.pluginsr   r   r   r   r   r   r   r   r   <module>   s   