Viewing File: /usr/lib/python2.7/site-packages/sos/policies/redhat.pyc


Kjc
@sddlmZddlZddlZddlZddlZddlZddlmZddl	m
Z
mZddlm
Z
mZmZddlmZddlmZejdZyddlZeZWnek
reZnXd	Zy
eZWnek
rnXd
e
fdYZdZ d
Z!edeZ"edeZ#ededeZ$dddgZ%dddgZ&dZ'dZ(dZ)dZ*e'Z+dZ,dZ-dZ.dZ/eddd d!gZ0d"Z1d#Z2d$Z3d%Z4ededd&gZ5d'Z6d(Z7ededed)e%de&Z8d*Z9d+Z:d,Z;d-Z<ied.e(d/e)d0e;d1e"e(6ed.e*d/e+e*6ed.e,d/e-d1e0e,6ed.e.d/e/d0e<d1e$e.6ed.e1d/e2d0e;d1e"e16ed.e3d/e4d0e;d1e5e36ed.e6d/e7d0e9d1e8e66Z=d2Z>d3Z?d4Z@d5efd6YZAd7eAfd8YZBd9ZCd:ZDd;ZEied.eCd/eEd0e;d1e"eC6ZFd<eAfd=YZGd>eAfd?YZHd@eGfdAYZIdBefdCYZJdS(Di(tprint_functionN(tDeviceAuthorizationClass(tPlugintRedHatPlugin(tLinuxPolicytPackageManagertPresetDefaults(t_sos(t
SoSOptionstsoss/etc/os-releasetRedHatPolicycBseZdZdZdZdZdZdZdZdZ	ddgZ
eZd	Z
d
ZdZdZdZdZd
ZddZedZdZdZdZdZdZRS(tCentOSshttps://www.centos.org/s/etc/redhat-releases/var/tmps7rpm -qa --queryformat "%{NAME}|%{VERSION}|%{RELEASE}\n"srpm -qalsrpm -Vt	debuginfos-develt/s/opt/rhtfriendlysVhttps://sso.redhat.com/auth/realms/redhat-external/protocol/openid-connect/auth/devicesPhttps://sso.redhat.com/auth/realms/redhat-external/protocol/openid-connect/tokencCsJtt|jd|d|_t|_|rG|j||_n|j}td|j	d|j
d|jd|jd||_
tg|_|j
j|_|jstdd	tjtjd
n|j|j|_|jrd|_n	d|_|jtjd
7_|jtjd7_|j|jdS(Ntsysroottt
query_commandtverify_commandt
verify_filtert
files_commandtchroots'Could not obtain installed package listtfileis/usr/sbin:/usr/bin:/root/bins'/sbin:/bin:/usr/sbin:/usr/bin:/root/bins/usr/local/bins/usr/local/sbin(tsuperR
t__init__t
ticket_numbertFalsetusrmovet_container_initt
_host_sysrootRt	_rpmq_cmdt	_rpmv_cmdt_rpmv_filtert
_rpmql_cmdtpackage_managerRtvalid_subclassestall_pkgstpkgstprinttsyststderrtexitt
check_usrmovetPATHtostpathsept
set_exec_pathtload_presets(tselfR((s7/usr/lib/python2.7/site-packages/sos/policies/redhat.pyRAs2		
						
cCstS(sThis method checks to see if we are running on CentOS Linux. It must be
        overriden by concrete subclasses to return True when running on a
        Fedora, CentOS, RHEL or other CentOS distribution or False otherwise.(R(tcls((s7/usr/lib/python2.7/site-packages/sos/policies/redhat.pytcheckfscCsXd|kr.tjjdo-tjjdS|dd}|ddkrPtStSdS(sqTest whether the running system implements UsrMove.

            If the 'filesystem' package is present, it will check that the
            version is greater than 3. If the package is not present the
            '/bin' and '/sbin' paths are checked and UsrMove is assumed
            if both are symbolic links.

            :param pkgs: a packages dictionary
        t
filesystems/bins/sbintversionit3N(R,tpathtislinktTrueR(R0R%tfilesys_version((s7/usr/lib/python2.7/site-packages/sos/policies/redhat.pyR*ms
"cCsHg}d}|jr@x!|D]}|j||qW|S|SdS(s2Mangle paths for post-UsrMove systems.

            If the system implements UsrMove, all files will be in
            '/usr/[s]bin'. This method substitutes all the /[s]bin
            references in the 'files' list with '/usr/[s]bin'.

            :param files: the list of package managed files
        cSsKddg}||kr5|tjjd|dfStjdd|fS(Ns/bin/rpms
/bin/mailxs/usris(^)(/s?bin)s\1/usr\2(R,R6tjointretsub(R6t
skip_paths((s7/usr/lib/python2.7/site-packages/sos/policies/redhat.pyttransform_pathsN(Rtextend(R0tfilestpathsR>tf((s7/usr/lib/python2.7/site-packages/sos/policies/redhat.pytmangle_package_path}s			
cCsttjkr1tjtdkr1t|_q1nttjkrStjt|_n|joh|jdk}|rtjj|j|j	}||_	n|r|jSdS(sCheck if sos is running in a container and perform container
        specific initialisation based on ENV_HOST_SYSROOT.
        tdockertociR
(RDREN(t
ENV_CONTAINERR,tenvironR8t
_in_containertENV_HOST_SYSROOTRR6tabspatht_tmp_dirtNone(R0tuse_sysrootthost_tmp_dir((s7/usr/lib/python2.7/site-packages/sos/policies/redhat.pyRscCsddlm}m}g}|d|dtd|d|dddt}|j\}}|rf|Sxj|jd	D]X}y|jd
d	\}	}
Wntk
rqwX|
dkrw|jt|	qwqwW|S(Ni(tPopentPIPEs"LC_ALL=C /sbin/chkconfig --list %stshelltstdoutR(tbufsizet	close_fdsit:ton(	t
subprocessRORPR8tcommunicatetsplitt
IndexErrortappendtint(R0tnameRORPtrettptoutterrttabstrunleveltonoff((s7/usr/lib/python2.7/site-packages/sos/policies/redhat.pytrunlevel_by_services&
	
cCs|s
|jS|S(N(RK(R0topt_tmp_dir((s7/usr/lib/python2.7/site-packages/sos/policies/redhat.pytget_tmp_dirsN(t__name__t
__module__tdistrotvendort
vendor_urlt_redhat_releaseRKRR!RR RRHRtdefault_scl_prefixtname_patternRLt
upload_urltupload_usertclient_identifier_urlttoken_endpointRtclassmethodR2R*RCRReRg(((s7/usr/lib/python2.7/site-packages/sos/policies/redhat.pyR
,s0%				t	containertHOSTtverifytall_logstboottstoragetsystemsboot.all-images=onsrpm.rpmva=onsrpm.rpmdb=onsCentOS LinuxtrhvtVirtualizationtrheltrhospsOpenStack PlatformtocpsOpenShift Container Platformtplugoptssprocess.lsof=offs#networking.ethtool_namespaces=Falsesnetworking.namespaces=200tcfmet
CloudFormst	satellitet	Satellites
apache.log=ontcantboots(For use when normal system startup failstprofiless9Data collection will be limited to a boot-affecting scopes$This preset may increase report sizes(This preset may increase report run times1This preset may increase report size and run timeR]tdesctnotetoptssZ
Any information provided to %(vendor)s will be treated in accordance with the published support policies at:

  %(vendor_url)s

The generated archive may contain data considered sensitive and its content should be reviewed by the originating organization before being passed to any third party.

No changes will be made to system configuration.
shttps://api.access.redhat.comssftp://sftp.access.redhat.comt
RHELPolicycBseZeZdZdZededZe	Z
dZdZ
ddZedZdZdZd	Zd
ZedZdZd
ZdZdZdZdZdZRS(Rshttps://wiki.centos.org/supportsThis command will collect diagnostic and configuration information from this %(distro)s system and installed applications.

An archive containing the collected information will be generated in %(tmpdir)s and may be provided to a %(vendor)s support representative.
s%(vendor_text)s
tpostcCs*tt|jd||jtdS(NR(RRRtregister_presetstrhel_presets(R0R((s7/usr/lib/python2.7/site-packages/sos/policies/redhat.pyR!scCstjjtstSttdd}xZ|D]R}|jdr/|jd\}}|jd}|j|j	rt
Sq/q/WWdQXtS(sTest to see if the running host is a RHEL installation.

            Checks for the presence of the "CentOS Linux"
            release string at the beginning of the NAME field in the
            `/etc/os-release` file and returns ``True`` if it is
            found, and ``False`` otherwise.

            :returns: ``True`` if the host is running RHEL or ``False``
                      otherwise.
        trtNAMEt=s"'N(R,R6texistst
OS_RELEASERtopent
startswithRYtstripRjR8(R1RBtlineR]tvalue((s7/usr/lib/python2.7/site-packages/sos/policies/redhat.pyR2%s
cCsL|jdjr&tjtdn|jsHt|_tjdndS(NtcmdlineoptssVThe option --upload-user has been deprecated in favour of device authorization in RHELs&No case id provided, uploading to SFTP(tcommonsRqtloggertinfot_tcase_idtRH_SFTP_HOSTRp(R0((s7/usr/lib/python2.7/site-packages/sos/policies/redhat.pytprompt_for_upload_user=s		cCs*|jdjr&tjtdndS(NRsVThe option --upload-pass has been deprecated in favour of device authorization in RHEL(Rtupload_passRRR(R0((s7/usr/lib/python2.7/site-packages/sos/policies/redhat.pytprompt_for_upload_passwordHscCs|jr|jS|jdjr.|jdjS|jdjdkrHtS|jdjsitjdtSd}t||jSdS(NRtsftps&No case id provided, uploading to SFTPs /support/v1/cases/%s/attachments(RpRtupload_protocolRRRRtRH_API_HOST(R0trh_case_api((s7/usr/lib/python2.7/site-packages/sos/policies/redhat.pytget_upload_urlQs	
cCsdj|j}i|d6S(Ns	Bearer {}t
Authorization(tformatt
_device_token(R0tstr_auth((s7/usr/lib/python2.7/site-packages/sos/policies/redhat.pyt_get_upload_https_auth_scCsi|jjdd||jfd6}t|j|j}|j|_tj	dj
|jtj
|jd|d|jd|S(sIf upload_https() needs to use requests.post(), use this method.
        Policies should override this method instead of the base upload_https()
        :param archive:     The open archive file object
        R
iRs1Device authorized correctly. Uploading file to {}R@theadersRw(R]RYt_get_upload_headersRRrRstget_access_tokenRRRRtget_upload_url_stringtrequestsRRR(R0tarchiveRwR@tRHELAuth((s7/usr/lib/python2.7/site-packages/sos/policies/redhat.pyt_upload_https_postcscCs+|jjtr'idd6dd6SiS(Ntfalset	isPrivatesno-caches
cache-control(RRR(R0((s7/usr/lib/python2.7/site-packages/sos/policies/redhat.pyRzscCs9|jjtrdS|jjtr2dS|jS(NsCustomer PortalsRed Hat Secure FTP(RRRRRp(R0((s7/usr/lib/python2.7/site-packages/sos/policies/redhat.pyRs
cCs4|jjdd}|jr0d|j|fS|S(sThe RH SFTP server will only automatically connect file uploads to
        cases if the filename _starts_ with the case number
        R
is%s_%s(tupload_archive_nameRYR(R0tfname((s7/usr/lib/python2.7/site-packages/sos/policies/redhat.pyt_get_sftp_upload_names	cCs$tjdd|jkr2tt|jStsGtdnd}d}|j	syt
|j|j}Wn5tk
r}dt
|krtjdqqX|j|_	n|j	rtjdj|jntd}d}|j	rr|j}tj|d|d	d
}|jdkretj|jd}tj|jd
}qtdnwitd6}tj|dtj|d	d
}	|	jdkrtj|	j}
|
d}|
d
}td|n|r|rtt|jd|d|StddS(sOverride the base upload_sftp to allow for setting an on-demand
        generated anonymous login for the RH SFTP server if a username and
        password are not given
        s//isOpython-requests is not installed and is required for obtaining SFTP auth token.send user denieds:Device token authorization has been cancelled by the user.s1Device authorized correctly. Uploading file to {}s/support/v2/sftp/tokenRttimeouti
itusernamettokensUUnable to retrieve Red Hat auth token using provided credentials. Will try anonymous.tisAnonymoustdatasHUsing anonymous user %s for upload. Please inform your support engineer.tusertpasswords1Could not retrieve valid or anonymous credentialsN(RRYRRRtupload_sftptREQUESTS_LOADEDt	ExceptionRLRRRrRststrRRRRRRRRRtstatus_codetjsontloadsttextR&R8tdumps(R0t_tokent_userRteturlR^Rtadatatanontresp((s7/usr/lib/python2.7/site-packages/sos/policies/redhat.pyRsP		
	

$

cCsy]|jrD|jjtrD|js8|jrDt|_ntt|j|}Wnft	k
r}t
}|jjtsqtd|tft|_tt|j|}nX|S(sOverride the base upload_archive to provide for automatic failover
        from RHCP failures to the public RH dropbox
        s5Upload to Customer Portal failed due to %s. Trying %s(RpRRtget_upload_usertget_upload_passwordRRRtupload_archiveRRR&(R0RtuploadedR((s7/usr/lib/python2.7/site-packages/sos/policies/redhat.pyRs	cCsy|jjd}|j|dd}|ddkr>dS|ddkrRdS|dd	krfd
S|ddkrzdS|dd
krdSWntk
rnXtS(Nsredhat-release*iR4t4it5Servert5Clientit6it7it8i(RR(R"tall_pkgs_by_name_regexR%RR(R0trrtpkgname((s7/usr/lib/python2.7/site-packages/sos/policies/redhat.pytdist_versions 
cCsx7ddgD])}|jjd|r
|jtSq
W|jddk	r\|jtS|jddk	r~|jtS|jddk	r|jtS|jddk	s|jddk	r|jt	S|jt
S(	Ntrescuet	emergencys	%s.targetssatellite-commons
rhosp-releaseRsovirt-enginetvdsm(tinit_systemt
is_runningtfind_presettCBtpkg_by_nameRLtRH_SATELLITEtRHOSPtRH_CFMEtRHVtRHEL(R0ttarget((s7/usr/lib/python2.7/site-packages/sos/policies/redhat.pytprobe_presets



N(RhRitRHEL_RELEASE_STRRjRkRlRtdisclaimer_texttmsgRt_upload_urlRLRt_upload_methodRRtR2RRRRR8RRRRRRRR(((s7/usr/lib/python2.7/site-packages/sos/policies/redhat.pyRs,										?		tCentOsPolicycBseZdZdZdZRS(Rshttps://www.centos.org/(RhRiRjRkRl(((s7/usr/lib/python2.7/site-packages/sos/policies/redhat.pyRstatomictAtomicsAtomic HosttRedHatAtomicPolicycBsFeZdZededZddZedZ	dZ
RS(sAtomic HostsThis command will collect diagnostic and configuration information from this %(distro)s system.

An archive containing the collected information will be generated in %(tmpdir)s and may be provided to a %(vendor)s support representative.
s%(vendor_text)s
cCs*tt|jd||jtdS(NR(RRRRtatomic_presets(R0R((s7/usr/lib/python2.7/site-packages/sos/policies/redhat.pyR#scCst}ttjkr|Stjt|j}tjj|sCtSy:x3t|djj	D]}|t
|kO}qbWWntk
rnX|S(NR(RRIR,RGRmR6RRtreadt
splitlinestATOMIC_RELEASE_STRtIOError(R1Rthost_releaseR((s7/usr/lib/python2.7/site-packages/sos/policies/redhat.pyR2's"
cCs)|jdr|jtS|jtS(Nsatomic-openshift(RRtRHOCPtATOMIC(R0((s7/usr/lib/python2.7/site-packages/sos/policies/redhat.pyR6s
N(RhRiRjRRRRLRRtR2R(((s7/usr/lib/python2.7/site-packages/sos/policies/redhat.pyRstRedHatCoreOSPolicycBsFeZdZededZddZedZ	dZ
RS(tCoreOSsThis command will collect diagnostic and configuration information from this %(distro)s system.

An archive containing the collected information will be generated in %(tmpdir)s and may be provided to a %(vendor)s support representative.
s%(vendor_text)s
cCstt|jd|dS(NR(RRR(R0R((s7/usr/lib/python2.7/site-packages/sos/policies/redhat.pyRHscCst}ttjkr|Stjt|j}y:x3t|djjD]}|d|kO}qLWWntk
rznX|S(NRR(	RRIR,RGRmRRRR(R1tcoreosRR((s7/usr/lib/python2.7/site-packages/sos/policies/redhat.pyR2Ks"
cCs
|jtS(N(RR(R0((s7/usr/lib/python2.7/site-packages/sos/policies/redhat.pyRXsN(RhRiRjRRRRLRRtR2R(((s7/usr/lib/python2.7/site-packages/sos/policies/redhat.pyR=s
tCentOsAtomicPolicycBseZdZdZdZRS(sCentOS Atomic HostRshttps://www.centos.org/(RhRiRjRkRl(((s7/usr/lib/python2.7/site-packages/sos/policies/redhat.pyR^stFedoraPolicycBs>eZdZdZdZddZedZdZ	RS(tFedorasthe Fedora Projectshttps://fedoraproject.org/cCstt|jd|dS(NR(RRR(R0R((s7/usr/lib/python2.7/site-packages/sos/policies/redhat.pyRjscCstjjdS(sXThis method checks to see if we are running on Fedora. It returns
        True or False.s/etc/fedora-release(R,R6tisfile(R1((s7/usr/lib/python2.7/site-packages/sos/policies/redhat.pyR2mscCs0|jdp|jdd}t|dS(Nsfedora-releasesfedora-release-.*iR4(RRR\(R0tpkg((s7/usr/lib/python2.7/site-packages/sos/policies/redhat.pytfedora_versionssN(
RhRiRjRkRlRLRRtR2R(((s7/usr/lib/python2.7/site-packages/sos/policies/redhat.pyRds(Kt
__future__RRR,R'R;tloggingtsos.policies.authRtsos.pluginsRRtsos.policiesRRRR	RRRt	getLoggerRRR8RtImportErrorRRt	raw_inputtinputt	NameErrorR
RFRIt_opts_verifyt_opts_all_logst_opts_all_logs_verifyt_cb_profilest_cb_plugoptsRRtRHV_DESCRt	RHEL_DESCRt
RHOSP_DESCRt
RHOCP_DESCt
RHOSP_OPTSRtRH_CFME_DESCRtRH_SATELLITE_DESCtSAT_OPTSRtCB_DESCtCB_OPTStCB_NOTEt	NOTE_SIZEt	NOTE_TIMEtNOTE_SIZE_TIMERRRRRRRRtATOMIC_DESCRRRRR(((s7/usr/lib/python2.7/site-packages/sos/policies/redhat.pyt<module>s




	


%
%!
Back to Directory File Manager