U
    -_g                     @   s*   d dl mZmZmZ G dd deeZdS )    )PluginIndependentPlugin	PluginOptc                   @   sN   e Zd ZdZdZdZdZdZefZe	dddd	gZ
d
d Zdd Zdd ZdS )SHMclia  shmcli pulls hardware information from PowerVault/Dell
    Storage JBOD's attached to server.
    It provides information of the adapters, emms, drives,
    enclosures, fans, power supplies and the sensory data of
    temp, voltage, and current sensors.
    zDell Server Hardware Managershmcli)systemZstorageZhardwarezC/opt/dell/ServerHardwareManager/ServerHardwareManagerCLI/bin/shmclidebugFzcapture support debug data)defaultZdescc                 C   sH   dddg}|D ]$}| j | j d| d| d q|   |   d S )Nzlist adapterszlist physical enclosureszlist failed drives Zshmcli_suggest_filename)add_cmd_output
shmcli_bincollect_enclosures_listcollect_drivers_list)selfsubcmdssubcmd r   ;/usr/lib/python3/dist-packages/sos/report/plugins/shmcli.pysetup    s    zSHMcli.setupc              
      s  g }|  d}|d dkrb|d  D ]:   }t|dkr&|d  dkr&|  d  q&tt|}dd	d
dddddddg
}| j| j	 ddd}|d dkr|d  dd D ]̉    t
 fdd|D r d } d }|D ]<}| j	 d| d| d| }|| j	d}	| j||	d q| dr| jdd}
| j	 d | d| }|| j	d}d!|
 }| j|| |d"d# qd$S )%z  Collect info on the enclosures z	lsscsi -gstatusr   output   ZDELL   z	list emmszlist drawerszlist emm slotszlist drive slotsz	list fanszlist temp sensorszlist voltage sensorszlist current sensorszlist power supplieszinfo enclosurez list enclosuresZshmcli_list_enclosuresr   c                 3   s   | ]}| kV  qd S )Nr   ).0mliner   r   	<genexpr>Q   s     z1SHMcli.collect_enclosures_list.<locals>.<genexpr>r
   z -a=z -enc=r   r   F)Zmakez getdebugcli -a=z -outputdir=i,  )r   ZtimeoutN)Zexec_cmd
splitlinessplitlenupperappendlistsetcollect_cmd_outputr   anyreplacer   Z
get_optionZget_cmd_output_path)r   Zmodelsresultwordsr   Zadapt_indexZ	enc_indexr   _cmd_fnameZlogpathZ_dcmdZ_dnameZ_odirr   r   r   r   0   sV    



 zSHMcli.collect_enclosures_listc                 C   s   | j | j ddd}|d dkr|d  D ]T}| }t|dkr.|d dkr.| j d	|d  }|| jd
}| j||d q.dS )z Collect info on the drives z list drivesZshmcli_list_drivesr   r   r   r      )ZWWNz---z info drive -d=r   N)r)   r   r"   r#   r$   r+   r   )r   r,   r   r-   r.   r/   r   r   r   r   d   s    
zSHMcli.collect_drivers_listN)__name__
__module____qualname____doc__Z
short_descZplugin_nameZprofilesr   filesr   Zoption_listr   r   r   r   r   r   r   r      s   4r   N)Zsos.report.pluginsr   r   r   r   r   r   r   r   <module>	   s   