https://t.me/RX1948
Server : Apache
System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
User : dh_edsupp ( 6597262)
PHP Version : 8.2.26
Disable Function : NONE
Directory :  /lib/python3/dist-packages/sos/collector/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/sos/collector/__pycache__/sosnode.cpython-310.pyc
o

-�_g͗�@s�ddlZddlZddlZddlZddlZddlmZddlmZddl	m
Z
ddlmZddl
mZddlmZddlmZdd	lmZdd
lmZmZmZmZddlmZeeeeed�ZGd
d�d�ZdS)�N)�quote)�load)�
InitSystem)�JujuSSH)�SSHControlPersist)�LocalTransport)�OCTransport)�SaltStackMaster)�CommandTimeoutException�ConnectionException�UnsupportedHostException�InvalidTransportException)�sos_parse_version)�local�control_persist�oc�	saltstack�jujuc@s�eZdZ		dhdd�Zedd��Zdd�Zd	d
�Zdd�Zed
d��Z	dd�Z
dd�Zdd�Zdd�Z
didd�Zedd��Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zdid.d/�Zd0d1�Zd2d3�Zd4d5�Zd6d7�Z		djd:d;�Zd<d=�Zd>d?�Z d@dA�Z!dBdC�Z"dDdE�Z#dFdG�Z$dHdI�Z%dJdK�Z&dLdM�Z'dNdO�Z(dPdQ�Z)dRdS�Z*dTdU�Z+dVdW�Z,dXdY�Z-dZd[�Z.d\d]�Z/d^d_�Z0d`da�Z1dbdc�Z2ddde�Z3dfdg�Z4dS)k�SosNodeNTc
Cs�|��|_||_|d|_|��|d|_|d|_|d|_|d|_|jj	|_	|jj
|_
d|_d|_d|_
d|_i|_i|_|pF|jj|_|jjsU|jjsU|j|j_|r[||j_d|_d|_d|_g|_dgggg|dd�|_d	|_t�d
�|_t�d�|_|�|�|_ |j j!r�|j j!dk|_z	|j �"|j�Wnt#y�}z	|�$d
|����d}~ww|�%�|_|j j|_|jr�|jj&r�d}|j'r�|r�|js�|j �(�dS|jr�|�)�r�d|j_*|jj*r�|�+�|�,�dS)N�cmdlineopts�tmpdir�hostlen�	need_sudo�sos_optionsF�sos_cmd)�version�enabled�disabled�options�presetsr�	sosreport�sos�sos_ui�rootzUnable to open remote session: )-�strip�address�commons�opts�_assign_config_optsrrrr�node_config_file�inherit_config_filer�host�cluster�hostname�sos_env_vars�	_env_vars�password�	_password�
nopasswd_sudo�sudo_pw�sos_path�	retrieved�hash_retrieved�	file_list�sos_info�sos_bin�logging�	getLogger�soslog�ui_log�_load_remote_transport�
_transport�default_user�connect�	Exception�	log_error�determine_host_policy�no_local�	connected�
disconnect�check_in_container�
containerized�create_sos_container�_load_sos_info)�selfr%r&r0�
local_sudo�
load_facts�err�rP�7/usr/lib/python3/dist-packages/sos/collector/sosnode.py�__init__,sx








���



zSosNode.__init__cCs|jr|jjSdS)NT)r?rF�rLrPrPrQrFqszSosNode.connectedcCs|j��dS)zDWrapper to close the remote session via our transport agent
        N)r?rGrSrPrPrQrGxszSosNode.disconnectcCst|jdvrd|_t|j|�S|jjtvrt|jj|j|�S|jjdkr4|�d|jj���t|jj��t|j|�S)z�Determine the type of remote transport to load for this node, then
        return an instantiated instance of that transport
        )�	localhostz	127.0.0.1T�autoz4Connection failed: unknown or unsupported transport )	r%rrr'�	transport�
