| Current Path : /lib/python3/dist-packages/sos/report/__pycache__/ |
| Current File : //lib/python3/dist-packages/sos/report/__pycache__/__init__.cpython-38.pyc |
U
���b�( � @ s8 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/dddgZ0G 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 }| }|rt | �d }nd}|D ]:}t |�t |� t |� dkrP|�|� |}|| | }q"|t |� d � |kr�|d t |� � }|�|� |S )N� � �H )�len�append)Z
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 5 s� e Zd ZdZdZdZdddddddddg g dddg g dg dddddd g g g ddddddg deeg dddg ddddddddddd
�4Z� fdd�Ze d
d� �Z
e dd� �Zdd� Zdd� Z
dd� Zdd� Zdd� Zdd� Zdd� Zdd � Zd!d"� Zd�d#d$�Zd%d&� Zd'd(� Zd)d*� Zd+d,� Zd-d.� Zd/d0� Zd1d2� Zed3d4� �Zd�d5d6�Zd7d8� Z d9d:� Z!d;d<� Z"d=d>� Z#d?d@� Z$dAdB� Z%d�dDdE�Z&dFdG� Z'dHdI� Z(dJdK� Z)dLdM� Z*dNdO� Z+dPdQ� Z,dRdS� Z-dTdU� Z.dVdW� Z/dXdY� Z0dZd[� Z1d�d\d]�Z2d^d_� Z3d`da� Z4dbdc� Z5ddde� Z6dfdg� Z7dhdi� Z8djdk� Z9dldm� Z:dndo� Z;dpdq� Z<drds� Z=dtdu� Z>dvdw� Z?dxdy� Z@dzd{� ZAd|d}� ZBd~d� ZCd�d�� ZDd�d�� ZEd�d�� ZF� ZGS )�� 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 archiveTFr r/ N� � /etc/sos/cleaner/default_mapping)4�
alloptions�all_logs�build�case_id�chroot�clean�container_runtime�keep_binary_files�desc�domains�disable_parsersZdry_run�
estimate_only�experimental�enable_plugins�keywords�keyword_file�plugopts�label�list_plugins�list_presets�
list_profiles�log_size�map_file�
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_urlZupload_directoryZupload_userZupload_passZ
upload_methodZupload_no_ssl_verifyZupload_protocol�
add_preset�
del_presetc s� t t| ��|||� g | _g | _g | _t� | _d | _|| _ d| _
d | _i | _| �
� | �� | j�� | _| jj�d�| _| jj| jd kr�| j�| jj�| _| js�tj�d| jj � | j�� | _d| j_| js�| j�� | _| j�| jj� | �| j�| _t | jjd��r*| jjj!dk�r*t"d� | �#� | �$� d }| jj
| _
| jj
�rPd
}n| j�%� �rn| j
t&j'k�rnd}| j(�)d| j
|f � | jj*t+k�r�| j(�,d
| jj* � t-�.� | j/�0� | �1d� | �2� | �3� | �4� d S )N�/�reportrV zUnknown preset: '%s'
T� verbosityr z~
WARNING: It is not recommended to set verbosity via the preset as it might have
unforseen consequences for your report logs.
�default�cmdline�policyzset sysroot to '%s' (%s)zinvalid chroot mode: %s� )5�superr2 �__init__�loaded_plugins�skipped_plugins�all_options�set�env_vars�archiveZ_args�sysrootrV �estimated_plugsizes�print_header�
_set_debugrg Zis_rootZ_is_root�manifestZ
components�add_section� report_md�opts�arg_defaults�find_preset�sys�stderr�writeZprobe_presetrH �mergeZapply_options_from_cmdline�hasattrrd �printZ_setup_logging�_set_directoriesZin_container�osr# �soslog�debugr9 �chroot_modes�error�logging�shutdown�
tempfile_utilr: �_exit�_check_container_runtime�_get_namespaces�_get_hardware_devices)�self�parser�argsrf �msg�� __class__r( r) rj � sZ �
zSoSReport.__init__c
C s, |� 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� |jd4d5d6d0d7td8g d3� |jd9d:dd;d<d� |jd=d>dd?dd@d � |jdAddBd(� |jdCddDddEd � |jdFddGtdHdIdJ� |jdKd dLd � |jdMdNd0dOtdPg d3� |jdQddRddSd � |jdTddUddVd � |jdWddXddYdZ� |jd[tdd#d\d%� |jd]d^d0d_td`g d3� |jdadtdbddc� |jddd ded � |jdfd dgd � |jdhdidjd0dktg dldJ� |jdmg d0dndodp� |jdqg d0drdsdp� |jdtdduddvd � |jdwddxddyd � |jdzddd{d|� |jd}d d~d � |jdd d�d � |jd�d d�d � |jd�d d�d � |jd�ddd�d�gd�d�� |jd�ddd�d�� |jd�ddd�d�d�gd�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�dp� |jd�d�g d0d�d�� d S )�NzReport Optionsz.These options control how report collects dataz-az--alloptions�
store_truer5 Fz%enable all options for loaded plugins)�action�destre �helpz
--all-logsr6 z-collect all available logs regardless of sizez--sinceZstorerZ zbEscapes archived files older than date. This will also affect --all-logs. Format: YYYYMMDD[HHMMSS])r� r� re �typer� z--buildr7 z;preserve the temporary directory and do not package resultsz --case-idr8 zspecify case identifier)r� r� r� z-cz--chrootr9 r/ zHchroot executed commands to SYSROOT [auto, always, never] (default=auto)z--container-runtimezLDefault container runtime to use for collections. 'auto' for policy control.)re r� z--descz
--descriptionr zDescription for a new preset)r� r� re 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� re z-kz--plugin-optionz
--plugoptsrE z7plugin options in plugname.option=value format (see -l)z--labelz--namerF z"specify an additional report labelz-lz--list-pluginsrG z)list plugins and available plugin optionsz--list-presetsz#display a list of available presetsz--list-profilesrI zBdisplay a list of available profiles and plugins that they includez
--log-sizerJ r3 z)limit the size of collected logs (in MiB))r� r� r� re r� z--namespaceszDlimit number of namespaces to collect output for - 0 means unlimitedz-nz--skip-pluginsrN zdisable these pluginsz--no-reportrP z disable plaintext/HTML reportingz
--no-env-varsrQ z$Do not collect environment variablesz
--no-postprocrR zDisable all post-processing)re r� r� r� z--notezBehaviour notes for new presetz-oz--only-pluginsrU zenable these plugins onlyz--presetzA preset identifier)r� r� r� re z--plugin-timeoutzset a timeout for all pluginsz
--cmd-timeoutz%set a command timeout for all pluginsz-pz --profilez
--profilesrY z)enable plugins used by the given profilesz--skip-commandsrL zdo not execute these commands)re r� r� r� z--skip-filesrM zdo not collect these filesz--verifyr[ z+perform data verification during collectionz--allow-system-changesr\ zJRun commands even if they can change the system (e.g. load kernel modules)z--uploadz+Upload archive to a policy-default location)r� re r� z--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-methodZputZpostz HTTP method to use for uploading)re �choicesr� z--upload-no-ssl-verifyz'Disable SSL verification for upload url)re r� r� z--upload-protocolZhttpsZftpZsftpz$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--maskr: zObfuscate sensitive information)r� re r� r� z --domainsr>