U
    -_g
                     @   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 ManagementZhpssm)systemZstorageZhardware)ZilorestssacliZssaduclidebugFzcapture debug data)defaultZdescc                    s   d dg}ddddddg|   fd	d
|D  td d }| |}g }|d dkrxfdd
|d  D } d |  fdd
|D  |  }| j d| ddd | dr| | d S )Nr   zctrl all show statusz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   ).0Z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 detailZstatusr   c                    s,   g | ]$}  |fD ]}|r|d q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   ZslotZ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compileZcollect_cmd_output
splitlinesZget_cmd_output_pathZ
get_optiondo_debug)selfZsubcmdsZconfig_detail_cmdZconfig_detailZ
ctrl_slotslogpathr   )r   r   r   r   r   setup   sD    





zHpssm.setupc                 C   s   | j d| |dd dS )z Collect debug logs z3ilorest serverlogs --selectlog=AHS --directorypath=zilorest.log)Zrunatr   N)r   )r    r!   r   r   r   r   I   s
     zHpssm.do_debugN)__name__
__module____qualname____doc__Z
short_descZplugin_nameZprofilesZpackagesr   Zoption_listr"   r   r   r   r   r   r      s   *r   )r   Zsos.report.pluginsr   r   r   r   r   r   r   r   <module>	   s   