TRANSPORTSrCr
r)rLr&rPrPrQr>}s
��zSosNode._load_remote_transportcCs|jd|jd���d|��S)N�<�z : )�	_hostnamer�rL�msgrPrPrQ�_fmt_msg�szSosNode._fmt_msgcCsp|js5|jrtj��|_|jS|�d�}|ddkr5|d�d�D]}|s&q!|�d�}|d|j|d<q!|jS)Nz
env --null�statusr�output��=rY)r/r�os�environ�copy�run_command�split)rL�ret�ln�_valrPrPrQ�env_vars�s	
�
zSosNode.env_varscCs`||_|j�d|j�|j�d|jj�|j�d|jd�|j�dd�|j�d|jj�dS)	z>Set the manifest section that this node will write to
        r-�policy�sos_versionr�final_sos_command�rVN)�manifest�	add_fieldrZr+�os_release_namer8r?�name)rLrorPrPrQ�set_node_manifest�szSosNode.set_node_manifestcCs<tj�d�r
|�d�dStj�d�dur|�d�dSdS)zV
        Tries to identify if we are currently running in a container or not.
        z/run/.containerenvz/Found /run/.containerenv. Running in container.T�	containerNz/Found env var 'container'. Running in containerF)rb�path�exists�	log_debugrc�getrSrPrPrQrH�s

zSosNode.check_in_containercCs�|jjru|jj|jj|��|jjd�}|j|dd�}|ddvri|ddkr@d|dvr3|�d	�t	�d
|dvr@|�d�t	�|j|j�
�dd�}|ddkr]|�d
|jj�d��dS|�d|d���t	�|�d|d���t	�dS)zJIf the host is containerized, create the container we'll be using
        )�image�auth�
force_pullT��	need_rootr^)r�}r~zunable to retrieve auth tokenr_zHCould not pull image. Provide either a username and password or authfilezunknown: Not foundz%Specified image not found on registryrzTemporary container z createdz(Could not start container after create: z$Could not create container on host: F)
r+rIrJr'ry�get_container_auth�force_pull_imagererCrB�restart_sos_container�log_info�sos_container_name)rL�cmd�resrgrPrPrQrJ�sD��
�
���zSosNode.create_sos_containercCsB|jjr|jjd�|jj|jj�S|jjd�|jjp|jj�S)zrDetermine what the auth string should be to pull the image used to
        deploy our temporary container
        �default)	r'�
registry_userr+�runtimes�fmt_registry_credentials�registry_password�fmt_registry_authfile�registry_authfile�container_authfilerSrPrPrQr�s��zSosNode.get_container_authFcCs8z|jd|��|d�}|ddkWStyYdSw)z3Checks for the presence of fname on the remote nodezstat r|r^rF)rerB)rL�fnamer}r�rPrPrQ�file_exists�s�zSosNode.file_existscCs|jrd|jvr|jS|jS)NrT)r-r%rSrPrPrQrZ�szSosNode._hostnamecCsd}t�|d|�S)zUAttempts to obfuscate sensitive information in log messages such as
        passwordsz>(?P<var>(pass|key|secret|PASS|KEY|SECRET).*?=)(?P<value>.*?\s)z\g<var>****** )�re�sub)rLr\�regrPrPrQ�_sanitize_log_msg�szSosNode._sanitize_log_msgcCs|j�|�|��dS)z:Format a ui message that includes host name and formattingN)r=�infor]r[rPrPrQ�ui_msg�szSosNode.ui_msgcC�8t��dd}d|j�d|�d|��}|j�|�dS)z#Used to print and log info messagesrY��[�:�] N)�inspect�stackrZr<r��rLr\�caller�lmsgrPrPrQr��zSosNode.log_infocCr�)z$Used to print and log error messagesrYr�r�r�r�N)r�r�rZr<�errorr�rPrPrQrC	r�zSosNode.log_errorcCsB|�|�}t��dd}d|j�d|�d|��}|j�|�dS)z$Used to print and log debug messagesrYr�r�r�r�N)r�r�r�rZr<�debug)rLr\r�rPrPrQrws
zSosNode.log_debugcCsR|j�dtj�d��dk}|jr|r|S|jjrdt|���S|jr'd|��S|S)z�If we need to provide a sudo or root password to a command, then
        here we prefix the command with the correct bits
        �USERr#zsu -c zsudo -S )	r/rxrbrcrr'�become_rootrr)rLr��is_rootrPrPrQ�_format_cmds

zSosNode._format_cmdc	
Cs�d}d}|jjdur'|jj�|jj�}|dur&d�|d�}|dr&|d}n|j|jjddd�}|ddkrC|d	���d
�\}}}|r{t	|�d��dkrR|d7}z|d
|�d�d��7}Wnt
yz}z|�d
|���WYd}~nd}~ww||jd<|jdr�|�
d|jd���n|j|jjks�|�d�d|_dS|�d�r�d|_|j�d�}|j|ddd�}|ddkr�|�|d	�|�d�r�|��dS)zLQueries the node for information about the installed version of sos
        N�.r�releaseT��
use_containerr}r^rr_�-�z.0z#Unable to fully parse sos release: zsos version is z!sos is not installed on this nodeFz4.0z
sos reportz -l�3.6)r+�container_version_command�package_manager�pkg_version�sos_pkg_name�joinrer$rf�lenrBrwr8r�r%r'�primaryrCrF�check_sos_versionr9�_load_sos_plugins�_load_sos_presets)	rL�ver�rel�pkg�pkgs�_rOr��sosinforPrPrQrK#sN�
���




zSosNode._load_sos_infocCsr|j�d�}|j|ddd�}|ddkr5|d��D]}|���d�r4|�d�d��}|jd	�|�qdSdS)
Nz --list-presetsTr�r^rr_zname:rYr)r9re�
splitlinesr$�
startswithrfr8�append)rLr�r��line�pnamerPrPrQr�Ws��zSosNode._load_sos_presetscCs�d}d}d}d}d}|d|}|d|}|d|}	|dd}
|�||�|jd<|�||�|jd	<|�|	|�|jd
<|�|
|d�|jd<dS)
Nz,The following plugins are currently enabled:z-The following plugins are currently disabled:z4The following options are available for ALL plugins:z+The following plugin options are available:z	Profiles:z(.*?)z

rrrT�profiles)�_regex_sos_helpr8)rLr��ENABLED�DISABLED�ALL_OPTIONS�OPTIONS�PROFILES�	enablereg�disreg�optreg�proregrPrPrQr�`szSosNode._load_sos_pluginsc
Cs�g}t�||tj�D]D}|��D]=}|s>z|��}r"|�|d�Wqty=}z|�d|���WYd}~qd}~ww|�d�}	|�dd�|	D��qq
|S)NrzError parsing sos help: �,css �|]}|��r|��VqdS�N)r$)�.0�prPrPrQ�	<genexpr>}s�z*SosNode._regex_sos_help.<locals>.<genexpr>)	r��findall�Sr�rfr�rBrw�extend)
rL�regexr��is_listr��resultr��lsrO�rrPrPrQr�qs ���
�
zSosNode._regex_sos_helpc
Cs\z|�d|���|j�|�WSty-}z|�d|�d|���WYd}~dSd}~ww)z1Reads the specified file and returns the contentsz
Reading file zException while reading �: Nrn)r�r?�	read_filerBrC)rL�to_readrOrPrPrQr��s��zSosNode.read_filec	Csv|jr|�d|jdj���|jdSti|jjt�d|jj	|�
d�d�}|r4|�d|j�d��|S|�d�t�)	z[Attempts to identify the host installation against supported
        distributions
        zusing local policy rkTz/etc/os-release)�cache�sysroot�init�
