File: //lib/python3/dist-packages/sos/report/__pycache__/__init__.cpython-310.pyc
o
i��d33 � @ s6 d dl Z d dlZd dlZd dlZd dlZd dlmZ d dlZd dlZd dl m
Z
mZmZm
Z
mZmZmZ d dlmZ d dlZd dlmZmZ d dlZd dlmZ d dlmZ d dlmZ d dlZd d lmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z( d d
l)m*Z* ej+ej,fZ-dd
d�Z.dd� Z/g d�Z0G dd� de�Z1dS )� N)�datetime)�ImporterHelper�SoSTimeoutError�bold�sos_get_command_output�TIMEOUT_DEFAULT�listdir�
is_executable)�rmtree)�ThreadPoolExecutor�TimeoutError)�_sos)�__version__)�SoSComponent)
�Report�Section�Command�
CopiedFile�CreatedFile�Alert�Note�PlainTextReport�
JSONReport�
HTMLReport)�
SoSCleanerF�, c C s� g }| }|r
t | �d }nd}|D ]}t |�t |� t |� dkr(|�|� |}|| | }q|t |� d � |krC|d t |� � }|�|� |S )N� � �H )�len�append)�
first_line�items�indent�sep�lines�line�newline�item� r) �5/usr/lib/python3/dist-packages/sos/report/__init__.py�_format_list) s
r+ c C s t �d�| �d�S )z� This function will format --since arg to append 0s if enduser
didn't. It's used in the _get_parser.
This will also be a good place to add human readable and relative
date parsing (like '2 days ago') in the future z{:<014s}z%Y%m%d%H%M%S)r �strptime�format)�dater) r) r* �
_format_since; s r/ )�auto�always�neverc sn e Zd ZdZdZdZi dd�dd�dd�dd �d
d�dd�d
d�dd�dd �dg �dg �dd�dd�dd�dg �dd�dg �i dd�dg �dd �dd�dd�dd�d d!�d"d�d#d$�d%g �d&g �d'g �d(d�d)d�d*d�d+d�d,d��i d-d �d.g �d/d�d0e�d1e�d2g �d3d�d4d�d5d�d6g �d7d�d8d�d9d�d:d�d;d�d<d�d=d��dd d d>��Z� fd?d@�Ze dAdB� �Z
e dCdD� �ZdEdF� ZdGdH� Z
dIdJ� ZdKdL� ZdMdN� ZdOdP� ZdQdR� ZdSdT� ZdUdV� Zd�dWdX�ZdYdZ� Zd[d\� Zd]d^� Zd_d`� Zdadb� Zdcdd� Zdedf� Zedgdh� �Zd�didj�Zdkdl� Z dmdn� Z!dodp� Z"dqdr� Z#dsdt� Z$dudv� Z%d�dxdy�Z&dzd{� Z'd|d}� Z(d~d� Z)d�d�� Z*d�d�� Z+d�d�� Z,d�d�� Z-d�d�� Z.d�d�� Z/d�d�� Z0d�d�� Z1d�d�d��Z2d�d�� Z3d�d�� Z4d�d�� Z5d�d�� Z6d�d�� Z7d�d�� Z8d�d�� Z9d�d�� Z:d�d�� Z;d�d�� Z<d�d�� Z=d�d�� Z>d�d�� Z?d�d�� Z@d�d�� ZAd�d�� ZBd�d�� ZCd�d�� ZDd�d�� ZEd�d�� ZFd�d�� ZG� ZHS )�� SoSReportzaRun a set of commands and file collections and save them to a report for
future analysis
z.Collect files and command output in an archiveT�
alloptionsF�all_logs�build�case_idr �chrootr0 �clean�container_runtime�keep_binary_files�desc�domains�disable_parsers�dry_run�
estimate_only�experimental�enable_plugins�journal_size�d �keywords�keyword_fileN�plugopts�label�list_plugins�list_presets�
list_profiles�log_size� �low_priority�map_file� /etc/sos/cleaner/default_mapping�
skip_commands�
skip_files�skip_plugins�
namespaces� no_report�no_env_vars�no_postproc� no_update�note�only_plugins�preset�plugin_timeout�cmd_timeout�profiles�since�verify�allow_system_changes� usernames�upload�
upload_url�upload_directory�upload_user�upload_pass�
upload_method�upload_no_ssl_verify)�upload_protocol�
add_preset�
del_presetc s� t t| ��|||� g | _g | _g | _t� | _d | _|| _ d| _
d | _i | _| �
� | �� | j�� | _| jj�d�| _| jj| jd kre| j�| jj�| _| jsetj�d| jj � | j�� | _d| j_| jsn| j�� | _| j�| jj� | �| j�| _t | jjd�r�| jjj!dkr�| �"| jjj!� | �#� d}| jj
| _
| jj
r�d }n
| j�$� r�| j
t%j&kr�d
}| j'�(d| j
|f � | jj)t*vr�| j'�+d| jj) � t,�-� | j.�/� | �0d
� | �1� | �2� | �3� d S )N�/�reportr[ zUnknown preset: '%s'
T� verbosityr �default�cmdline�policyzset sysroot to '%s' (%s)zinvalid chroot mode: %s� )4�superr3 �__init__�loaded_plugins�skipped_plugins�all_options�set�env_vars�archive�_args�sysrootr[ �estimated_plugsizes�print_header�
_set_debugrr �is_root�_is_root�manifest�
components�add_section� report_md�opts�arg_defaults�find_preset�sys�stderr�write�probe_presetrJ �merge�apply_options_from_cmdline�hasattrro �set_loggers_verbosity�_set_directories�in_container�osr$ �soslog�debugr8 �chroot_modes�error�logging�shutdown�
tempfile_utilr9 �_exit�_check_container_runtime�_get_namespaces�_get_hardware_devices)�self�parser�argsrq �msg�� __class__r) r* ru � sV
zSoSReport.__init__c
C sL |� dd�}|jddddddd � |jd
ddddd � |jd
ddd tdd� |jdddddd � |jddddd� |jddddddd � |jdddd � |jd!d"tdd#d$d%� |jd&dd'd(� |jd)dd*d(� |jd+dd,dd-d � |jd.d/d0d1td2g d3� |jd4td5d6d7d8� |jd9d:d;d0d<td=g d3� |jd>d?dd@dAd� |jdBdCddDddEd � |jdFddGd(� |jdHddIddJd � |jdKddLtdMdNdO� |jdPdddQdR� |jdSd dTd � |jdUdVd0dWtdXg d3� |jdYddZdd[d � |jd\dd]dd^d � |jd_dd`ddadb� |jdctdd#ddd%� |jdedfd0dgtdhg d3� |jdidtdjddk� |jdld dmd � |jdnd dod � |jdpdqdrd0dstg dtdO� |jdug d0dvdwdx� |jdyg d0dzd{dx� |jd|dd}dd~d � |jddd�dd�d � |jd�ddd�dR� |jd�d d�d � |jd�d d�d � |jd�d d�d � |jd�d d�d � |jd�dg d��d�d�� |jd�ddd�d�� |jd�dg d��d�d�� |�� }|jd�tdd�d�� |jd�tdd�d�� |� d�d��}|jd�d�d�d�ddd�d�� |jd�d�g d0d�d�� |jd�d0g d�d�d�� |jd�d0g d�d�d�� |jd�d d�d�d�� |jd�ddd�d�d�� |jd�d�d�d�d�� |jd�ddd�d�dx� |jd�d�g d0d�d�� d S )�NzReport Optionsz.These options control how report collects dataz-az--alloptions�
store_truer4 Fz%enable all options for loaded plugins)�action�destrp �helpz
--all-logsr5 z-collect all available logs regardless of sizez--since�storer_ zbEscapes archived files older than date. This will also affect --all-logs. Format: YYYYMMDD[HHMMSS])r� r� rp �typer� z--buildr6 z;preserve the temporary directory and do not package resultsz --case-idr7 zspecify case identifier)r� r� r� z-cz--chrootr8 r0 zHchroot executed commands to SYSROOT [auto, always, never] (default=auto)z--container-runtimezLDefault container runtime to use for collections. 'auto' for policy control.)rp r� z--descz
--descriptionr zDescription for a new preset)r� r� rp r� z --dry-runz#Run plugins but do not collect data)r� r� z--estimate-onlyzzApproximate disk space requirements for a real sos run; disables --clean and --collect, sets --threads=1 and --no-postprocz--experimentalrA zenable experimental pluginsz-ez--enable-plugins�extendrB zenable these plugins)r� r� r� r� rp z--journal-sizerD rC z+limit the size of collected journals in MiB)r� rp r� r� z-kz--plugin-optionz
--plugoptsrG z7plugin options in plugname.option=value format (see -l)z--labelz--namerH z"specify an additional report labelz-lz--list-pluginsrI z)list plugins and available plugin optionsz--list-presetsz#display a list of available presetsz--list-profilesrK zBdisplay a list of available profiles and plugins that they includez
--log-sizerL rM z6limit the size of collected logs (not journals) in MiB)r� r� r� rp r� z--low-priorityz(generate report with low system priority)r� rp r� z--namespaceszDlimit number of namespaces to collect output for - 0 means unlimitedz-nz--skip-pluginsrS zdisable these pluginsz--no-reportrU z disable plaintext/HTML reportingz
--no-env-varsrV z$Do not collect environment variablesz
--no-postprocrW zDisable all post-processing)rp r� r� r� z--notezBehaviour notes for new presetz-oz--only-pluginsrZ zenable these plugins onlyz--presetzA preset identifier)r� r� r� rp z--plugin-timeoutzset a timeout for all pluginsz
--cmd-timeoutz%set a command timeout for all pluginsz-pz --profilez
--profilesr^ z)enable plugins used by the given profilesz--skip-commandsrQ zdo not execute these commands)rp r� r� r� z--skip-filesrR zdo not collect these filesz--verifyr` z+perform data verification during collectionz--allow-system-changesra zJRun commands even if they can change the system (e.g. load kernel modules)z--uploadz+Upload archive to a policy-default locationz--upload-urlz&Upload the archive to specified serverz--upload-directoryz$Specify upload directory for archivez
--upload-userz'Username to authenticate to server withz
--upload-passz'Password to authenticate to server withz--upload-method)r0 �put�postz HTTP method to use for uploading)rp �choicesr� z--upload-no-ssl-verifyz'Disable SSL verification for upload url)rp r� r� z--upload-protocol)r0 �https�ftp�sftpz$Manually specify the upload protocol�--add-presetz#Add a new named command line preset)r� r� r� z--del-presetz$Delete the named command line presetzCleaner/Masking Optionsz7These options control how data obfuscation is performedz--cleanz --cleanerz--maskr9 zObfuscate sensitive information)r� rp r� r� z --domainsr= z$Additional domain names to obfuscatez--disable-parsersr>