U
    idB
                     @   s&   d dl mZmZ G dd deeZdS )    )PluginIndependentPluginc                   @   s$   e Zd ZdZdZdZdZdd ZdS )
InfinibandzInfiniband informationZ
infiniband)Zhardware)zlibibverbs-utilsZopensmZrdmazinfiniband-diagsc           
   
      sR  |  dddg |  d | ddddd	g d
dddg}d}| |rR| |ng }|D ]}|drjqZ| || d D ]}zt|| d | d }W n tk
r   Y q|Y nX | }|  |dkrq|zt|| d | d }W n tk
r   Y q|Y nX | }	|  |		ds&q|d||f  |  fdd|D  q|qZd S )Nz/etc/ofed/openib.confz/etc/ofed/opensm.confz	/etc/rdmaz/var/log/opensm*Zibv_deviceszibv_devinfo -vZibstatZibstatusZ
ibswitchesZibhostsZ
iblinkinfoZsminfoZ	perfqueryz/sys/class/infiniband/Zhfiz/portsz/ports/z/link_layerzInfiniBand
z/statez	: ACTIVE
z-C %s -P %sc                    s   g | ]}d | f qS )z%s %s ).0cZoptsr   ?/usr/lib/python3/dist-packages/sos/report/plugins/infiniband.py
<listcomp>P   s     z$Infiniband.setup.<locals>.<listcomp>)
Zadd_copy_specZadd_cmd_outputZ
path_isdirlistdir
startswithopenIOErrorreadlinecloseendswith)
selfZ
ports_cmdsZ
IB_SYS_DIRZibsZibZportpZ
link_layersstater   r   r	   setup   sX    





zInfiniband.setupN)__name__
__module____qualname__Z
short_descZplugin_nameZprofilesZpackagesr   r   r   r   r	   r      s
   r   N)Zsos.report.pluginsr   r   r   r   r   r   r	   <module>   s   