probe_runtime�remote_exec�remote_checkzloaded policy z	 for hostz4Unable to determine host installation. Ignoring node)
rr�r&rqrr'r�rr?rer�rCr)rLr+rPrPrQrD�s�
�
zSosNode.determine_host_policyc
CsTz|jd}t|�t|�kWSty)}z|�d|���WYd}~dSd}~ww)a�Checks to see if the sos installation on the node is AT LEAST the
        given ver. This means that if the installed version is greater than
        ver, this will still return True

        :param ver: Version number we are trying to verify is installed
        :type ver:  ``str``

        :returns:   True if installed version is at least ``ver``, else False
        :rtype:     ``bool``
        rzError checking sos version: NF)r8rrBrC)rLr��	_node_verrOrPrPrQr��s
��zSosNode.check_sos_versioncCs|jsdS|jj�|�duS)z2Checks if a given package is installed on the nodeFN)r+r��pkg_by_name)rLr�rPrPrQ�is_installed�szSosNode.is_installed�rUc

Cs�|js3|js3|�d�z|j�|j�}|s|�d�t�Wnty2}z	|�d|����d}~ww|r?|jj	r?|j�
|�}|rF|�|�}|rP|j}	|	�
|�}|j�|||||�S)a�Runs a given cmd, either via the SSH session or locally

        :param cmd:     The full command to be run
        :type cmd:      ``str``

        :param timeout: Time in seconds to wait for `cmd` to complete
        :type timeout:  ``int``

        :param use_shell: If a shell is needed to run `cmd`, set to True
        :type use_shell:  ``bool`` or ``auto`` for transport-determined

        :param use_container: Run this command in a container *IF* the host
                              is a containerized host
        :type use_container: ``bool``

        :param env: Pass environment variables to set for this `cmd`
        :type env:  ``dict``
        z-Node is disconnected, attempting to reconnectzFailed to reconnect to nodez!Error while trying to reconnect: N)rFrrwr?�	reconnectr1rrBr+rI�format_container_commandr�rj�updatere)
