a >h?@szddlZddlmZmZddlmZmZmZmZmZddl m Z GdddeZ Gddde eeZ Gd d d e eZ dS) N)datetime timedelta)Plugin RedHatPlugin DebianPlugin UbuntuPlugin PluginOpt)sos_parse_versionc@sneZdZdZdZdZdZeddedded d d d gZ dZ d dZ ddZ ddZ ddZddZddZdS) Pacemakerz4Pacemaker high-availability cluster resource manager pacemaker)Zcluster)r zpacemaker-remotecrm-fromz%specfiy the start time for crm_report)defaultZval_typedesc crm-scrubTz$enable crm_report password scrubbing)rrcCs|ddS)z Get cluster summary zcrm_mon -1 -A -n -r -tNadd_cmd_outputselfr@/usr/lib/python3.9/site-packages/sos/report/plugins/pacemaker.py setup_crm_mon$szPacemaker.setup_crm_moncCs|ddgdS)z& Get cluster status and configuration z crm statuscrm configure showNrrrrrsetup_crm_shell(szPacemaker.setup_crm_shellcCs|jjd}|durdS|d|gdd|d}t|tdkr\|dn |d |jd d d |jd dd |jddd dS)z& Get pacemaker/corosync configuration ZpcsNz/var/log/pcsd/pcsd.log)zpcs stonith sbd status --fullzpcs stonith sbd watchdog listzpcs stonith history show.versionz0.10.8zpcs property config --allzpcs property list --all pcs configZ pcs_config)tagszpcs quorum statusZpcs_quorum_statuszpcs status --fullZ pcs_status)ZpolicyZpackage_managerZ pkg_by_name add_copy_specrjoinr )rZpcs_pkgZ pcs_versionrrr setup_pcs/s   zPacemaker.setup_pcscCs|ddddS) Clear password rpassw([^\s=]*)=\S+passw\1=********NZdo_cmd_output_subrrrrpostproc_crm_shellFs zPacemaker.postproc_crm_shellcCs|ddddS)r!rr"r#Nr$rrrr postproc_pcsNs zPacemaker.postproc_pcsc Csr|gd|ttddd}|drrtdt |drZ|d}n| d|dd|j d d d }|d rd }nd}| d| d|j d|d|d|d|dd}||jrn||jt|jddd`}|D]J}t||rt||d}dD]}t|d|}q*||qWdn1sd0YdS)N)z!/var/log/pacemaker/pacemaker.log*/var/log/pacemaker/bundles/*/z/var/log/pacemaker/pengine*z/var/log/pacemaker.logr'z/var/log/cluster/pacemaker.log*z/var/log/cluster/bundles/*/H)Zhoursz%Y-%m-%d %H:%m:%Sr z#\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}zcrm_from parameter 'z$' is not a valid date: using defaultZ crm_reportF)nameZmakerz -p "passw.*"r z-scrubbing of crm passwords has been disabled:z:data collected by crm_report may contain sensitive values.zcrm_report --sos-mode z -S -d --dest z --from "")chrootz0^\s*PCMK_logfile=[\'\"]?(\S+)[\'\"]?\s*(\s#.*)?$rzUTF-8)encoding)z^"z"$z^\'z\'$)rrrZtodayrstrftimeZ get_optionrematchstrZ _log_errorZget_cmd_output_pathZ _log_warnrZtmp_in_sysrootZ path_isfileenvfileopensearchgroupsub) rZcrm_fromZcrm_destZ crm_scrubpatternfilelineZlogfileZregexprrrsetupVsL        zPacemaker.setupN)__name__ __module__ __qualname__Z short_descZ plugin_nameZprofilesZpackagesrr2Z option_listr3rrr r%r&r;rrrrr s$r cs$eZdZfddZddZZS)DebianPacemakercs*|d|_||tdS)Nz/etc/default/pacemaker) path_joinr3rr superr;r __class__rrr;s zDebianPacemaker.setupcCs||dSN)r%r&rrrrpostprocszDebianPacemaker.postprocr<r=r>r;rE __classcell__rrrBrr?s r?cs$eZdZfddZddZZS)RedHatPacemakercs,|d|_||dtdS)Nz/etc/sysconfig/pacemakerz/etc/sysconfig/sbd)r@r3r rrAr;rrBrrr;s  zRedHatPacemaker.setupcCs |dSrD)r&rrrrrEszRedHatPacemaker.postprocrFrrrBrrHs rH)r0rrZsos.report.pluginsrrrrrZ sos.utilitiesr r r?rHrrrr s