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

fc@s3ddlmZddlmZmZddlmZmZddlm	Z	ddl
mZddlm
Z
ddlmZddlmZdd	lZdd	ljjZdd	ljjZdd	ljjZdd	ljjZdd	lZdd	lZdd	lZd
Zej dZ!defd
YZ"d	S(i(tOption(tRequestErrortConnectionError(tEmptyValueErrort_(tLaunchHelper(t	Constants(t
GenericPrompt(tPlugin(t
AddAttachmentNs&Spenser Shumaker <sshumake@redhat.com>s$redhat_support_tool.plugins.add_casetOpenCasecBseZdZdZdZdZdZdZe	dZ
e	dZe	dZe	dZ
dZdZdZd	Zd
ZdZdZd
ZdZdZdZdZRS(topencasesRed Hat Enterprise LinuxcCs
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 -s SUMMARY -p PRODUCT -v VERSION -d DESCRIPTION [options](R(tcls((sI/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/open_case.pyt	get_usage2s	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
        s0Use the '%s' command to open a new support case.(Rtplugin_name(R((sI/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/open_case.pytget_desc>s		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 -s "Case Summary" -p "Red Hat Virtualization" -v 3.0 -d "Case description"
(RR(R((sI/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/open_case.pyt
get_epilogJscCs*tdddddtddd&tdd	dd
dtddd&tdd
dddtddd&tdddddtddd&tdddddtddd&tdddddtddd&tdddddd dtd!dttd"d#dd$dtd%dd&gS('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-ps	--producttdesttproductthelps7The product the case will be opened against. (required)tdefaults-vs	--versiontversionsFThe version of the product the case will be opened against. (required)s-ss	--summarytsummarys!A summary for the case (required)s-ds
--descriptiontdescriptions&A description for the case. (required)s-Ss
--severitytseveritys$The severity of the case. (optional)s-as--attachmentt
attachments6Add an attachment to the newly opened case. (optional)s-os--obfuscatet	obfuscatetactiont
store_trues}Obfuscate the attachment by running it through soscleaner to clean hostnames and IP addresses (requires root user privileges)s-gs--casegroupt	casegroups6Add this case to the designated case group. (optional)N(RRtNonetFalse(R((sI/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/open_case.pytget_optionsYs0cCstd|j}d|_t}|jdsatjsO|GHt|n|j	|}ntj
|_|st}xS|jD]H}|jj|jdjkrt
}|j|jd<PqqW|std}|GHt|qndS(NsERROR: %s requires a product.Rs ERROR: Invalid product provided.(RRRt_productsAryRt_optionstcommontis_interactivet	Exceptiont_interactive_product_selectiontget_productstget_nametlowertTrue(tselftmsgt
been_verifiedtinArrayR((sI/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/open_case.pyt_check_products*	
	
%cstj|_tj}|jddt}dksKdkrW|jnt	fd|jDd}|dk	r|dkrt
td}t|j
jdkr|j|jd<t}t}n|r|j|||}qn|S(Ntoptiontdefault_producttc3s'|]}|jkr|VqdS(N(R((t.0tval(R1(sI/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/open_case.pys	<genexpr>ss5Do you want to use the default product - "%s" (y/N)?:tyR(R#R'R!tconfighelpertget_config_helpertgetR*Rtdefault_product_nametnextt	raw_inputRtstrtstripR)R(R"Rt_prompt_for_product(R+R-tcfgtneeds_user_inputt
searched_itemtline((R1sI/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/open_case.pyR&s""
	cCstj|jxtrttd}t|jdkrOtnyt	|}WntdGHqnX|t
dt|jdkr|dkr|j|dj|j
d<t}PqtdGHqW|j
d|jkr|j|j
dn|S(Ns*Please select a product (or 'q' to exit): tqs!ERROR: Invalid product selection.iR2R(R#tprint_productsR!R*R;RR<R=R%tinttrangetlenR(R"t_prompt_for_default_product(R+R-R?RARB((sI/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/open_case.pyR>s$	.cCstd|j}t}d}x:|jD]/}|jd|jkr)|j}Pq)q)W|jdsYtj	rEtj
|xtrAttd}t
|jdkrtnyt|}WntdGHqnX|tdt|dkr3|dkr3||d|jd<t}PqtdGHqWqY|GHt|n|st}xD|D]<}|j|jdjkrlt}||jd<PqlqlW|std	}|GHt|qndS(
NsERROR: %s requires a version.RRs*Please select a version (or 'q' to exit): RCs!ERROR: Invalid version selection.iR2s ERROR: Invalid version provided.(RRRRR!R"R(tget_versionsR#R$tprint_versionsR*R;R<R=R%RERFRGR)(R+R,tbeenVerifiedtversionsRRBR.R((sI/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/open_case.pyt_check_versionsL	


	+

cCstd|j}|jdstjrxtrttd}yt|j}WntdGHnXt|jdkrt	n|dkrtdGHq/||jd<Pq/Wq|GHt	|ndS(NsERROR: %s requires a summary.Rs)Please enter a summary (or 'q' to exit): s!ERROR: Invalid summary selection.RCR2(
RRR"R#R$R*R;R<R=R%(R+R,RB((sI/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/open_case.pyt_check_summary
s$	

	
cCstd|j}|jdstjrxtrg}y,tdGHxtre|jtqLWWq/tk
rt	dj
|j}|dkrtdGHq|jd|jd<Pq/Xq/Wq|GHt
|ndS(Ns!ERROR: %s requires a description.RsCPlease enter a description (Ctrl-D on an empty line when complete):s
R2sERROR: Invalid description.tutf_8(RRR"R#R$R*tappendR;tEOFErrorR<tjoinR=tdecodeR%(R+R,t	userinputR((sI/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/open_case.pyt_check_description#s&	

		
cCsctd}|jdstjr_tj}tj|xtrttd}t|j	dkr}t
nyt|}Wn|GHqAnX|tdt
|dkr|dkr||d|jd<PqA|GHqAWq_nmt}xJtjD]<}|jdj|jkrt}||jd<PqqW|s_td}|GHndS(Ns!ERROR: Invalid severity selectionRs+Please select a severity (or 'q' to exit): RCiR2s"ERROR: Invalid severity specified.(RR"R#R$tget_severitiestprint_severitiesR*R;R<R=R%RERFRGRR)(R+R,t
severitiesAryRBtmatchR((sI/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/open_case.pyt_check_severity=s6

	+
cCs|jds)tjr|jqnt}xtjD]}|jdj|jjkr<t}|j|jd<|j	|jd<t
jtj
d|jd|jdfPq<q<W|std}|GHndS(NRtcasegroupnumbers!Casegroup(%s) casegroupnumber(%s)s$ERROR: Invalid case group specified.(R"R#R$t_interactive_case_group_actionRt
get_groupsR)R(R*tget_groupNumtloggertlogtloggingtINFOR(R+RYtgroupR,((sI/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/open_case.pyt_check_case_group_s$

cCstj}td|Dd}|dks=|dkrYtd|Dd}n|dk	sq|dkrttd|j}t|jj	dkr|j
|q|j|jd<|j|jd<n
|j
|dS(Ncss!|]}|jr|VqdS(N(t
get_isDefault(R3R4((sI/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/open_case.pys	<genexpr>wsR2css'|]}|jdkr|VqdS(s-1N(R^(R3R4((sI/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/open_case.pys	<genexpr>zss:Would you like to use the default (%s) Case Group (y/N)? :tnRR[(
R#R]R:RR;RR(R<R=R)t_prompt_for_case_groupR"R^(R+t	groupsArytdefault_case_groupRB((sI/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/open_case.pyR\tscCstd}tj|xtrttd}t|jdkrXtnyt|}Wn|GHqnX|t	dt
|dkr
|dkr
||dj|jd<||dj
|jd<tjtjd|jd|jdfPq|GHqWdS(	Ns#ERROR: Invalid case group selections-Please select a case group (or 'q' to exit): RCiR2RR[s!Casegroup(%s) casegroupnumber(%s)(RR#tprint_groupsR*R;R<R=R%RERFRGR(R"R^R_R`RaRb(R+RhR,RB((sI/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/open_case.pyRgs(
	+
cCs@|j|j|j|j|j|jdS(N(R/RMRNRURZRd(R+((sI/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/open_case.pyt
validate_argss




cCsd}|jdrPtj|jd|jd<tj|jd|jd<ny5tj}|jj}|jd|_|jd|_	|jd|_
|jd|_|jd|_|jdr|jd|_
ntjrttd	}t|jj}|d
kr|jj|}tj|\}}tt}|jd|dtd
ttd}|jdkrtdGHdSqn|jj|}|jdkrtd}	|	GHt|	n|j|_dt j!tdt j"t j#fGHtd|j}	|	GHt$j%t&j'|	|jdrtj(t)tt*}|jd|jt+j,j-|jd|jdrdnd|jdfn3t+j.dkrt/j0j1td|jt}t|j}|d
krt2j3ddgdt2j4dt2j5}
|
j6dj7d}x||D]q}d|kr^t|j}
tj(t)tt*}|jd |j|jdrdnd|
fPq^q^Wqntd!|j|jfGH|jdsttd"|j}t|j}|d
krtj(t)tt*}|jd#|j|jdrsdndfqnWn.t8k
r}td$t|}	|	GHt$j%t&j9|	nt:k
r'}td%|j;}	|	GHt$j%t&j9|	|j;d&kr!tj<nnt=k
r~}td'}	|	GHt|j7d(}|d)GHt$j%t&j9|	n8tk
rtd*}	|	GHt$j%t&j9|	nXdS(+NRRRRRRRR[saWould you like to see if there's a solution to this problem before opening a support case? (y/N) R5R2tprompts-Selection (q returns to case creation menu): s5Would you still like to open the support case? (Y/n) RfsSupport case not created.s.ERROR: There was a problem creating your case.s%s%s%st-s.Support case %s has successfully been opened.
Rs -c %s -d '[RHST] File %s ' %s %ss-oisgWould you like Red Hat Support Tool to automatically generate and
attach a SoS report to %s now? (y/N) t	sosreports--batchtstdouttstderrs
s.tar.s-c %s %s %ssPlease attach a SoS report to support case %s. Create a SoS report as
the root user and execute the following command to attach the SoS report
directly to the case:
 redhat-support-tool addattachment -c %s <path to sosreport>
s:Would you like to attach a file to %s at this time? (y/N) s-c %s %s -rs	ERROR: %ss?Unable to fulfill request with support services API. Reason: %stUnauthorizedsZProblem connecting to the support services API.  Is the service accessible from this host?s, isUnable to create case.(>RR"R#tobfuscate_textt	apihelpertget_apitimtmakeCaseRRRRRtgroupNumberR$R;RR<R=R)tproblemstdiagnoseCasetrecommendationpromptertgenerate_metadataRRtruntcasestaddtget_caseNumberR%t_caseNumberRtBOLDtMAX_RULEtENDR_R`RaRbtset_interactiveR*R	tostpathtbasenametgeteuidtsysRotwritetsubtPopentPIPEtSTDOUTtcommunicatetsplitRtWARNINGRtreasontremove_userR(R+tapitcaseRBtrecommendationst	recprompttrecdoctlhtcsR,tptoutputtoutRtevetreterrmsgtemg((sI/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/open_case.pytnon_interactive_actions
 


		


	




(	

	
N(t__name__t
__module__RRtcommentRR!RR9tclassmethodR
RRR R/R&R>RMRNRURZRdR\RgRkR(((sI/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/open_case.pyR
*s,:				0			"				(#toptparseRt(redhat_support_lib.infrastructure.errorsRRt(redhat_support_tool.helpers.confighelperRRt(redhat_support_tool.helpers.launchhelperRt%redhat_support_tool.helpers.constantsRt4redhat_support_tool.helpers.genericinteractivepromptRtredhat_support_tool.pluginsRt*redhat_support_tool.plugins.add_attachmentR	Rt%redhat_support_tool.helpers.apihelperthelpersRst"redhat_support_tool.helpers.commonR#t2redhat_support_tool.helpers.recommendationprompterRzR6t
subprocessRRaRt
__author__t	getLoggerR_R
(((sI/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/open_case.pyt<module>s$