rLr��timeout�	use_shellr}r��env�reconnectedrO�_cmd_envrPrPrQre�s.

���

�zSosNode.run_commandc
Csxz|��}|r
|�|�n|�d�|jr|��|_Wnty5}z|�d|���WYd}~nd}~ww|��dS)z.Run an sos report on the node, then collect itz'Unable to determine path of sos archivezError during sos execution: N)�execute_sos_command�finalize_sos_pathrCr4�retrieve_sosreportr5rB�cleanup)rLrurOrPrPrQr �s

���zSosNode.sosreportcC�||jdvS)z/Verifies if the given preset exists on the noder�r8)rL�presetrPrPrQ�_preset_exists��zSosNode._preset_existscs&t�fdd�|jd|jdfD��S)z/Verifies if the given plugin exists on the nodec3��|]}�|vVqdSr�rP)r��s��pluginrPrQr����z)SosNode._plugin_exists.<locals>.<genexpr>rr)�anyr8�rLr�rPr�rQ�_plugin_exists�s
�zSosNode._plugin_existscCr�)z6Checks to see if the plugin is default enabled on noderr�r�rPrPrQ�_check_enabled�r�zSosNode._check_enabledcCr�)z7Checks to see if the plugin is default disabled on noderr�r�rPrPrQ�_check_disabled�r�zSosNode._check_disabledcCsR|�d�d}|�|�sdS|�|�r||jjvrdS|�|�r'||jdvSdS)z�Attempts to verify that the given option is available on the node.
        Note that we only get available options for enabled plugins, so if a
        plugin has been force-enabled we cannot validate if the plugin option
        is correct or notr�rFrT)rfrrr'�enable_pluginsrr8)rL�opt�plugrPrPrQ�_plugin_option_exists�s


zSosNode._plugin_option_existscsd��fdd�|D��S)z^Returns a comma delimited list for sos plugins that are confirmed
        to exist on the noder�c3s�|]
}��|�r|VqdSr��r�r��orSrPrQr�s�z,SosNode._fmt_sos_opt_list.<locals>.<genexpr>)r�)rLr'rPrSrQ�_fmt_sos_opt_listszSosNode._fmt_sos_opt_listcCs
||_dS)zVExpose the node to the cluster profile determined for the
        environment
        N)r,)rLr,rPrPrQ�set_clusters
