
    -_g                     H    d dl Z d dlZd dlZd dlmZmZmZ  G d dee      Zy)    N)PluginRedHatPlugin	PluginOptc                   N    e Zd ZdZdZdZdZdZdZ e	ddd	
      gZ
d Zd Zd Zy)GlusterzGlusterFS storagegluster)storagevirtz/run/gluster)	glusterfszglusterfs-core)z/etc/glusterdz/var/lib/glusterddumpFzenable glusterdump support)defaultdescc                 X   d}| j                  |      D cg c]  }| j                  |      s| }}|D ]b  }|dz   }| j                  ||      }d}|dk(  s"t        |dd      5 }|j	                         d   }	|	j                  d      }ddd       |dk(  rAd yc c}w # 1 sw Y   xY w)	z Wait until state dump is done r      rzUTF-8)encodingDUMP_END_TIMEN)listdirpath_isfile	path_joinopen	readlinescount)
selfname_dirstatedumps_presentfstatedump_entriesstatedump_file_spathretsfile	last_lines
             </usr/lib/python3/dist-packages/sos/report/plugins/gluster.pywait_for_statedumpzGluster.wait_for_statedump   s    <<1
T5E5Ea5H
 
 0 	;N!3A!5^^Hn=FC)&#8 ;E % 1" 5I#///:C; )		;
; ;s   BB%%B  B)	c                    | j                  d      r| j                  | j                        sy 	 t        j                  | j                  dz         }|j	                  t        j                  | j                  dz                |D ]  }t        j                  |        y y # t        $ r}| j                  d|        Y d }~y d }~ww xY w)Nr   z/*.dump.[0-9]*z/glusterd_state_[0-9]*_[0-9]*z"Could not remove statedump files: )	
get_optionpath_existsstatedump_dirglobextendosremoveOSError
_log_error)r   remove_filesnameerrs       r%   postproczGluster.postproc-   s    ??6"##D$6$67L#yy););>N)NO##DIId.@.@$C/D %E F( $DIIdO$ #  L"DSE JKKLs   A/B   	C)CCc                    | j                  d       | j                  d       | j                  dd       | j                  d       | j                  dd       | j                  g d	t        j                  d
      z          | j	                  d      s| j                  g d       n| j                  d       | j	                  d      r| j                  | j                        rd}| j                  |      d   dk(  rLt        j                  d       | j                  | j                         | j                  | j                         nB| j                  j                  d       n&| j                  j                  d| j                         | j                  d      }|d   dk(  r'|d   j                         d   }| j                  |       | j                  dd      }|d   dk(  rp|d   j!                         D ]Y  }|j#                  d      s|dd  }| j                  d| dd| dd | d!d | d"d#| d$d%| d&| d'd(| dd)| d*| g
       [ y y )+Nz,/var/lib/glusterd/geo-replication/secret.pemz6/var/lib/glusterd/glusterfind/glusterfind_*_secret.pemzgluster peer statusgluster_peer_status)tagszgluster pool listzgluster volume statusgluster_v_status)z/etc/redhat-storage-releasez/etc/swift/z/etc/glusterd.rpmsavez/etc/glusterfsz/var/lib/glusterd/z(/run/gluster/shared_storage/nfs-ganesha/z$/var/lib/glusterd/glusterfind/.keys/z/run/gluster/*tier-dht/*all_logs)z/var/log/glusterfs/*logz/var/log/glusterfs/*/*logz)/var/log/glusterfs/geo-replication/*/*logz/var/log/glusterfsr   z+killall -USR1 glusterfs glusterfsd glusterdstatusr   r   z6could not send SIGUSR1 to glusterfs/glusterd processesz4Unable to generate statedumps, no such directory: %szgluster get-stateoutputr   zgluster volume infogluster_v_infozVolume Name:   zgluster volume get z allzgluster volume geo-replication z statuszgluster volume heal z infoz info split-brainzgluster volume status z clientszgluster snapshot list zgluster volume quota z listzgluster volume rebalance zgluster snapshot info zgluster snapshot status )add_forbidden_pathadd_cmd_outputadd_copy_specr+   r(   r)   r*   exec_cmdtimesleepr&   sosloginfowarningsplitcollect_cmd_output
splitlines
startswith)r   statedump_cmdstate
state_file
volume_cmdlinevolnames          r%   setupzGluster.setup:   s    NOD	
 	18MN/03!3 	 	5 	 
 II012 	3 z*    34??6" 2 23 M==/9Q> JJqM++D,>,>?&&t'9'9:KK$$ &: ; ## %4595G5GIMM"56EX!#"8_224R8
"":.,,-B2B - D
h1$"8,779 ~6rs)##)'$75gYgF*7)59*7)3DE,WIX>,WI6+G9E:/y@,WI6.wi8% 	 %    N)__name__
__module____qualname__
short_descplugin_nameprofilesr*   packagesfilesr   option_listr&   r4   rQ    rR   r%   r   r      sG    $JK"H"M.H2E 	&%.JKK;LIrR   r   )r+   r-   rB   sos.report.pluginsr   r   r   r   r\   rR   r%   <module>r^      s&     	  > >tfl trR   