o
    O6uf•
  ã                   @   s2   d dl Z d dlmZmZmZ G dd„ deeƒZdS )é    N)ÚPluginÚIndependentPluginÚ	PluginOptc                   @   s@   e Zd ZdZdZdZdZdZedddd	�gZ	d
d„ Z
dd„ ZdS )ÚHpssmaG  
    This plugin will capture details for each controller from Smart Storage
    Array Administrator, an Array diagnostic report from Smart Storage
    Administrator Diagnostics Utility and, when the plugins debug option is
    enabled will gather the Active Health System log via the RESTful Interface
    Tool (iLOREST).
    zHP Smart Storage ManagementÚhpssm)ÚsystemÚstorageÚhardware)ÚilorestÚssacliÚssaducliÚdebugFzcapture debug data)ÚdefaultÚdescc                    sÌ   d‰ dg}g d¢‰|   ‡ fdd„|D ƒ¡ t d¡‰ˆ d }|  |¡}g }|d d	kr8‡fd
d„|d  ¡ D ƒ}ˆ d ‰|   ‡‡fdd„|D ƒ¡ |  ¡ }| j d|› d�dd� |  d¡rd|  |¡ d S d S )Nr   zctrl all show status)zarray all show detailzld all showzld all show detailzpd all showzpd all show detailzshow detailc                    s   g | ]	}ˆ › d |› �‘qS ©ú © )Ú.0Úsubcmd)Úcmdr   ú:/usr/lib/python3/dist-packages/sos/report/plugins/hpssm.pyÚ
<listcomp>-   s    zHpssm.setup.<locals>.<listcomp>z#^HP[E] (.*) in Slot ([0123456789]+)z ctrl all show config detailÚstatusr   c                    s$   g | ]}ˆ   |¡}|r| d ¡‘qS )é   )ÚsearchÚgroup)r   ÚlineÚm)Úpatternr   r   r   5   s    þÚoutputz ctrl slot=c                    s(   g | ]}ˆ D ]}ˆ› |› d |› �‘qqS r   r   )r   ÚslotÚslot_subcmd)Úslot_subcmdsÚssacli_ctrl_slot_cmdr   r   r   :   s    þþzssaducli -v -adu -f z/adu-log.zipzssaducli_-v_-adu.log)Úsuggest_filenamer   )Úadd_cmd_outputÚreÚcompileÚcollect_cmd_outputÚ
splitlinesÚget_cmd_output_pathÚ
get_optionÚdo_debug)ÚselfÚsubcmdsÚconfig_detail_cmdÚconfig_detailÚ
ctrl_slotsÚlogpathr   )r   r   r"   r#   r   Úsetup   s:   ÿÿ



ÿÿÿ
þ
ÿzHpssm.setupc                 C   s   | j d|› �|dd� dS )z Collect debug logs z3ilorest serverlogs --selectlog=AHS --directorypath=zilorest.log)Úrunatr$   N)r%   )r-   r2   r   r   r   r,   I   s   
þzHpssm.do_debugN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú
short_descÚplugin_nameÚprofilesÚpackagesr   Úoption_listr3   r,   r   r   r   r   r      s    ÿ*r   )r&   Úsos.report.pluginsr   r   r   r   r   r   r   r   Ú<module>   s   