zSosNode.set_clustercs^|jjr|js
|jj|_n|�d|jj�d��|jjr.|jjD]
}||jvr-|j�|�q |jjrG|jjD]��|jvrF|jj�|j�<q6|jjro|jjD]�t	�fdd�|j
D��sn��d|jj���}|j
�|�qO|j�|�r�|jj�|j�
|�Wd�dS1s�wYdS|jj�|j�|�Wd�dS1s�wYdS)a+This is used to modify the sos report command run on the nodes.
        By default, sos report is run without any options, using this will
        allow the profile to specify what plugins to run or not and what
        options to use.

        This will NOT override user supplied options.
        zCluster specified preset z> but user has also defined a preset. Using user specification.c3r�r�rPr�rrPrQr�2r�z2SosNode.update_cmd_from_cluster.<locals>.<genexpr>raN)r,�
sos_presetr�r��sos_pluginsrr�r�sos_plugin_optionsr��plugopts�check_node_is_primary�lock�set_primary_options�set_node_options)rLr�optionrPrrQ�update_cmd_from_clusters:
�
�
��
"�
"�zSosNode.update_cmd_from_clustercCsJt|jj�|_t|jj�|_t|jj�|_t|jj�|_t|jj�|_dS)z�From the global opts configuration, assign those values locally
        to this node so that they may be acted on individually.
        N)�listr'�only_plugins�skip_pluginsrrr�rSrPrPrQr(>s
zSosNode._assign_config_optscs��jd}���}|r|�dt|��d�}g}��d�r0�jjdkr0|�dtt�jj�������d�rG�jjrG|�dtt�jj�������d�rn�jj	rU|�d	��jj
r^|�d
��jjrn|�dt�jj������d�r��jjr�|�d
td�
�jj������jjr�|�dtd�
�jj�������d�r��jjr�|�dtt�jj�������d�s���d�r؈jjdkr�|�d�jj����jjr�|�d�jj�����d�r�jjr�|�d�jj����jjr�|�d����|�dtj�
�jj�j��}�jD]}�j|}|�d|�d|�r|nd����q	�j�rE�fdd��jD�}|�rE|�dtd�
d d!�|D�������j�rf���j��r\|�d"t�j����n
��d#�j�d$���j �rÇfd%d��j D�}t!|�t!�j �k�r�t"t#�j �t#|��}��d&|�d'����$�j �}	|	�r�|�d(t|	����|�dd�
|����_%��&d)�j%����j'�(d*�j%�d+S�j)�r�fd,d��j)D�}
t!|
�t!�j)�k�r�t"t#�j)�t#|
��}��d-|�d.����$|
�}|�r|�d/t|�����j*�r?�fd0d��j*D�}t!|�t!�j*�k�r-t"t#�j*�t#|��}
��d1|
�d2����$|�}|�r?|�d3t|����|�dd�
|����_%��&d)�j%����j'�(d*�j%�d+S)4zZUse host facts and compare to the cluster type to modify the sos
        command if neededr� r��z
--threads=z3.7z--plugin-timeout=z3.8z--allow-system-changesz
--no-env-varsz--since=z4.1z--skip-commands=r�z
--skip-files=z4.2z--cmd-timeout=z4.3z4.2-13rUz--container-runtime=z
--namespaces=z4.5.2z--journal-size=z--low-priorityr z--rncs8g|]}��|�d�d�r��|�d�d�r|�qS)r�rra)rrfrrrSrPrQ�
<listcomp>�s
�
�z,SosNode.finalize_sos_cmd.<locals>.<listcomp>z-k css�|]}|VqdSr�rPrrPrPrQr��s�z+SosNode.finalize_sos_cmd.<locals>.<genexpr>z	--preset=zRequested to enable preset z" but preset does not exist on nodec�g|]	}��|�r|�qSrPrrrSrPrQr��zRequested plugins z. were requested to be enabled but do not existz--only-plugins=zFinal sos command set to rmNcrrP)rrrSrPrQr�rzRequested to skip plugins z%, but plugins are already not enabledz--skip-plugins=cs.g|]}|�jvr��|�r��|�r|�qSrP)rrrrrSrPrQr�s
���zRequested to enable plugins z1, but plugins are already enabled or do not existz--enable-plugins=)+r8�determine_sos_labelrr�r'�threadsr��str�plugin_timeout�allow_system_changes�no_env_vars�since�
skip_commandsr��
skip_files�cmd_timeout�container_runtime�
namespaces�journal_size�low_priorityr�replacerbrur+�sos_bin_pathr9rrr�r�rwrr�r�setr
rr�rorprr)rLr�label�sos_optsrrir'�plugs�not_only�only�skip�not_skip�skipln�not_on�enablerPrSrQ�finalize_sos_cmdIs�


