o
    i©¹dB
  ã                   @   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 informationÚ
infiniband)Úhardware)zlibibverbs-utilsÚopensmÚ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*)Úibv_deviceszibv_devinfo -vÚibstatÚibstatusÚ
ibswitches)ÚibhostsÚ
iblinkinfoÚsminfoÚ	perfqueryz/sys/class/infiniband/Ú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©Úoptsr   ú?/usr/lib/python3/dist-packages/sos/report/plugins/infiniband.pyÚ
<listcomp>P   s    z$Infiniband.setup.<locals>.<listcomp>)
Úadd_copy_specÚadd_cmd_outputÚ
path_isdirÚlistdirÚ
startswithÚopenÚIOErrorÚreadlineÚcloseÚendswith)
ÚselfÚ
ports_cmdsÚ
IB_SYS_DIRÚibsÚibÚportÚpÚ
link_layerÚsÚstater   r   r   Úsetup   sF   
	

ÿÿÿ
é÷zInfiniband.setupN)Ú__name__Ú
__module__Ú__qualname__Ú
short_descÚplugin_nameÚprofilesÚpackagesr-   r   r   r   r   r      s    r   N)Úsos.report.pluginsr   r   r   r   r   r   r   Ú<module>   s   
