o
    *bB
  ã                   @   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           
   
      s8  |   g d¢¡ |   d¡ |  g d¢¡ g d¢}d}|  |¡r#|  |¡ng }|D ]r}	 | d¡r0q'|  || d ¡D ]_}zt|| d | d	 ƒ}W n	 tyR   Y q9w | ¡ }| ¡  |d
kr`q9zt|| d | d ƒ}W n	 tyw   Y q9w | ¡ }	| ¡  |	 	d¡s†q9d||f ‰ |  ‡ fdd„|D ƒ¡ q9q'd S )N)z/etc/ofed/openib.confz/etc/ofed/opensm.confz	/etc/rdmaz/var/log/opensm*)Zibv_deviceszibv_devinfo -vZibstatZibstatusZ
ibswitches)Z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   sF   
	

ÿÿÿ
é÷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   