�



��
���

�

$$

zSosNode.finalize_sos_cmdcCs�d}||j�|�7}|jjr||s|jj�nd|jj��7}|s"dS|�d|���|�d�r2d}nd}|j�d�d	�d|��}|�d
|��S)z?Determine what, if any, label should be added to the sos reportrnr�NzLabel for sos report set to r�z--labelz--namer�rra)r,�get_node_labelr'r0rwr�r%rf)rLr0�lcmdrPrPrQr�s�
zSosNode.determine_sos_labelcCs^|jj}|r|�|d�}|��d}|�d|���||_|�d�d|_|j�d|j�dS)z\Use host facts to determine if we need to change the sos path
        we are retrieving fromrnrzFinal sos path: �/����collected_archiveN)	r+�sos_path_stripr-rfr�r4�archiverorp)rLru�pstriprPrPrQr��szSosNode.finalize_sos_pathcCsT|dkrdS|dkrd|vrdS|dkrdSt|�dkr%|�d	�dd�Sd
|��S)Nr>z+sos report process received SIGKILL on noderY�sudozsudo attempt failed�z4sos report terminated unexpectedly. Check disk spacer�
zsos exited with code )r�rf)rL�rc�stdoutrPrPrQ�determine_sos_error�s
zSosNode.determine_sos_errorc
Cs |�d�z�d}d}d}|jjrd|jj��}n)|jjrA|js:d|j�d�d�d�}|j�|jj	|�d|��}nd|jj	��}|rL|j
�d	|��|_
|j|j
|jjd
d
d
|j
d�}|dd
kr�|d��D]$}t�|d�rs|��}|�d�r�|�d�d}qg|�d�r�|��d}qg|r�|j�d|�t|�dkr�|j�dd�|WSt|�dkr�|j�dd�|WS|j�dd�|WS|j�dd�|WS|�|d|d�}|�d|d�d|d���t|��ty�|�d��t�y}z|�d|���|�d |����d!}~ww)"z2Run sos report and capture the resulting file pathzGenerating sos report...Frnz--config-file=z/tmp/r=r>z.confrT)r�r�r}r�r�r^rr_z*sosreport-*tar*)z sha256	z md5	�	rYzThe checksum is: r��checksum� �
checksum_type�md5�@�sha256�unknownzError running sos report. rc = z msg = zTimeout exceededz'Exception during sos report execution: zError running sos report: N)r�r'r)r*rrrfr?�copy_file_to_remote�config_filerrer�r.r��fnmatchr$r�rorpr�rHrwrBr
rCr�)rLrurJ�config_file_arg�
remote_configr�r�rOrPrPrQr��s~
���

��
�����
��zSosNode.execute_sos_commandc
Cs�|jd}tj�||�d�d�}z$|�|�r*|�d|�d|���|j�||�WS|�	d|�d��WdSt
yS}z|�	d|�d	|���WYd
}~dSd
}~ww)z7Copies the specified file from the host to our temp dirr=r>zCopying remote z
 to local zAttempting to copy remote file �%, but it does not exist on filesystemFzFailed to retrieve r�N)rrbrur�rfr�r�r?�
