• File: btextract.pyc
  • Full Path: /home3/farmfre2/public_html/ALFA_DATA/alfasymlink/root/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/btextract.pyc
  • Date Modified: 03/28/2024 3:28 PM
  • File size: 16.52 KB
  • MIME-type: text/x-bytecode.python
  • Charset: 8 bit

fc@sddlmZddlmZddlmZddlmZddlm	Z	ddl
mZddlm
Z
mZmZddlmZdd	lmZdd
lmZddlmZddlmZdd
lZdd
lZdd
lZdd
ljj Z dd
l!jj"Z"dd
l
jj#Z#dd
ljj$Z$dd
l%Z%dd
l&Z&dd
l'Z'dZ(ej)dZ*de
fdYZ+d
S(i(tdeque(tOption(t_(t	Constants(tLaunchHelper(tVMCore(tInteractivePlugint
DisplayOptiontObjectDisplayOption(t
AddAttachment(t
AddComment(tGetKernelDebugPackages(tDiagnose(tOpenCaseNs%Keith Robertson <kroberts@redhat.com>s%redhat_support_tool.plugins.btextractt	BTExtractcBseZdZdZdZdZdZdZe	Z
edZedZ
edZedZdZdZdZd	Zd
ZdZdZdd
ZdZdZddZddZdZRS(t	btextracttcCs
tdS(s
        The usage statement that will be printed by OptionParser.

        Example:
            - %prog -c CASENUMBER [options] <comment text here>
        Important: %prog is a OptionParser built-in.  Use it!
        s!%prog [options] </path/to/vmcore>(R(tcls((sI/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/btextract.pyt	get_usage9s	cCstd|jS(s
        The description statement that will be printed by OptionParser.

        Example:
            - 'Use the '%s' command to add a comment to a case.'             % cls.plugin_name
        sUse the '%s' command get a kernel stack backtrace and other related information from a kernel core dump file. The default behavior is to issue 'bt -a'; however, there are a variety of other 'crash' commands that can be run.(Rtplugin_name(R((sI/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/btextract.pytget_descDs		cCstd|jS(s
        The epilog string that will be printed by OptionParser.  Usually
        used to print an example of how to use the program.

        Example:
         Examples:
          - %s -c 12345678 Lorem ipsum dolor sit amet, consectetur adipisicing
          - %s -c 12345678
        s"Examples:
  - %s /var/crash/vmcore(RR(R((sI/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/btextract.pyt
get_epilogSscCsrtdddddtddd*tdd	dd
dddtd
dttdddddddtddttdddddddtddttdddddddtddttdddddddtddttdddd dddtd!dttd"d#dd$dddtd%dttd&d'dd(dtd)dd*g	S(+sO
        Subclasses that need command line options should override this method
        and return an array of optparse.Option(s) to be used by the
        OptionParser.

        Example:
         return [Option("-f", "--file", action="store",
                        dest="filename", help='Some file'),
                 Option("-c", "--case",
                        action="store", dest="casenumber",
                        help='A case')]

         Would produce the following:
         Command (? for help): help mycommand

         Usage: mycommand [options]

         Use the 'mycommand' command to find a knowledge base solution by ID
         Options:
           -h, --help  show this help message and exit
           -f, --file  Some file
           -c, --case  A case
         Example:
          - mycommand -c 12345 -f abc.txt

        s-cs--casetdestt
casenumberthelps9Add the collected data as a comment to the provided case.tdefaults-as--alltalltactiont
store_trues Run all options. Equals -aeflpFis-es	--exframetexframesPSearch the stack for possible kernel and user mode exception frames (ie. bt -e).s-fs--foreachbtt	foreachbts8Display the stack traces for all tasks (ie. foreach bt).s-ls--logtlogs9Dumps the kernel log_buf contents in chronological order.s-ps--pstpss=Displays process status for selected processes in the system.s-Fs--filestfiless&Displays information about open files.s-os--obfuscatet	obfuscateswObfuscate the data by running it through soscleaner to clean hostnames and IP addresses (requires root user privileges)s-is	--cmdfiletcmdfiles:Run a sequence of individual 'crash' commands from a file.N(RRtNonetFalse(R((sI/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/btextract.pytget_optionsbsDcCs
tdS(NsO
Select the crash command output to view or 'e' to return to the previous menu.(R(tself((sI/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/btextract.pytget_intro_textscCs|jS(N(t
_submenu_opts(R'((sI/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/btextract.pytget_sub_menu_optionsscCst||_dS(s
        Will create a VMCore object from a given core file
        or throw an exception if crash has a problem inspecting the
        core file for OSRELEASE.
        N(Rtvmcore(R'tfilename((sI/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/btextract.pyt
_check_vmcorescCsEtjjdd}tj||jj}|rL|jj|ntd|j	dGHt
td|jj}t|jj
dkr(td|jjGHtt}|j|jjdttj||jj}|r|jj|qAttd	ntd
|jjdS(sS
        At this point self.vmcore had better be non-null.  This
        method will call vmcorehelper's get_debug_symbols which scans
        the designated debug symbols directory looking for debug symbols
        which match the given core file.  If symbols are found, the
        VMCore object will be passed a VMLinux object.
        toptiontkern_debug_dirs-WARNING: Debug symbols for %s were not found.isWWould you like to install kernel-debuginfo-%s from available debug repositories (y/n)? tysInstalling kernel-debuginfo-%stpt_exceptionsFInstallation of debug images failed, cannot proceed with debug sessionsBUser elected not to install debug packages for kernel-debuginfo-%sN(tconfighelpertget_config_helpertgettvmcorehelpertget_debug_symbolsR+tgetKernelVersiontsetDebugSymbolsRt_argst	raw_inputtstrtstriptlowerRRtruntTruet	Exception(R't
kernelext_dirtvmlinuxtlinetlh((sI/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/btextract.pyt_find_debug_symbolss.		
	cCs|js0td|j}|GHt|n|j|jdy|jWnetk
r}tjtj	|t
jjdrd|_
qt
jjdrd|_
qnXdS(Ns<ERROR: %s requires the full path to a kernel core dump file.is/usr/sbin/makedumpfiles/sbin/makedumpfile(R9RRR@R-REtloggerRtloggingtDEBUGtostpathtexiststmkdumpfilepath(R'tmsgte((sI/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/btextract.pyt
validate_argss		
c	Cst|_i|_|jr+|jnRy|jWnAtk
r|}td|}|GHtj	t
j||nXy|jdrx|jD]}|j
dkrqntd|j|}t|jdd}t|jdd}d}t|d	krytjd
ddd
\}}tj|d}|j||jtt}|jd|jd|jjdd|jdrdnd|ftj|dtjj ||j!j"f}Wq0tdGHq0Xn9dt|j#t$j%t&j't|j#t$j%|f}|rt(j)t*tt+}|jd|jd|jdrudnd|ft*|_,qqWnWnAtk
r}td|}|GHtj	t
j||nXdS(Ns	ERROR: %sRt_send_to_shadowmant	_opencasecSs
|tjkS(N(tstringt	printable(tx((sI/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/btextract.pyt<lambda>st"t t'i Ntprefixsvmcoreinfo-tsuffixs-rhsttws-c %s --description="%s" %s %ssUTF-8treplaceR"s-oRsIThe attachment %s was uploaded by Red Hat Support Tool from the VMCore %ss^Unable to upload output to Red Hat Customer Portal, reverting to displaying output to console.sM%s
The following comment was added by Red Hat Support Tool
Version: %s
%s

%ss
-c %s %s "%s"(s_send_to_shadowmans	_opencase(-RR)t	_sectionsRLt_mkdumpfile_log_fallbackt_execute_bt_commandsR@RRFRRGtERRORt_optionst
function_nametfilterR;R\R$tlenttempfiletmkstempRItfdopentwritetcloseRR	R>tdisplay_texttencodetremoveRJtbasenameR+tcoreFilenametrulerRtMAX_RULEt	apihelpert
USER_AGENTtcommontset_interactiveR?R
t
no_submenu(	R'RNRMtopttfiltered_stringtfdttemppatht
attachmentRD((sI/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/btextract.pytpostinitsv		


		

	



	
cCs|jr
dSd}x"|jD]}||j|7}qWy|jddGHWnItk
r}tjtj|ddl	}|j|j
dGHnXdS(NusUTF-8R\i(RuR)R]RkR@RFRRGtWARNINGtsystgetdefaultencoding(R'tdocRvRNR}((sI/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/btextract.pytnon_interactive_actionBs	cCs0|j|}tj|jdddddS(NsUTF-8R\tcmdsless -R(R]tpydoct	pipepagerRk(R'tdisplay_optionR((sI/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/btextract.pytinteractive_actionXs
cCs"|jdrtj|S|SdS(NR"(RaRstobfuscate_text(R'ttext((sI/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/btextract.pyt
_obfuscate\s

cCs'ytjd}|jd|jjtjj|dg}tj	|dtj
dtj}|dkrtd}t
|n|jttjj|dj}ttdd	}|jj|||j|<ttd
d|}|jj|||j|<Wn
nXdS(Ns-rhsts--dump-dmesgtdmesglogtstderrtstdoutis4Unable to get core dmesg log using alternate method.sKernel log buffer (dmesg) logsRs#Open a support case with dmesg logsRQ(RetmkdtempRLR+RnRIRJtjoint
subprocesstcalltSTDOUTtPIPERR@RtopentreadRR)tappendR]R(R'ttempdirt	mkdumpcmdtretRMtoutputtdisp_opt((sI/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/btextract.pyR^cs0		*	
		cCs tt}|jd|dS(NR(RRR>(R'RRD((sI/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/btextract.pyRPsc	Csztt}y,td|j}t|jdd}t|jdd}d}t|dkryitj	dddd	\}}t
j|d
}|j||j
|jd|t
j|Wq7tdGHq7XnJd
t|jtjtjt|jtj|f}|jd|Wn;tk
ru}td|}|GHtjtj|nXdS(NcSs
|tjkS(N(RRRS(RT((sI/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/btextract.pyRUsRVRWRXi NRYsvmcoreinfo-RZs-rhstR[s--attachment=%ss^Unable to upload output to Red Hat Customer Portal, reverting to displaying output to console.sM%s
The following comment was added by Red Hat Support Tool
Version: %s
%s

%ss-d '%s's	ERROR: %s(RR
Rct
stored_objR;R\R$RdReRfRIRgRhRiR>RlRRoRRpRqRrR@RFRRGR`(	R'RRDRwRMRxRyRzRN((sI/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/btextract.pyRQs:		


cCs|jdrQt|jd<t|jd<t|jd<t|jd<t|jd<ntdGH|j|jjd}ttd	d
}|jj|||j	|<t
jr"ttdd|}|jj|||j	|<ttd
d|}|jj|||j	|<n|jdr|j|jjd}ttdd
}|jj|||j	|<n|jdr|j|jjd}ttdd
}|jj|||j	|<n|jdr9|j|jjd}ttdd
}|jj|||j	|<n|jdr|j|jjd}ttdd
}|jj|||j	|<n|jdr|j|jjd}ttdd
}|jj|||j	|<n|jdryxt
|jddj}|j|jj|}ttd|jdd
}|jj|||j	|<Wqtk
r}td|jd|f}tjtj|t|qXndS(s`
        A utility method which executes the BT commands specified by the
        user.
        RRRRR R!sExecuting crash commands ...sbt -asOutput from crash 'bt -a'RsDiagnose 'bt -a' outputRPs'Open a support case with 'bt -a' outputRQsbt -esOutput from crash 'bt -e's
foreach btsOutput from crash 'foreach bt'sOutput from crash 'log'sOutput from crash 'ps'sOutput from crash 'files'R#trsOutput from crash -i %ss Problem opening %s. Error is: %sN(RaR?RRR+texe_crash_commandsRR)RR]Rstis_interactiveRRRR@RFRRGR`(R'RRt
file_contentsRNRM((sI/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/btextract.pyR_s




	
	
		
	
	
	
	
	
		N(t__name__t
__module__RR$R)R]tend_of_entriesR+RLR%RutclassmethodRRRR&R(R*R-REROR{RRRR^RPRQR_(((sI/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/btextract.pyR/s0G				&		R			-(,tcollectionsRtoptparseRt(redhat_support_tool.helpers.confighelperRt%redhat_support_tool.helpers.constantsRt(redhat_support_tool.helpers.launchhelperRt(redhat_support_tool.helpers.vmcorehelperRtredhat_support_tool.pluginsRRRt*redhat_support_tool.plugins.add_attachmentR	t'redhat_support_tool.plugins.add_commentR
t+redhat_support_tool.plugins.get_kerneldebugRt$redhat_support_tool.plugins.diagnoseRt%redhat_support_tool.plugins.open_caseR
RGtos.pathRIRt"redhat_support_tool.helpers.commonthelpersRst%redhat_support_tool.helpers.apihelperRqR5R2RRRRet
__author__t	getLoggerRFR(((sI/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/btextract.pyt<module>s0