Current File : //lib/python2.7/site-packages/sos/plugins/__init__.pyo
�
u��ec@�sedZddlmZddlmZmZmZmZmZm	Z	ddl
Z
ddlZddlZddl
Z
ddlmZddlZddlZddlZddlZddlmZmZddlmZyeWnek
r�eZnXd�Zd	�Zd
�Zd�Zd�Zd
�Zej dej!�Z"dZ#de$fd��YZ%de$fd��YZ&de$fd��YZ'de$fd��YZ(de(fd��YZ)de(fd��YZ*de(fd��YZ+de$fd��YZ,d e$fd!��YZ-d"e$fd#��YZ.d$e$fd%��YZ/d&e$fd'��YZ0e1d(�Z2dS()s; This exports methods available for use by plugins for sos i����(twith_statement(tsos_get_command_outputt
import_moduletgreptfileobjttailt
is_executableN(ttime(tziptfilter(tdatetimecC�sDt|tj�s@|jd�r.|d7}ntj|�}n|S(Ns\t (t
isinstancetsixt	text_typetendswithtu(ts((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt_to_u&s

cC�sNy5t|��#}tj||j�tj�SWdQXWntk
rIgSXdS(s=Return a list of all non overlapping matches in the string(s)N(Rtretfindalltreadt	MULTILINEtAttributeError(tregextfnametf((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt
regex_findall1s
&
cC�sYtjdd|�}tjdd|�}tjdd|�jd�}|d|!}|S(	Ns^/(usr/|)(bin|sbin)/ts[^\w\-\.\/]+t_t/t.s ._-i(Rtsubtstrip(tcommandtname_maxtmangledname((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt_mangle_command:s

c�st�fd�|D��S(Nc3�s|]}|�kVqdS(N((t.0tp(tpath(s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pys	<genexpr>Cs(tany(R(t	path_list((R(s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt_path_in_path_listBscC�sftjdftjdftjdftjdfg}x)|D]!}|d|j�r=|dSq=WdS(s� return a string indicating the type of special node represented by
    the stat buffer st (block, character, fifo, socket).
    sblock devicescharacter devices
named pipetsocketiiN(tstattS_ISBLKtS_ISCHRtS_ISFIFOtS_ISSOCKtst_mode(tstt_typestt((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt
_node_typeFs
cC�s
|jd�S(s�Check if a file appears to be compressed

    Return True if the file specified by path appears to be compressed,
    or False otherwise by testing the file name extension against a
    list of known file compression extentions.
    s.gzs.xzs.bzs.bz2(s.gzs.xzs.bzs.bz2(R(R(((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt_file_is_compressedUss-*BEGIN.*?-*ENDs
-----SCRUBBEDtSoSPredicatecB�s�eZdZdZeZgZgZgZ	gZ
gZeddd�Zd�Z
d�Zd�Zd�Zd�Zd�Zd	�Zd
�Zd�Zd�Zd
�Zd�Zd�Zd�Zd�Zegggggid�ZRS(s�A class to implement collection predicates.

        A predicate gates the collection of data by an sos plugin. For any
        `add_cmd_output()`, `add_copy_spec()` or `add_journal()` call, the
        passed predicate will be evaulated and collection will proceed if
        the result is `True`, and not otherwise.

        Predicates may be used to control conditional data collection
        without the need for explicit conditional blocks in plugins.
    Rc	C�s�d}d|j}|j}|r?g|D]}||^q)n|}|ddj|�7}|j}|r�g|D]}	||	^qrn|}|ddj|�7}|j}
|r�g|
D]}||^q�n|
}
|ddj|
�7}g|jD]4}d|d||d|d	||d	f^q�}
|d
dj|
�7}|j}|rug|D]}||^q_n|}|ddj|�7}|||S(sxReturn a string representation of this SoSPredicate with
            optional prefix, suffix and value quoting.
        s"%s"sdry_run=%s, skmods=[%s], t,sservices=[%s], spackages=[%s], s{ %s: %s, %s: %s }tcmdtoutputscmdoutputs=[%s], sarches=[%s](tdry_runtkmodstjointservicestpackagestcmd_outputstarch(tselftquotetprefixtsuffixtquotestpstrR=tkR?RtpkgsR't	cmdoutputt
cmdoutputstarchesta((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt__str�s$
	)	)	)A	)cC�s
|j�S(s�Return a string representation of this SoSPredicate.

            "dry_run=False, kmods=[], services=[], cmdoutputs=[]"
        (t_SoSPredicate__str(RC((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt__str__�scC�s|jdtdddd�S(s�Return a machine readable string representation of this
            SoSPredicate.

            "SoSPredicate(dry_run=False, kmods=[], services=[], cmdoutputs=[])"
        RDREs
SoSPredicate(RFt)(RPtTrue(RC((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt__repr__�scC�sG|dkrt|�S|dkr,t|�S|dkrCt|�SdS(s�Helper to simplify checking the state of the predicate's evaluations
        against the setting of the required state of that evaluation
        R)talltnoneN(R)RU(RCtitemstrequired((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt_check_required_state�s

cC�sH|j|}|dkr0|j|j|�n|j|j|�dS(s�Helper to direct failed predicates to provide the proper messaging
        based on the required check type

            :param test:      The type of check we're doing, e.g. kmods, arch
            :param item:      The string of what failed
        RVN(RXt_failedtappendt
_forbidden(RCttesttitemt_req((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt_failed_or_forbidden�s
cC�s�|js|jjd�r tSg}xI|jD]>}|jj|�}|j|�|s0|jd|�q0q0W|j||jd�S(Ntallow_system_changesR=(	R=t_ownert
get_optionRStis_module_loadedR[R`RYRX(RCt_kmodstkmodtres((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt_eval_kmods�s
cC�sv|js
tSg}xI|jD]>}|jj|�}|j|�|s|jd|�qqW|j||jd�S(NR?(R?RSRbtis_service_runningR[R`RYRX(RCt_svcstsvcRg((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt_eval_services�s	
cC�sv|js
tSg}xI|jD]>}|jj|�}|j|�|s|jd|�qqW|j||jd�S(NR@(R@RSRbtis_installedR[R`RYRX(RCt_pkgstpkgRg((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt_eval_packages�s	
cC�ssd|ksd|krtSt|d�}|ddkr@tSx,|dj�D]}|d|krQtSqQWtS(s*Does 'cmd' output contain string 'output'?R:R;tstatusi(tFalseRt
splitlinesRS(RCt
cmd_outputtresulttline((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt_eval_cmd_output�scC�s�|js
tSg}xX|jD]M}|j|�}|j|�|s|jdd|d|df�qqW|j||jd�S(NRAs%s: %sR:R;(RARSRwR[R`RYRX(RCt_cmdsR:Rg((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt_eval_cmd_outputss	
 cC�s�|js
tS|jjj�}ddj|j�}|jddkrvtj||�rr|j	dj
|�tStStj||�r�tS|jdj
|�tS(Ns(?:%s)t|RBRVtarchitecture(
RBRSRbtpolicytget_archR>RXRtmatchR\R[RrRZ(RCt_archR((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt
_eval_archs	cC�sod}d}x\|jj�D]K\}}|s4qnt|�}|||djd�|D��f7}qW|S(s\Return a string informing user what caused the predicate to fail
        evaluation
        Rsrequired %s missing: %s.s, cs�s|]}|VqdS(N((R&tv((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pys	<genexpr>,s(RZRWtsetR>(RCtmsgt_substrtkeytval((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt_report_failed"s+cC�sod}d}x\|jj�D]K\}}|s4qnt|�}|||djd�|D��f7}qW|S(sxReturn a string informing the user that a forbidden condition exists
        which caused the predicate to fail
        Rsforbidden %s '%s' found.s, cs�s|]}|VqdS(N((R&R�((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pys	<genexpr>9s(R\RWR�R>(RCR�R�R�R�((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt_report_forbidden/s+cC�s+|j�|j�g}dj|�j�S(s}Used by `Plugin()` to obtain the error string based on if the reason
        was a failed check or a forbidden check
        R(R�R�R>tlstrip(RCR�((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pytreport_failure<scC�sxt|j|j|j|j|j|jg�s4tS|j�ow|j	�ow|j
�ow|j�ow|j�ow|jS(s#Predicate evaluation hook.
        (
R)R=R?R@RARBR<RSRhRlRpRyR�(RC((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt__nonzero__CscC�s
|j�S(N(R�(RC((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt__bool__Qsc		�s4|�_t|��_t|��_t|��_t|��_t|t�s`|g}n|�_|�jjdj	B�_	idd6dd6dd6dd6dd6�_
�j
j��fd��j�D��igd6gd6gd6gd6gd	6�_
igd6gd6gd6gd6gd	6�_d
S(s.Initialise a new SoSPredicate object.
        tcmdlineoptsR)R=R?R@RARBc�s6i|],\}}�|�j|kr||�qS((RX(R&RIR�(RXRC(s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pys
<dictcomp>fs		R{N(RbtlistR=R?R@RBRRAtcommonsR<RXtupdateRWRZR\(	RCtownerR<R=R?R@RARBRX((RXRCs8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt__init__Vs&			 
N(t__name__t
__module__t__doc__tNoneRbRrR<R=R?R@RARBRPRQRTRYR`RhRlRpRwRyR�R�R�R�R�R�R�(((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyR8cs4
"				
		
	
				
	
				t
SoSCommandcB�s eZdZd�Zd�ZRS(s�A class to represent a command to be collected.

    A SoSCommand() object is instantiated for each command handed to an
    _add_cmd_output() call, so that we no longer need to pass around a very
    long tuple to handle the parameters.

    Any option supported by _add_cmd_output() is passed to the SoSCommand
    object and converted to an attribute. SoSCommand.__dict__ is then passed to
    _get_command_output_now() for each command to be collected.
    cK�s|jj|�dS(N(t__dict__R�(RCtkwargs((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyR��scC�s&djd�t|jj��D��S(sIReturn a human readable string representation of this SoSCommand
        s, cs�s%|]\}}d||fVqdS(s%s=%rN((R&tparamR�((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pys	<genexpr>�s(R>tsortedR�RW(RC((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyRQ�s(R�R�R�R�RQ(((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyR�ts
	tPlugincB�s7eZdZdZZeZdZd[Zd\Z	d]Z
d^Zd_ZdZZ
dZZd`ZdZdZdZeZdZZdZZdadd	defgZd
�Zed��Zd�Zed
��Zd�Zd�Zd�Z d�Z!d�Z"d�Z#d�Z$d�Z%d�Z&d�Z'd�Z(d�Z)d�Z*d�Z+d�Z,d�Z-d�Z.d�Z/edZd �Z0edZd!�Z1eeed"�Z2d#d$�Z3d%�Z4d#d&�Z5d'�Z6d(�Z7d)�Z8d*�Z9d+�Z:d,�Z;d-�Z<d.�Z=dZd/�Z>d0�Z?d1�Z@d2�ZAd3d4�ZBd5dZd6�ZCd7�ZDdZdZedZd8�ZEd9�ZFdZdZeeedZdZedZdZdZeed:�
ZGdZed;�ZHd<�ZId=�ZJdZd>�ZKd?�ZLdZd@�ZMdZeeeedZdZedZdZeedA�ZNdZeeeedZdZedZdZdZdB�ZOeeedZdZedZedC�ZPdD�ZQdE�ZRdF�ZSdG�ZTdZdZdZdZdZedZedZdZdZdZdH�ZUedI�ZVdJ�ZWdK�ZXdL�ZYdM�ZZdN�Z[dO�Z\dP�Z]dQ�Z^dR�Z_dS�Z`dT�ZadU�ZbdV�ZcdW�ZddX�ZedY�ZfRS(bsA This is the base class for sosreport plugins. Plugins should subclass
    this and set the class variables where applicable.

    plugin_name is a string returned by plugin.name(). If this is set to None
    (the default) class\_.__name__.tolower() will be returned. Be sure to set
    this if you are defining multiple plugins that do the same thing on
    different platforms.

    requires_root is a boolean that specifies whether or not sosreport should
    execute this plugin as a super user.

    version is a string representing the version of the plugin. This can be
    useful for post-collection tooling.

    packages (files) is an iterable of the names of packages (the paths
    of files) to check for before running this plugin. If any of these packages
    or files is found on the system, the default implementation of
    check_enabled will return True.

    profiles is an iterable of profile names that this plugin belongs to.
    Whenever any of the profiles is selected on the command line the plugin
    will be enabled (subject to normal check_enabled tests).
    tunversionedRi,ttimeoutsTimeout in seconds for plugintfasti����tpostprocs,Enable post-processing collected plugin datacC�s[t|dt�sg|_ng|_g|_t�|_g|_d|_g|_	g|_
||_g|_t�|_
g|_g|_|d|_|d|_d|jkr�|jdntjd�|_|jj|j�xV|jD]K}|j	j|d�|j
ji|dd	6|d
d6|dd
6�q�W|jt|��dS(Ntoption_listRtsysrootR|tsoslogtsosiitdescitspeeditenabled(tgetattrRrR�tcopied_filestexecuted_commandsR�t	_env_varstalertstcustom_textt	opt_namest	opt_parmsR�tforbidden_pathst
copy_pathstcopy_stringstcollect_cmdsR�R|tloggingt	getLoggerR�textendt_default_plug_optsR[t
set_predicateR8(RCR�topt((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyR��s0										

"cC�s�d}y�|jd�}t|jd��}|dkrB|}nL|dk	ri|dkrit|�}n%|dk	r�|dkr�|}ndSWntk
r�|jSX|dk	r�|dkr�|S|jS(s�Returns either the default plugin timeout value, the value as
        provided on the commandline via -k plugin.timeout=value, or the value
        of the global --plugin-timeout option.
        tplugin_timeoutR�i����N(R�Rctintt
ValueErrorR�(RCt_timeouttopt_timeouttown_timeout((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyR��s 		
cC�s|jS(sV
        Checks to see if the plugin has hit its timeout.

        This is set when the sos.collect_plugin() method hits a timeout and
        terminates the thread. From there, a Popen() call can still continue to
        run, and we need to manually terminate it. Thus, check_timeout() should
        only be called in sos_get_command_output().

        Since sos_get_command_output() is not plugin aware, this method is
        handed to that call to use as a polling method, to avoid passing the
        entire plugin object.

        Returns True if timeout has been hit, else False.

        (t_timeout_hit(RC((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt
check_timeout�scC�s|jr|jS|jj�S(s^Returns the plugin's name as a string. This should return a
        lowercase string.
        (tplugin_nameR�tlower(tcls((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pytnames	cC�sd|j�|fS(Ns[plugin:%s] %s(R�(RCR�((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt_format_msgscC�s|jj|j|��dS(N(R�terrorR�(RCR�((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt
_log_errorscC�s|jj|j|��dS(N(R�twarningR�(RCR�((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt	_log_warnscC�s|jj|j|��dS(N(R�tinfoR�(RCR�((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt	_log_infoscC�s|jj|j|��dS(N(R�tdebugR�(RCR�((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt
_log_debugscC�s6|dtjkr |d}ntjj|j|�S(Nii(tostsepR(R>R�(RCR(((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pytjoin_sysroot s
cC�s7|j�s|S|j|j�r3|t|j�S|S(N(tuse_sysroott
startswithR�tlen(RCR(((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt
strip_sysroot%s
cC�s|jtjjtj�kS(N(R�R�R(tabspathR�(RC((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyR�,scC�s1|j|jj�g}tjj|�|jkS(N(R�tarchivetget_tmp_dirR�R(tcommonprefix(RCtpaths((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyttmp_in_sysroot/scC�s|jj|�dk	S(s'Is the package $package_name installed?N(R|tpkg_by_nameR�(RCtpackage_name((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyRm3scC�s|jjj|�S(s+Does the service $name exist on the system?(R|tinit_systemt
is_service(RCR�((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyR�7scC�s|jjj|�S(sIs the service $name enabled?(R|R�t
is_enabled(RCR�((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pytis_service_enabled;scC�s|jjj|�S(sIs the service $name disabled?(R|R�tis_disabled(RCR�((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pytis_service_disabled?scC�s|jjj|�S(s'Is the service $name currently running?(R|R�t
is_running(RCR�((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyRiCscC�s|jjj|�dS(s,Return the reported status for service $nameRq(R|R�tget_service_status(RCR�((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyR�GscC�s|jjj|�S(s$Get all service names matching regex(R|R�tget_service_names(RCR((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyR�KscC�s
||_dS(s<Set or clear the default predicate for this plugin.
        N(t	predicate(RCtpred((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyR�OscC�s
||_dS(s�Set or clear the default predicate for command collection
            for this plugin. If set, this predecate takes precedence
            over the `Plugin` default predicate for command and journal
            data collection.
        N(t
cmd_predicate(RCR�((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pytset_cmd_predicateTscC�s3|dk	r|S|r,|jdk	r,|jS|jS(sqGet the current default `Plugin` or command predicate. If the
            `cmd` argument is `True`, the current command predicate is
            returned if set, otherwise the default `Plugin` predicate
            will be returned (which may be `None`).

            If no default predicate is set and a `pred` value is passed
            it will be returned.
        N(R�R�R�(RCR:R�((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt
get_predicate\s
	cC�s2|jd|d|�}|dk	r.t|�StS(s1Test the current predicate and return its value.

            :param cmd: ``True`` if the predicate is gating a command or
                        ``False`` otherwise.
            :param pred: An optional predicate to override the current
                         ``Plugin`` or command predicate.
        R:R�N(R�R�tboolRr(RCR:R�((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyttest_predicateks
cC�s:d||j�f}|r)|d7}n|j|�dS(sLog that a command was skipped due to predicate evaluation.

            Emit a warning message indicating that a command was skipped due
            to predicate evaluation. If ``kmods`` or ``services`` are ``True``
            then the list of expected kernel modules or services will be
            included in the log message. If ``allow_changes`` is ``True`` a
            message indicating that the missing data can be collected by using
            the "--allow-system-changes" command line option will be included.
        sskipped command '%s': %ss3 Use '--allow-system-changes' to enable collection.N(R�R�(RCR�R:R=R?tchangesR�((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pytlog_skipped_cmdxs
RcC�sM|js
dS|jd|�|r4dt|fnt}|j|t|�S(shRemove certificate and key output archived by sosreport. cmd
        is the command name from which output is collected (i.e. exlcuding
        parameters). Any matching instances are replaced with: '-----SCRUBBED'
        and this function does not take a regexp or substituting string.

        This function returns the number of replacements made.
        is1Scrubbing certs and keys for commands matching %ss%s %s(R�R�t
_cert_replacetdo_cmd_output_subt
_certmatch(RCR:R�treplace((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pytdo_cmd_private_sub�s		c
C�s�d|d}t|d�r&|jn|}|jd|||f�|jsSdSd}y�x�|jD]�}|ddkr�qfn|ddkr�|jd|d	�qfntj|d
|�rftjj	|j
d|d�}|jd|�|jj|�}	t
j|||	j��\}
}|rF|jj|
|�qFqfqfWWn:tk
r�}d
}|j||d	|f�d}nX|S(s_Apply a regexp substitution to command output archived by sosreport.
        cmd is the command name from which output is collected (i.e. excluding
        parameters). The regexp can be a string or a compiled re object. The
        substitution string, subst, is a string that replaces each occurrence
        of regexp in each file collected from cmd. Internally 'cmd' is treated
        as a glob with a leading and trailing '*' and each matching file from
        the current module's command list is subjected to the replacement.

        This function returns the number of replacements made.
        t*tpatterns4substituting '%s' for '%s' in commands matching '%s'itfiletbinarytyess6Cannot apply regex substitution to binary output: '%s'texeR:tcmddirsapplying substitution to '%s's-regex substitution failed for '%s' with: '%s'N(thasattrR�R�R�R�R�tfnmatchR�R(R>R�R�t	open_fileRtsubnRt
add_stringt	ExceptionR�(
RCR:tregexptsubsttglobstrR�treplacementstcalledR(treadableRuteR�((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyR��s8			 !
c	C�s�|jd|�tj|�j}|r9dt|fnt}g|jD]}||d�rI|^qI}x7|D]/}|d}|s�qrn|j|t|�qrWdS(s�Scrub certificate/key/etc information from files collected by sos.

        Files matching the provided pathregex are searched for content that
        resembles certificate, ssh keys, or similar information. Any matches
        are replaced with "-----SCRUBBED $desc" where `desc` is a description
        of the specific type of content being replaced, e.g.
        "-----SCRUBBED RSA PRIVATE KEY" so that support representatives can
        at least be informed of what type of content it was originally.

        Positional arguments:
            :param pathregex: A string or regex of a filename to match against
            :param desc: A description of the replaced content
        s.Scrubbing certs and keys for paths matching %ss%s %stsrcpathtdstpathN(R�RtcompileR~R�R�tdo_file_subR�(	RCt	pathregexR�R~R�Rt	file_listtiR(((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pytdo_file_private_sub�s	,

cC�sWy�|j|�}t|d�r*|jn|}|jd|�|jd|||f�|sedS|jj|�}|j�}t|tj	�s�|j
dd�}ntj|||�\}}	|	r�|jj
||�nd}	Wnhttfk
rR}
|
jtjkr,d}|j||�nd}|j|||
f�d}	nX|	S(	sgApply a regexp substitution to a file archived by sosreport.
        srcpath is the path in the archive where the file can be found.  regexp
        can be a regexp string or a compiled re object.  subst is a string to
        replace each occurance of regexp in the content of srcpath.

        This function returns the number of replacements made.
        R�ssubstituting scrpath '%s's"substituting '%s' for '%s' in '%s'itutf8tignores-file '%s' not collected, substitution skippeds-regex substitution failed for '%s' with: '%s'(t_get_dest_for_srcpathR�R�R�R�R�RRR
tstring_typestdecodeRR�RtOSErrortIOErrorterrnotENOENTR�(RCR	RRR(R�RtcontentRuRRR�((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyR�s0	

cC�s�t|d�s!tj|�}n|j}g|jD]}||d�r4|^q4}x%|D]}|j|d||�q]WdS(szApply a regexp substituation to a set of files archived by
        sos. The set of files to be substituted is generated by matching
        collected file pathnames against pathexp which may be a regular
        expression string or compiled re object. The portion of the file
        to be replaced is specified via regexp and the replacement string
        is passed in subst.R~R	N(R�RRR~R�R(RCtpathexpRRR~RRR�((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pytdo_path_regex_subs	,
cC�s
t||�S(N(R(RCRR((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pytdo_regex_find_allsc	C�stj|�}tjjtjj|�|�}tjj|�}tjj|�r�tjjtjj|��}tjj|d|�}|j	�r�|t
tjtj�}n|j
d||f�n|}|j
d||tjj|�f�|j|�}|jj||�tjj|�rB|j
d|�dS|jji|d6|d6dd6|d	6�ytj|�Wn7tk
r�}|jd
kr�|j
d|�dSnX|j
d||f�||kr�|j|�n|j
d
|�dS(Ntstarts&made link target '%s' relative as '%s's0copying link '%s' pointing to '%s' with isdir=%ss%link '%s' is a directory, skipping...R	R
R�tsymlinktpointstoi(s;link '%s' is part of a file system loop, skipping target...s#normalized link target '%s' as '%s's.link '%s' points to itself, skipping target...(R�treadlinkR(R>tdirnametnormpathtisabstrealpathtrelpathR�R�R�tpardirR�tisdirR�R�tadd_linkR�R[R-RRt
_do_copy_path(	RCR	tlinkdesttdesttabsdesttrealdirtreldestR
R((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt
_copy_symlinksF!					cC�s�yWxPtj|�D]?}|jd||f�tjj||�}|j|�qWWn�tk
r�}|jtjks�tj	r�d}|j
d||f�dS|jtjkr�d}|jd||f�dS�nXdS(Ns!recursively adding '%s' from '%s'sPermission denieds_copy_dir: '%s' %ss)Too many levels of symbolic links copyings_copy_dir: %s '%s'(
R�tlistdirR�R(R>R*RRtEPERMtEACCESR�tELOOPR�(RCR	R�R(RR�((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt	_copy_dirRs 	cC�sN|j�r|j|�}nx)|jD]}||dkr(|dSq(WdS(NR	R
(R�R�R�R�(RCR	tcopied((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyRdscC�st||j�S(N(R+R�(RCR(((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt_is_forbidden_pathlscC�sStj|j�}tj|j�}|j}|jj||tj||��dS(N(R�tmajortst_rdevtminorR2R�tadd_nodetmakedev(RCR(R3tdev_majtdev_mintmode((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt
_copy_nodeos	cC�s�|jr
dS|j|�r1|jd|�dS|s@|}n|j�r^|j|�}nytj|�}Wn)ttfk
r�|j	d|�dSXt
j|j�r�|j
|�dSt
j|j�rtj|tj�rtj|�s
|jj|�dS|j|�dSt
j|j�p<t
j|j�svt|�}|jd||f�|j||�dS|jd||f�|jd@s�|jjd|�n|jj||�|jji|d6|d	6d
d6�dS(s�Copy file or directory to the destination tree. If a directory, then
        everything below it is recursively copied. A list of copied files are
        saved for use later in preparing a report.
        Nsskipping forbidden path '%s'Rsfailed to stat '%s's creating %s node at archive:'%s's!copying path '%s' to archive:'%s'i$R	R
tnoR(R�R7R�R�R�R�tlstatRRR�R-tS_ISLNKR2R0tS_ISDIRtaccesstR_OKR1R�tadd_dirR5tS_ISREGR6R@Rtadd_fileR�R[(RCR	R,R3tntype((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyR*vsJ		
'
$	
cC�s�t|tj�r|g}n|j�rOg|D]}|j|�^q1}nxI|D]A}|jd|�x'tj|�D]}|jj|�q}WqVWdS(snSpecify a path, or list of paths, to not copy, even if it's
            part of a copy_specs[] entry.
        sadding forbidden path '%s'N(	RR
RR�R�R�tglobR�R[(RCt	forbiddenRtforbidR(((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pytadd_forbidden_path�s%
cC�s|j|jfS(s%return a list of all options selected(R�R�(RC((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pytget_all_options�scC�s�x�t|j|j�D]i\}}||krt|d�}|t|�krq|td�krq||�}n||d<tSqWtS(smSet the named option to value. Ensure the original type
           of the option value is preserved.
        R�N(RR�R�ttypeR�RSRr(RCt
optionnametvalueR�tparmstdefaulttype((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt
set_option�s"$
icC�syd	}||kr&t|jd|�SxLt|j|j�D]5\}}||kr<|d}|d
k	rq|Sq<q<W|S(sHReturns the first value that matches 'optionname' in parameters
        passed in via the command line or set via set_option or via the
        global_plugin_options dictionary, in that order.

        optionaname may be iterable, in which case the first option that
        matches any of the option names is returned.
        tall_logsRatlog_sizeR�tsincetverifyR�R�(sall_logssallow_system_changesslog_sizesplugin_timeoutssinceRYN(R�R�RR�R�R�(RCRQtdefaulttglobal_optionsR�RSR�((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyRc�s
"
R9cC�sg|j|�}y?g|j|�D]}|j�^q"}ttd|��SWntk
rb|SXdS(sTWill try to return the option as a list separated by the
        delimiter.
        N(RctsplitR!R�R	R�R(RCRQt	delimiterRZtoptionR�topt_list((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pytget_option_as_list�s(
cC�s|jj|�dS(N(R�R�(RCR�((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt_add_copy_paths�sc�s�d�|jd�r'|jd��ntjd��tjd|jd���|jd|�s�|jd||jd|�f�dS|dkr�|jd�}n|jd	�r�d}n|r�|d9}n|s�tSt	|t
j�r�|g}nx�|D]�}|ot|�stS|j
�r=|j|�}n|j|�}t|�dkrdqnd�������fd
���s��r�tt�fd�|��}n|jd�dt�d}t}	x�|D]�}
|
|jkr
|jd|
�q�n|j|
�r0|jd|
�q�n|	rM|jd|
�q�nytj|
�}Wn%tk
r�|jd|
�q�nX||tj7}|r�||kr�t}	|r�t|
�r�|jd|
�|
}|dtjkr|jtj�}n|jtjjd�d}
|jt |
|�|
�tjj!dtjj"|
��}tjj#|d|j$�|
�}|j%j&||
�q�|jd|
�q�|j'|
g�q�WqWdS(s-Add a file or glob but limit it to sizelimit megabytes. Collect
        files with mtime not older than maxage hours.
        If fname is a single file the file will be tailed to meet sizelimit.
        If the first file in a glob is too large it will be tailed to meet
        the sizelimit.
        RXs".*((\.(zip|gz|bz2|xz))|[-.][\d]+)$s^%s/*tetcR�s,skipped copy spec '%s' due to predicate (%s)NRWRViicS�s-ytjj|�SWntk
r(dSXdS(Ni(R�R(tgetmtimeR(R(((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyRc/s
c�sz�j|�dks*�j|�dk	r.tStj�|��}�rU|�ksr�rvt�|�dkrvtStS(sp When --since is passed, or maxage is coming from the
                plugin, we need to filter out older files iN(tsearchR�RSR
t
fromtimestampRRr(R(tfiletime(tconfigfile_patternRctlogarchive_patterntmaxageRX(s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyttime_filter5sc�s
�|�S(N((R(Rj(s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt<lambda>DsR�treversesskipping redundant file '%s'sskipping forbidden path '%s'sskipping '%s' over size limitsfailed to stat '%s's)collecting tail of '%s' due to size limitRs.tailedRtsos_stringsi((R�RcRRR�R�R�R�RrRR
RR�R�t_expand_copy_specR�R	tsortRSR�R�R7R�R-RtST_SIZER7R�R�R�R(tadd_string_as_fileRR&R"R>R�R�R)Ra(RCt	copyspecst	sizelimitRittailitR�tcopyspectfilestcurrent_sizet
limit_reachedt_filetfilestatt	file_nametstrfiletrel_patht	link_path((RgRcRhRiRXRjs8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt
add_copy_spec�s�		

	!

	!c	K�s�d|kr|jd�nd}t|�}|jd|j��|jdtd|�r�|jj|�|j	d|j
�n:|j||j
dt|j
�dt|j�d|j�dS(	s?Internal helper to add a single command to the collection list.R�spacked command: R:sadded cmd output '%s'R=R?R�N(tpopR�R�R�RQR�RSR�R[R�R:R�R�R=R?R�(RCR�R�tsoscmd((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt_add_cmd_outputts!!c C�s�t|tj�r|g}nt|�dkrL|s<|rL|jd�n|
dkrj|jd�}
n|dkr�|jdt�}nxl|D]d}|j	d|d|d|d|d|d	|d
|d|d|	d
|
d|d|d|
d|�q�WdS(s:Run a program or a list of programs and collect the outputis.ambiguous filename or symlink for command listRWR:tsuggest_filenametroot_symlinkR�tstderrtchroottrunattenvR�RsR�tsubdirR�t
foregroundN(
RR
RR�R�R�RcR�RSR�(RCtcmdsR�R�R�R�R�R�R�R�RsR�R�R�R�R:((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pytadd_cmd_output�s
cC�s_tjj|jj�d|j��}|rEtjj||�}n|r[tj|�n|S(s[Return a path into which this module should store collected
        command output
        tsos_commands(R�R(R>R�R�R�tmakedirs(RCR�tmaketcmd_output_path((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pytget_cmd_output_path�scG�s
t||�S(s�Returns lines matched in fnames, where fnames can either be
        pathnames to files to grep through or open file objects to grep through
        line by line.
        (R(RCRtfnames((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt	file_grep�scC�s|jj�}t||�S(N(R�R#R%(RCR�R#((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyR%�sc
C�sX|j�}|r0|d|jd�d7}ntjj|jd|�}|j|�}tjjtjj|jj	�||��rEd}|jj
�}x�trAd|}|}	|t|	�t|�kr�|	|t|	�t|� }	n|	|}	tjjtjj|jj	�||	��s4|	}Pn|d7}q�Wntjj||�S(s@The internal function to build up a filename based on a command.s/%sRiR�is.%d(
R�R\R�R(R>R�R%texistsR�R�R#RSR�(
RCR�R�t
plugin_dirtoutdirtoutfntincR#RFtnewfn((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt_make_command_filename�s*	
!
cC�sUt|t�s|g}nx3|D]+}|jj||j�|j�g�q"WdS(sAdd an environment variable to the list of to-be-collected env vars.

        Accepts either a single variable name or a list of names. Any value
        given will be added as provided to the method, as well as an upper-
        and lower- cased version.
        N(RR�R�R�tupperR�(RCR�R�((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pytadd_env_var�s
cC�s�|r|j�dnd}t|tj�sC|jdd�}n|jdtd|�s�|jd||jd|�f�dS|j	j
||f�|jd	||f�dS(
s6Add a string to the archive as a file named `filename`iRRRR:R�s,skipped string ...'%s' due to predicate (%s)Nsadded string ...'%s' as '%s'(RsRR
RRR�RrR�R�R�R[R�(RCRtfilenameR�tsummary((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyRq�s	cC�s�|jr
dS|s)|jdjdkr5|j}nd}t�}t|d|d|d|d|d|d	|	d
|
d|jd|
�	}|d
dkr�|jd||f�n|d
dks�|d
dkr�|r[|dkr[|jdjdkr[|j	d|j
�d|f�t|d|dtd|d|d	|	d
|
d|j�}q[n|jd|�|d
d kr�|Sn|jd|j
�dt�||f�|r�|j
||�}n|j
||�}|t|jd�d}|	r|jj|d|�n|jj|d|�|rI|jj||�n|jji|d6|d6|	rodndd	6�|r�tjj|jj�|�nd|d<|S(!s-Execute a command and save the output to a file for inclusion in the
        report.

        Positional Arguments:
            :param cmd:                 The command to run

        Keyword Arguments:
            :param suggest_filename:    Filename to use when writing to the
                                        archive
            :param root_symlink:        Create a symlink in the archive root
            :param timeout:             Time in seconds to allow a cmd to run
            :param stderr:              Write stderr to stdout?
            :param chroot:              Perform chroot before running cmd?
            :param runat:               Run the command from this location,
                                        overriding chroot
            :param env:                 Dict of env vars to set for the cmd
            :param binary:              Is the output in binary?
            :param sizelimit:           Maximum size in MB of output to save
            :param subdir:              Subdir in plugin directory to save to
            :param changes:             Does this cmd potentially make a change
                                        on the system?

        :returns:       dict containing status, output, and filename in the
                        archive for the executed cmd

        NR�talwaysR�R�R�tchdirR�R�RstpollerR�Rqi|s command '%s' timed out after %dsi~iRs5command '%s' not found in %s - re-trying in host rootis%could not run '%s': command not founds+collected output of '%s' in %s (changes=%s)R�iR;R:R�R�RARR�(i~i(R�R�R�R�R�RRR�R�R�R\RrR�R�R�R�t
add_binaryRR)R�R[R�R(R>tget_archive_path(RCR:R�R�R�R�R�R�R�R�RsR�R�R�trootRRuR�toutfn_strip((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt_collect_cmd_output�sR		 		"$
c

C�s�|jdtd|�sZ|jd||jdtd|�f�idd6dd6dd6S|j|d|d	|d
|d|d|d
|d|d|	d|
d|�
S(s]Execute a command and save the output to a file for inclusion in the
        report.
        R:R�s-skipped cmd output '%s' due to predicate (%s)RqRR;R�R�R�R�R�R�R�R�R�RsR�N(R�RSR�R�R�R�(
RCR:R�R�R�R�R�R�R�R�RsR�R�((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pytcollect_cmd_outputMs	 c
C�s�|jdtd|�s*idd6dd6S|sF|jdjdkrR|j}
nd}
t|d|d	|
d
|d|d|d
|	�S(sExecute a command right now and return the output and status, but
        do not save the output within the archive.

        Use this method in a plugin's setup() if command output is needed to
        build subsequent commands added to a report via add_cmd_output().
        R:R�RqRR;R�R�R�R�R�R�R�R�N(R�RSR�R�R�R�R(RCR:R�R�R�R�R�R�R�R�R�((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pytexec_cmdds	cC�s||jjkS(s?Return whether specified module as module_name is loaded or not(R|tkernel_mods(RCtmodule_name((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyRd|scC�s|jj|�dS(spAdd an alert to the collection of alerts for this plugin. These
        will be displayed in the report
        N(R�R[(RCtalertstring((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt	add_alert�scC�s|j|7_dS(svAppend text to the custom text that is included in the report. This
        is freeform and can include html.
        N(R�(RCttext((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pytadd_custom_text�scK�svt|tj�r|g}n|jjj}|sD|jd�dSx+|D]#}|jdd||f|�qKWdS(sHCollect service status information based on the InitSystem used.

        :param services: A string, or list of strings, specifying the services
                          to collect
        :param kwargs    Optional arguments to pass to _add_cmd_output
                         (timeout, predicate, suggest_filename,..)
        sFCannot add service output, policy does not define an InitSystem to useNR:s%s %s(RR
RR|R�t	query_cmdR�R�(RCR?R�tquerytservice((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pytadd_service_status�s

c

C�s�d}
d}d}d}d}d}d}d}d	}d
}|jd�}|p]|jd�}|sut||�nd
}t|tj�r�|g}n|r�x|D]}|
||7}
q�Wn|	r�|
||	7}
n|
r�|
|7}
n|r�|
d7}
n|r?|dkrd}n|dkr.d}n|
||7}
n|rV|
||7}
n|rm|
||7}
n|r�|
||7}
n|r�|
||7}
n|jd|
�|jd|
d|d|d|�dS(s7Collect journald logs from one of more units.

        :param units: A string, or list of strings specifying the
                       systemd units for which journal entries will be
                       collected.

        :param boot: A string selecting a boot index using the
                      journalctl syntax. The special values 'this' and
                      'last' are also accepted.

        :param since: A string representation of the start time for
                       journal messages.

        :param until: A string representation of the end time for
                       journal messages.

        :param lines: The maximum number of lines to be collected.

        :param allfields: A bool. Include all journal fields
                           regardless of size or non-printable
                           characters.

        :param output: A journalctl output control string, for
                        example "verbose".

        :param timeout: An optional timeout in seconds.
        :param identifier: An optional message identifier.
        :param catalog: Bool. If True, augment lines with descriptions
                        from the system catalog.
        :param sizelimit: Limit to the size of output returned in MB.
                          Defaults to the value of --log-size.
        sjournalctl --no-pager s
 --unit %ss
 --boot %ss
 --since '%s's --until %ss --lines %ss --output %ss --identifier %ss
 --catalogidRVRWis --alltthisRtlasts-1scollecting journal: %sR:R�RsR�N(RctmaxRR
RR�R�(RCtunitstbootRXtuntiltlinest	allfieldsR;R�t
identifiertcatalogRsR�tjournal_cmdtunit_opttboot_optt	since_optt	until_optt	lines_optt
output_opttidentifier_opttcatalog_opttjournal_sizeRVRWtunit((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pytadd_journal�sR$


		cC�swd}|r|d7}nt|tj�r7|g}nx9|D]1}|jd|�|jdd||f�q>WdS(sGCollect udevadm info output for a given device

        :param device: A string or list of strings of device names or sysfs
                       paths. E.G. either '/sys/class/scsi_host/host0' or
                       '/dev/sda' is valid.
        :param attrs: If True, run udevadm with the --attribute-walk option.
        sudevadm infos -ascollecting udev info for: %sR:s%s %sN(RR
RR�R�(RCtdevicetattrstudev_cmdtdev((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt
add_udev_info�s

cC�s
tj|�S(N(RK(RCRu((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyRnscC�s6x/|jD]$}|jd|�|j|�q
WdS(Nscollecting path '%s'(R�R�R*(RCR(((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt_collect_copy_specsscC�sSxL|jD]A}|jd|j��|jd|j�|j|j�q
WdS(Nsunpacked command: scollecting output of '%s'(R�R�RQR�R:R�R�(RCR�((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt
_collect_cmdsscC�s�x�|jD]�\}}|jr#dSd}|ri|j�d}t|tj�si|jdd�}qin|jd||f�y/|jj	|t
jjd|j
�|��Wq
tk
r�}|jd||f�q
Xq
WdS(NRiRRs!collecting string ...'%s' as '%s'Rmscould not add string '%s': %s(R�R�RsRR
RRR�R�RR�R(R>R�RR�(RCtstringR{RR((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt_collect_stringss$				cC�sUt�}|j�|j�|j�|j�t�|f}|jd|�dS(sCollect the data for a plugin.scollected plugin '%s' in %sN(RR�R�R�R�R�(RCRtfields((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pytcollect1s	


cC�s[yBt|d�r(|jr(|jj�St|j|�jj�SWntk
rVdSXdS(s9 This function will return the description for the pluginR�s<no description available>N(R�R�R!tsupert	__class__R(RC((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pytget_description:s

c
C�s[t|j|j|j|j|j|jg�r0t|jtj	�rW|jg|_nt|jtj	�r~|jg|_nt|jtj	�r�|jg|_nt|jtj	�r�|jg|_nt|jtj	�r�|jg|_nt|t
�rgt|�_x�|j
�D]�}g|jD]}|i|d6^q.}g|jD]}|i|d6^qU}g|jD]}|i|d6^q|}g|jD]}|i|d6^q�}	|j||||	�rt|�jj|�qqWtt|�j�dkS|j|j|j|j|j�St|t
�rW|j
�t|�_ntS(s�This method will be used to verify that a plugin should execute
        given the condition of the underlying environment.

        The default implementation will return True if none of class.files,
        class.packages, nor class.commands is specified. If any of these is
        specified the plugin will check for the existence of any of the
        corresponding paths, packages or commands and return True if any
        are present.

        For SCLPlugin subclasses, it will check whether the plugin can be run
        for any of installed SCLs. If so, it will store names of these SCLs
        on the plugin class in addition to returning True.

        For plugins with more complex enablement checks this method may be
        overridden.
        tscl_namei(R)RvR@tcommandsR�R?t
architecturesRR
Rt	SCLPluginRPt
_scls_matchedt	_get_sclst_check_plugin_triggersR[R�RS(
RCtsclRRvR'R@tcR�RR?((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt
check_enabledCs@''''		
c�s�td�|D��s�t�fd�|D��s�td�|D��s�t�fd��jD��s�t�fd�|D��o��j�S(Ncs�s!|]}tjj|�VqdS(N(R�R(R�(R&R((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pys	<genexpr>�sc3�s|]}�j|�VqdS(N(Rm(R&Ro(RC(s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pys	<genexpr>�scs�s|]}t|�VqdS(N(R(R&R:((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pys	<genexpr>�sc3�s|]}�j|�VqdS(N(Rd(R&tmod(RC(s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pys	<genexpr>�sc3�s|]}�j|�VqdS(N(R�(R&Rk(RC(s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pys	<genexpr>�s(R)R�tcheck_is_architecture(RCRvR@R�R?((RCs8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyR��scC�sB|jdkrtSddj|j�}tj||jj��S(s�Checks whether or not the system is running on an architecture that
        the plugin allows. If not architecture is set, assume plugin can run
        on all arches.
        s(?:%s)RzN(R�R�RSR>RR~R|R}(RCR((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyR��scC�stS(swThis decides whether a plugin should be automatically loaded or
        only if manually specified in the command line.(RS(RC((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pytdefault_enabled�scC�s7x0|jD]%}|j|�r
|j|�q
q
WdS(s�Based on the class attrs defined for plugin enablement, add a
        standardized set of collections before we call the plugin's own setup()
        method.
        N(R?R�R�(RCR�((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pytadd_default_collections�scC�s|jt|j��dS(s�Collect the list of files declared by the plugin. This method
        may be overridden to add further copy_specs, forbidden_paths, and
        external programs if required.
        N(RR�Rv(RC((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pytsetup�scC�s�t|d�s|jr_t|d�rX|jrXg|jD]}|d^q<|_q_dSn|jj}|j|j�}|r�|j|�ndS(Ntverify_packagesR@t$(R�R�R@R|tpackage_managertbuild_verify_commandR�(RCR'tpmt
verify_cmd((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pytsetup_verify�s&cC�sdS(sLPerform any postprocessing. To be replaced by a plugin if required.
        N((RC((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyR��sc	C�s�t}d}yZtj|�}xD|D]<}t|d�}|j�j�}||kr%t}q%q%WWntk
r|}tSX|S(saChecks if a named process is found in /proc/[0-9]*/cmdline.
        Returns either True or False.s/proc/[0-9]*/cmdlinetr(RrRKtopenRR!RSR(	RCtprocessRqt
cmd_line_globtcmd_line_pathsR(Rtcmd_lineR((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pytcheck_process_by_name�s
c	C�s�g}d}tj|�}x~|D]v}yWt|d��B}|j�j�}||krx|j|jd�d�nWdQXWq"tk
r�}q"q"Xq"W|S(slReturns PIDs of all processes with process name.
        If the process doesn't exist, returns an empty lists/proc/[0-9]*/cmdlineR�RiN(RKR�RR!R[R\R(	RCR�tpidsR�R�R(RR�R((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pytget_process_pids�s
'N(((((((stimeoutsTimeout in seconds for pluginR�i����(gR�R�R�R�R�RSt
requires_roottversionR@RvR�R�R?R�R�tprofilesR�R�tcmd_timeoutRrR�R�R�R�R�tpropertyR�R�tclassmethodR�R�R�R�R�R�R�R�R�R�RmR�R�R�RiR�R�R�R�R�R�R�R�R�RRRRR0R5RR7R@R*RNRORURcR`RaRR�R�R�R�R%R�R�RqR�R�R�RdR�R�R�R�R�RnR�R�R�R�R�R�R�R�R�R�R�R�R�R�R�(((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyR��s�		"																				
	,	%			;				<				u	
		
				^								W									=		
				
		tRedHatPlugincB�seZdZRS(s/Tagging class for Red Hat's Linux distributions(R�R�R�(((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyR��sR�cB�sSeZdZed��Zd�Zd�Zd�Zd�Zd�Z	d�Z
RS(s�Superclass for plugins operating on Software Collections (SCLs).

    Subclasses of this plugin class can specify class.files and class.packages
    using "%(scl_name)s" interpolation. The plugin invoking mechanism will try
    to match these against all found SCLs on the system. SCLs that do match
    class.files or class.packages are then accessible via self.scls_matched
    when the plugin is invoked.

    Additionally, this plugin class provides "add_cmd_output_scl" (run
    a command in context of given SCL), and "add_copy_spec_scl" and
    "add_copy_spec_limit_scl" (copy package from file system of given SCL).

    For example, you can implement a plugin that will list all global npm
    packages in every SCL that contains "npm" package:

    class SCLNpmPlugin(Plugin, SCLPlugin):
        packages = ("%(scl_name)s-npm",)

        def setup(self):
            for scl in self.scls_matched:
                self.add_cmd_output_scl(scl, "npm ls -g --json")
    cC�s4tt|�d�s'gt|�_nt|�jS(NR�(R�RPR�(RC((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pytscls_matched�scC�s3td�d}g|j�D]}|j�^qS(Nsscl -lR;(RRsR!(RCR;R�((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyR��scC�s�|jj�}y&td|d�j�jd�}Wn*tk
ra}|jd||f�nXtjd}x-|j	d�D]}d||||f}qWd|||f}|S(	sCwrapping command in "scl enable" call and adds proper PATH
        s/etc/scl/prefixes/%sR�s
s*Failed to find prefix for SCL %s, using %stPATHt:s
%s/%s%s:%ssscl enable %s "PATH=%s %s"(
R|tget_default_scl_prefixR�RtrstripRR�R�tenvironR\(RCR�R:RERR(R'tscl_cmd((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pytconvert_cmd_scls
	
cK�sbt|tj�r|g}ng}x'|D]}|j|j||��q+W|j||�dS(spSame as add_cmd_output, except that it wraps command in
        "scl enable" call and sets proper PATH.
        N(RR
RR[RR�(RCR�R�R�tscl_cmdsR:((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pytadd_cmd_output_scls
cC�s\|jj�}xFddgD]8}tjd|�}|jd|||f|�}qW|S(NRbtvars^/%s/s
/%s/%s/%s/(R|RRRR (RCR�Rut
scl_prefixtrootdirR'((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pytconvert_copyspec_scl's
cC�s_t|tj�r|g}ng}x'|D]}|j|j||��q+W|j|�dS(s`Same as add_copy_spec, except that it prepends path to SCL root
        to "copyspecs".
        N(RR
RR[R
R(RCR�Rrt
scl_copyspecsRu((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pytadd_copy_spec_scl/s
cK�s |j|j||�|�dS(seSame as add_copy_spec_limit, except that it prepends path to SCL
        root to "copyspec".
        N(tadd_copy_spec_limitR
(RCR�RuR�((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pytadd_copy_spec_limit_scl:s(R�R�R�R�R�R�RRR
RR(((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyR��s					tPowerKVMPlugincB�seZdZRS(s$Tagging class for IBM PowerKVM Linux(R�R�R�(((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyRDst
ZKVMPlugincB�seZdZRS(s Tagging class for IBM ZKVM Linux(R�R�R�(((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyRIstUbuntuPlugincB�seZdZRS(sTagging class for Ubuntu Linux(R�R�R�(((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyRNstDebianPlugincB�seZdZRS(sTagging class for Debian Linux(R�R�R�(((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyRSst
SuSEPlugincB�seZdZRS(s*Tagging class for SuSE Linux distributions(R�R�R�(((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyRXstIndependentPlugincB�seZdZRS(s6Tagging class for plugins that can run on any platform(R�R�R�(((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyR]stExperimentalPlugincB�seZdZRS(s=Tagging class that indicates that this plugin is experimental(R�R�R�(((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyRbscC�s)d|}|stf}nt||�S(s�Import name as a module and return a list of all classes defined in that
    module. superclasses should be a tuple of valid superclasses to import,
    this defaults to (Plugin,).
    ssos.plugins.%s(R�R(R�tsuperclassest
plugin_fqname((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt
import_plugings
(3R�t
__future__Rt
sos.utilitiesRRRRRRR�RKRR-RR�R�RR
t	six.movesRR	R
tFileNotFoundErrort	NameErrorRRRR%R+R6R7RtDOTALLR�R�tobjectR8R�R�R�R�RRRRRRRR�R(((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt<module>sX.

							
������Wc