retrieve_filerwrB)rLru�destdir�destrOrPrPrQrW5s

��zSosNode.retrieve_filec
Cs�d�|���}zAt|�d��dkr|�d|�d��WdS|�|�r=|�d|���d|��}|j|d	d
�}|ddkWS|�d
|�d��WdStyf}z|�d|�d|���WYd}~dSd}~ww)z|Removes the spciefied file from the host. This should only be used
        after we have retrieved the file already
        rnr=r�zRefusing to remove path z0: appears to be incorrect and possibly dangerousFzRemoving file zrm -f Tr|r^rz!Attempting to remove remote file rVzFailed to remove r�N)r�rfr�rwr�r�rerB)rLrur�r��erPrPrQ�remove_fileDs"

��zSosNode.remove_filec
Cs�|js|jjrz|�|j�Wnty|�d�YdSw|�d|j���|�	d�z|�
|j�}WntyM}z|�|�WYd}~dSd}~ww|rc|�	d�|j�|j�
d�d�d	S|�	d
�dS)z,Collect the sos report archive from the nodezFailed to make archive readableFzRetrieving sos report from zRetrieving sos report...Nz!Successfully collected sos reportr=r>TzFailed to retrieve sos report)rr'r��make_archive_readabler4rBrCr�r%r�rWr7r�rf)rLrgrOrPrPrQr�Zs,
�

��

zSosNode.retrieve_sosreportcCsX|jdus|jr
dSd|jvr|�d|j�d��dS|�|j�}|s*|�d�dSdS)zvRemove the sos report archive from the node, since we have
        collected it and it would be wasted space otherwiseNr zNode sos report path z/ looks incorrect. Not attempting to remove pathzFailed to remove sos report)r4rrwr[rC)rL�removedrPrPrQ�remove_sos_archiveps
�zSosNode.remove_sos_archivecCsP|��|jrdD]}|�|j|�rnq	|j��}|r&|j|dd�dSdS)z<Remove the sos archive from the node once we have it locally)z.sha256z.md5Tr|N)r^r4r[r+�set_cleanup_cmdre)rL�extr�rPrPrQr�s�
�zSosNode.cleanupcCs�|D]u}zW|js|jjr:z|�|�Wn&ty9}z|�d|���|�d|�d|���WYd}~Wqd}~ww|�|�}|rR|j�	|�
d�d�|�|�n|�d|���Wqtyw}zd|��}|�|�WYd}~qd}~wwdS)z4Collect the file created by a cluster outside of soszUnable to retrieve file zFailed to make file z readable: Nr=r>z/Error collecting additional data from primary: )rr'r�r\rBrCrwrWr7r�rfr[)rL�	filenames�filenamerOrgrZr\rPrPrQ�collect_extra_cmd�s2���
�
���zSosNode.collect_extra_cmdcCsHd|��}|j|ddd�}|ddkrdSd}|�|||df�t�)z�Used to make the given archive world-readable, which is slightly
        better than changing the ownership outright.

        This is only used when we're not connecting as root.
        z
chmod o+r �
T)r�r}r^rz6Exception while making %s readable. Return code was %s)rerCrB)rL�filepathr�r�r\rPrPrQr\�s
zSosNode.make_archive_readable)NNT)F)r�rUFFN)5�__name__�
__module__�__qualname__rR�propertyrFrGr>r]rjrsrHrJrr�rZr�r�r�rCrwr�rKr�r�r�r�rDr�r�rer r�rrrrr
rrr(r:rr�rHr�rWr[r�r^r�rcr\rPrPrPrQr*st
�E


(



4	
	
�((<r)rSr�r:rbr��shlexr�sos.policiesr�sos.policies.init_systemsr�sos.collector.transports.jujur�(sos.collector.transports.control_persistr�sos.collector.transports.localr�sos.collector.transports.ocr�"sos.collector.transports.saltstackr	�sos.collector.exceptionsr
rrr
�
sos.utilitiesrrWrrPrPrPrQ�<module>s,�	

https://t.me/RX1948 - 2025