o
    Û1jÄ	  ã                   @   s.   d dl Z d dlmZmZ G dd„ deeƒZdS )é    N)ÚIndependentPluginÚPluginc                   @   s0   e Zd ZdZdZdZdZdZdd„ Zdd	„ Z	d
S )ÚGroutzGrout graph routerÚgrout)Únetwork)r   )zgrout.*c                 C   s|   g d¢}g d¢}|   | jd ¡}| j||d� |r*| j||d� |  t| jƒ¡ d S |  ddg¡ |  |¡ | jdd� d S )	N)zgrcli interfacezgrcli interface statszgrcli addresszgrcli routezgrcli nexthopzgrcli nexthop configzgrcli stats softwarezgrcli stats hardwarezgrcli affinity cpuszgrcli affinity qmapz	grcli fdbzgrcli fdb configzgrcli flood vtepzgrcli conntrackzgrcli conntrack configzgrcli dnat44zgrcli snat44z
grcli dhcpzgrcli router-advertzgrcli srv6 tunsrc)zip -d addressz
ip -d linkzip -4 routezip -6 router   )Ú	containerz/etc/grout.initz/etc/default/groutr   )Úunits)Úget_container_by_nameÚ
containersÚadd_cmd_outputÚadd_container_logsÚlistÚadd_copy_specÚ_collect_netns_ipÚadd_journal)ÚselfÚ
grcli_cmdsÚip_cmdsÚcon© r   ú:/usr/lib/python3/dist-packages/sos/report/plugins/grout.pyÚsetup   s   
zGrout.setupc                    sR   |   d¡}t d|d ¡D ]}|d ‰ ˆ dkrq‡ fdd„|D ƒ}|  |¡ qdS )	zåCollect iproute2 info from grout's private network namespace.

        When grout runs as a systemd service with PrivateNetwork=true,
        its netns is unnamed and only reachable via nsenter on the
        daemon PID.
        zsystemctl show -p MainPID groutzMainPID=(\d+)Úoutputr   Ú0c                    s   g | ]
}d ˆ › d|› �‘qS )znsenter --net -t ú r   )Ú.0Úcmd©Úpidr   r   Ú
<listcomp>L   s    z+Grout._collect_netns_ip.<locals>.<listcomp>N)Úcollect_cmd_outputÚreÚfinditerr   )r   r   ÚresÚmÚcmdsr   r   r   r   @   s   
ûzGrout._collect_netns_ipN)
Ú__name__Ú
__module__Ú__qualname__Ú
short_descÚplugin_nameÚprofilesÚpackagesr
   r   r   r   r   r   r   r      s    *r   )r!   Úsos.report.pluginsr   r   r   r   r   r   r   Ú<module>   s   