Spamworldpro Mini Shell
Spamworldpro


Server : Apache/2.4.52 (Ubuntu)
System : Linux webserver 6.8.0-49-generic #49~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Nov 6 17:42:15 UTC 2 x86_64
User : www-data ( 33)
PHP Version : 8.1.2-1ubuntu2.21
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

i��ds��@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)�
parse_version)�local�control_persist�oc�	saltstack�jujuc@s�eZdZ		dgdd�Zedd��Zdd�Zd	d
�Zdd�Zed
d��Z	dd�Z
dd�Zdd�Zdd�Z
dhdd�Zedd��Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zdhd.d/�Zd0d1�Zd2d3�Zd4d5�Zd6d7�Z		did9d:�Zd;d<�Zd=d>�Z d?d@�Z!dAdB�Z"dCdD�Z#dEdF�Z$dGdH�Z%dIdJ�Z&dKdL�Z'dMdN�Z(dOdP�Z)dQdR�Z*dSdT�Z+dUdV�Z,dWdX�Z-dYdZ�Z.d[d\�Z/d]d^�Z0d_d`�Z1dadb�Z2dcdd�Z3dedf�Z4dS)j�SosNodeNTc
Cs�|��|_||_|d|_|��|d|_|d|_|d|_|d|_d|_	d|_
d|_d|_i|_
i|_|p<|jj|_|jjsK|jjsK|j|j_|rQ||j_d|_d|_d|_g|_dgggg|dd�|_d	|_t�d
�|_t�d�|_|�|�|_|jjr�|jjdk|_z	|j� |j�Wnt!y�}z|�"d
|��d}~ww|�#�|_
|jj|_|j	r�|jj$r�d}|j%r�|r�|j
s�|j�&�dS|j	r�|�'�r�d|j
_(|j
j(r�|�)�|�*�dSdSdS)N�cmdlineopts�tmpdir�hostlen�	need_sudo�sos_optionsF�sos_cmd)�version�enabled�disabled�options�presetsr�	sosreport�sos�sos_ui�rootz!Unable to open remote session: %s)+�strip�address�commons�opts�_assign_config_optsrrrrr�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&r.�
local_sudo�
load_facts�err�rN�7/usr/lib/python3/dist-packages/sos/collector/sosnode.py�__init__*st






���



�zSosNode.__init__cCs|jr|jjSdS)NT)r=rD�rJrNrNrOrDlszSosNode.connectedcCs|j��dS)zDWrapper to close the remote session via our transport agent
        N)r=rErQrNrNrOrEsszSosNode.disconnectcCsv|jdvrd|_t|j|�S|jjt��vr t|jj|j|�S|jjdkr5|�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�autoz6Connection failed: unknown or unsupported transport %s)
r%rrr'�	transport�
TRANSPORTS�keysrAr
r)rJr&rNrNrOr<xs
��zSosNode._load_remote_transportcCsd�|j|jd|�S)Nz{:<{}} : {}�)�format�	_hostnamer�rJ�msgrNrNrO�_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��=rW)r-r�os�environ�copy�run_command�split)rJ�ret�ln�_valrNrNrO�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�rTN)�manifest�	add_fieldrYr)�distror6r=�name)rJrnrNrNrO�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)ra�path�exists�	log_debugrb�getrQrNrNrOrF�s

zSosNode.check_in_containercCs�|jjrq|jj|jj|��|jjd�}|j|dd�}|ddvrf|ddkr@d|dvr3|�d	�t	�d
|dvr@|�d�t	�|j|j�
�dd�}|ddkr[|�d
|jj�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 %s createdz*Could not start container after create: %sz&Could not create container on host: %sN)
r)rGrHr'rx�get_container_auth�force_pull_imagerdrAr@�restart_sos_container�log_info�sos_container_name)rJ�cmd�resrfrNrNrOrH�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_authfilerQrNrNrOr~�s��zSosNode.get_container_authFcCs6z|jd||d�}|ddkWStyYdSw)z3Checks for the presence of fname on the remote nodezstat %sr{r]rF)rdr@)rJ�fnamer|r�rNrNrO�file_exists�s�zSosNode.file_existscCs|jrd|jvr|jS|jS)NrR)r+r%rQrNrNrOrY�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)rJr[�regrNrNrO�_sanitize_log_msg�szSosNode._sanitize_log_msgcCs|j�|�|��dS)z:Format a ui message that includes host name and formattingN)r;�infor\rZrNrNrO�ui_msg�szSosNode.ui_msgcC�0t��dd}d|j||f}|j�|�dS)z#Used to print and log info messagesrW��
[%s:%s] %sN)�inspect�stackrYr:r��rJr[�caller�lmsgrNrNrOr���zSosNode.log_infocCr�)z$Used to print and log error messagesrWr�r�N)r�r�rYr:�errorr�rNrNrOrAr�zSosNode.log_errorcCs:|�|�}t��dd}d|j||f}|j�|�dS)z$Used to print and log debug messagesrWr�r�N)r�r�r�rYr:�debug)rJr[r�rNrNrOrvs
zSosNode.log_debugcCs&|jjr
dt|�S|jrd|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
        zsu -c %sz
sudo -S %s)r'�become_rootrr)rJr�rNrNrO�_format_cmds
zSosNode._format_cmdc	
Cs�d}d}|jjdur'|jj�|jj�}|dur&d�|d�}|dr&|d}n|j|jjddd�}|ddkrC|d	���d
�\}}}|ryt	|�d��dkrR|d7}z
|d
|�d�d7}Wnt
yx}z
|�d|�WYd}~nd}~ww||jd<|jdr�|�
d|jd�n|j|jjks�|�d�d|_dS|�d�r�d|_d|j}|j|ddd�}|ddkr�|�|d	�|�d�r�|��dSdS)zLQueries the node for information about the installed version of sos
        N�.r�releaseT��
use_containerr|r]rr^�-��.0�-%sz%Unable to fully parse sos release: %szsos version is %sz!sos is not installed on this nodeFz4.0z
sos reportz%s -l�3.6)r)�container_version_command�package_manager�pkg_version�sos_pkg_name�joinrdr$re�lenr@rvr6r�r%r'�primaryrArD�check_sos_versionr7�_load_sos_plugins�_load_sos_presets)	rJ�ver�rel�pkg�pkgs�_rMr��sosinforNrNrOrIsN�
���





�zSosNode._load_sos_infocCspd|j}|j|ddd�}|ddkr4|d��D]}|���d�r3|�d�d��}|jd	�|�qdSdS)
Nz%s --list-presetsTr�r]rr^zname:rWr)r7rd�
splitlinesr$�
startswithrer6�append)rJr�r��line�pnamerNrNrOr�Os
��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_helpr6)rJr��ENABLED�DISABLED�ALL_OPTIONS�OPTIONS�PROFILES�	enablereg�disreg�optreg�proregrNrNrOr�XszSosNode._load_sos_pluginsc
Csxg}t�||tj�D]/}|��D](}|s)z|�|��d�Wqty(Yqw|�d�}|�dd�|D��qq
|S)Nr�,css �|]}|��r|��VqdS�N�r$)�.0�prNrNrO�	<genexpr>ts�z*SosNode._regex_sos_help.<locals>.<genexpr>)r��findall�Sr�r�rer@�extend)rJ�regexr��is_listr��resultr��rrNrNrOr�is�
�	zSosNode._regex_sos_helpc
CsVz|�d|�|j�|�WSty*}z|�d||f�WYd}~dSd}~ww)z1Reads the specified file and returns the contentszReading file %szException while reading %s: %sNrm)r�r=�	read_filer@rA)rJ�to_readrMrNrNrOr�ws��zSosNode.read_filec	Csp|jr|�d|jdj�|jdSti|jjt�d|jj	|�
d�d�}|r1|�d|j�|S|�d�t�)z[Attempts to identify the host installation against supported
        distributions
        zusing local policy %srjTz/etc/os-release)�cache�sysroot�init�
probe_runtime�remote_exec�remote_checkzloaded policy %s for hostz4Unable to determine host installation. Ignoring node)
rr�r&rprr'r�rr=rdr�rAr)rJr)rNrNrOrB�s
�
�
zSosNode.determine_host_policyc
sj�fdd�}||�}zt�jd�}t|�}||kWSty4}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``
        c
s�z-|�d�d}d}d|vrd|�d�d�d�d}t|�d��dkr)|d7}||WStyJ}z��d||f�|WYd}~Sd}~ww)	Nr�rrm���r�r�r�zUnable to format '%s': %s)rer�r@rv)r��_fver�_relrMrQrNrO�_format_version�s
��z2SosNode.check_sos_version.<locals>._format_versionrzError checking sos version: %sNF)rr6r@rA)rJr�r��_ver�	_node_ver�	_test_verrMrNrQrOr��s
��zSosNode.check_sos_versioncCs|jsdS|jj�|�duS)z2Checks if a given package is installed on the nodeFN)r)r��pkg_by_name)rJr�rNrNrO�is_installed�szSosNode.is_installed�c

Cs�|js2|js2|�d�z|j�|j�}|s|�d�t�Wnty1}z|�d|��d}~ww|r>|jj	r>|j�
|�}|rE|�|�}d|vrKd}|rU|j}	|	�
|�}|j�|||||�S)a�Runs a given cmd, either via the SSH session or locally

        Arguments:
            cmd - the full command to be run
            timeout - time in seconds to wait for the command to complete
            get_pty - If a shell is absolutely needed to run a command, set
                      this to True
            need_root - if a command requires root privileges, setting this to
                        True tells sos-collector to format the command with
                        sudo or su - as appropriate and to input the password
            use_container - Run this command in a container *IF* the host is
                            containerized
        z-Node is disconnected, attempting to reconnectzFailed to reconnect to nodez#Error while trying to reconnect: %sN�atomicT)rDrrvr=�	reconnectr/rr@r)rG�format_container_commandr�ri�updaterd)
rJr��timeout�get_ptyr|r��env�reconnectedrM�_cmd_envrNrNrOrd�s2

���

�zSosNode.run_commandcCsVz|��}|r
|�|�n|�d�|jr|��|_Wn	ty$Ynw|��dS)z.Run an sos report on the node, then collect itz'Unable to determine path of sos archiveN)�execute_sos_command�finalize_sos_pathrAr2�retrieve_sosreportr3r@�cleanup)rJrtrNrNrOr �s

��zSosNode.sosreportcC�||jdvS)z/Verifies if the given preset exists on the noder�r6)rJ�presetrNrNrO�_preset_exists��zSosNode._preset_existscs&t�fdd�|jd|jdfD��S)z/Verifies if the given plugin exists on the nodec3��|]}�|vVqdSr�rN)r��s��pluginrNrOr����z)SosNode._plugin_exists.<locals>.<genexpr>rr)�anyr6�rJr�rNr�rO�_plugin_exists�s
�zSosNode._plugin_existscCr�)z6Checks to see if the plugin is default enabled on noderr�rrNrNrO�_check_enabled�r�zSosNode._check_enabledcCr�)z7Checks to see if the plugin is default disabled on noderr�rrNrNrO�_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)rerrr'�enable_pluginsrr6)rJ�opt�plugrNrNrO�_plugin_option_existss


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��orQrNrOr�s�z,SosNode._fmt_sos_opt_list.<locals>.<genexpr>)r�)rJr'rNrQrO�_fmt_sos_opt_listszSosNode._fmt_sos_opt_listcCs
||_dS)zVExpose the node to the cluster profile determined for the
        environment
        N)r*)rJr*rNrNrO�set_clusters
zSosNode.set_clustercsX|jjr|js
|jj|_n	|�d|jj�|jjr,|jjD]
}||jvr+|j�|�q|jjrE|jjD]��|jvrD|jj�|j�<q4|jjrl|jjD]�t	�fdd�|j
D��skd�|jj�f}|j
�|�qM|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.
        zYCluster specified preset %s but user has also defined a preset. Using user specification.c3r�r�rNr�rrNrOr�:rz2SosNode.update_cmd_from_cluster.<locals>.<genexpr>�%s=%sN)r*�
sos_presetr�r��sos_pluginsrr�r�sos_plugin_optionsr�plugopts�check_node_is_primary�lock�set_primary_options�set_node_options)rJr�optionrNrrO�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�rQrNrNrOr(Gs
zSosNode._assign_config_optscs��jd}���}|rd|t|�f}g}��d�r-�jjdkr-|�dtt�jj�����d�rC�jjrC|�dtt�jj�����d�ri�jj	rQ|�d	��jj
rZ|�d
��jjri|�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�r9�fdd��jD�}|�r9|�d td�
d!d"�|D�����j�rW���j��rO|�d#t�j��n��d$�j��j �r��fd%d��j D�}t!|�t!�j �k�r�t"t#�j �t#|��}��d&|���$�j �}	|	�r�|�d't|	��d(|d�
|�f�_%��&d)�j%��j'�(d*�j%�d+S�j)�r�fd,d��j)D�}
t!|
�t!�j)�k�r�t"t#�j)�t#|
��}��d-|���$|
�}|�r�|�d.t|���j*�r%�fd/d��j*D�}t!|�t!�j*�k�rt"t#�j*�t#|��}
��d0|
���$|�}|�r%|�d1t|��d(|d�
|�f�_%��&d)�j%��j'�(d*�j%�d+S)2zZUse host facts and compare to the cluster type to modify the sos
        command if neededrz%s %s r��z--threads=%sz3.7z--plugin-timeout=%sz3.8z--allow-system-changesz
--no-env-varsz
--since=%sz4.1z--skip-commands=%sr�z--skip-files=%sz4.2z--cmd-timeout=%sz4.3z4.2-13rSz--container-runtime=%sz--namespaces=%sz4.5.2z--journal-size=z--low-priorityr z--� rmcs8g|]}��|�d�d�r��|�d�d�r|�qS)r�rr`)rrer	rrQrNrO�
<listcomp>�s
�
�z,SosNode.finalize_sos_cmd.<locals>.<listcomp>z-k %scss�|]}|VqdSr�rNrrNrNrOr��s�z+SosNode.finalize_sos_cmd.<locals>.<genexpr>z--preset=%sz?Requested to enable preset %s but preset does not exist on nodec�g|]	}��|�r|�qSrNr
rrQrNrOr ��zBRequested plugins %s were requested to be enabled but do not existz--only-plugins=%sz%s %szFinal sos command set to %srlNcr!rN)rrrQrNrOr �r"zARequested to skip plugins %s, but plugins are already not enabledz--skip-plugins=%scs.g|]}|�jvr��|�r��|�r|�qSrN)rrrrrQrNrOr �s
���zORequested to enable plugins %s, but plugins are already enabled or do not existz--enable-plugins=%s)+r6�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�replacerartr)�sos_bin_pathr7rrr�r�rvrr�r�setr
rr�rnrorr)rJr�label�sos_optsrrhr'�plugs�not_only�only�skip�not_skip�skipln�not_on�enablerNrQrO�finalize_sos_cmdRs�


�



���
�
�
�

�

""���
�
zSosNode.finalize_sos_cmdcCs�d}||j�|�7}|jjr||sd|jjnd|jj7}|s"dS|�d|�|�d�r1d}nd}d	|j�d
�d|f}d||fS)
z?Determine what, if any, label should be added to the sos reportrmz%sr�NzLabel for sos report set to %sr�z--labelz--namez%s-%sr�rr)r*�get_node_labelr'r4rvr�r%re)rJr4�lcmdrNrNrOr#�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 fromrmrzFinal sos path: %s�/r��collected_archiveN)	r)�sos_path_stripr1rer�r2�archivernro)rJrt�pstriprNrNrOr��szSosNode.finalize_sos_pathcCsR|dkrdS|dkrd|vrdS|dkrdSt|�dkr%|�d	�dd�Sd
|S)Nr�z+sos report process received SIGKILL on noderW�sudozsudo attempt failed�z4sos report terminated unexpectedly. Check disk spacer�
zsos exited with code %s)r�re)rJ�rc�stdoutrNrNrO�determine_sos_error�szSosNode.determine_sos_errorc
Cs�|�d�z�d}d}|j|j|jjddd|jd�}|ddkr�|d��D]$}t�|d�r1|��}|�	d	�r>|�
d
�d}q%|�	d�rI|�
�d
}q%|r}|j�d|�t
|�dkrc|j�dd�|WSt
|�dkrs|j�dd�|WS|j�dd�|WS|j�dd�|WS|�|d|d�}|�d|d|df�t|��ty�|�d��ty�}z|�d|���|�d|����d}~ww)z2Run sos report and capture the resulting file pathzGenerating sos report...FT)r�r�r|r�r�r]rr^z*sosreport-*tar*)z sha256	z md5	�	rWzThe checksum is: r��checksum� �
checksum_type�md5�@�sha256�unknownz*Error running sos report. rc = %s msg = %szTimeout exceededz'Exception during sos report execution: zError running sos report: N)r�rdrr'r�r,r��fnmatchr$r�rernror�rKrvr@r
rAr�)rJrtrMr�r�rMrNrNrOr�sZ
�

��
����
��zSosNode.execute_sos_commandc
Cs�|jd}tj�||�d�d�}z |�|�r(|�d||f�|j�||�WS|�	d|�WdSt
yM}z|�	d||f�WYd}~dSd}~ww)z7Copies the specified file from the host to our temp dirrAr�zCopying remote %s to local %szFAttempting to copy remote file %s, but it does not exist on filesystemFzFailed to retrieve %s: %sN)rrartr�rer�r�r=�
retrieve_filervr@)rJrt�destdir�destrMrNrNrOrU0s"

����zSosNode.retrieve_filec
Cs�d�|���}z;t|�d��dkr|�d|�WdS|�|�r9|�d|�d|}|j|dd	�}|d
dkWS|�d|�WdSty^}z|�d
||f�WYd}~dSd}~ww)z|Removes the spciefied file from the host. This should only be used
        after we have retrieved the file already
        rmrAr�zJRefusing to remove path %s: appears to be incorrect and possibly dangerousFzRemoving file %szrm -f %sTr{r]rzHAttempting to remove remote file %s, but it does not exist on filesystemzFailed to remove %s: %sN)r�rer�rvr�r�rdr@)rJrtr�r��erNrNrO�remove_fileAs*�
���zSosNode.remove_filec
Cs.|jrl|js
|jjr"z|�|j�Wnty!|�d�YdSw|�d|j�|�	d�z|�
|j�}WntyO}z|�|�WYd}~dSd}~ww|re|�	d�|j�|j�
d�d�d	S|�	d
�dS|j��rw|j��}ndd�|j��D�d}|j�d
|j|f�|�d|�dS)z+Collect the sosreport archive from the nodezFailed to make archive readableFzRetrieving sos report from %szRetrieving sos report...Nz!Successfully collected sos reportrAr�TzFailed to retrieve sos reportcSsg|]	}|jr|���qSrNr�)r��xrNrNrOr tr"z.SosNode.retrieve_sosreport.<locals>.<listcomp>z"Failed to run sos report on %s: %szFailed to run sos report. %s)r2rr'r��make_archive_readabler@rAr�r%r�rUr5r�re�stderr�readrJ�	readlinesr:r�)rJrfrMrXrNrNrOr�Xs>
�

��


�zSosNode.retrieve_sosreportcCsT|jdus|jr
dSd|jvr|�d|j�dS|�|j�}|s(|�d�dSdS)zuRemove the sosreport archive from the node, since we have
        collected it and it would be wasted space otherwiseNr zFNode sos report path %s looks incorrect. Not attempting to remove pathzFailed to remove sos report)r2rrvrYrA)rJ�removedrNrNrO�remove_sos_archivezs
��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`r2rYr)�set_cleanup_cmdrd)rJ�extr�rNrNrOr��s�
�zSosNode.cleanupcCs�|D]p}zS|js|jjr7z|�|�Wn#ty6}z|�d|�|�d||f�WYd}~Wqd}~ww|�|�}|rO|j�	|�
d�d�|�|�n|�d|�Wqtyr}zd|}|�|�WYd}~qd}~wwdS)z4Collect the file created by a cluster outside of soszUnable to retrieve file %sz#Failed to make file %s readable: %sNrAr�z1Error collecting additional data from primary: %s)rr'r�r[r@rArvrUr5r�rerY)rJ�	filenames�filenamerMrfrXr[rNrNrO�collect_extra_cmd�s2���
����zSosNode.collect_extra_cmdcCsFd|}|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 %s�
T)r�r|r]rz6Exception while making %s readable. Return code was %s)rdrAr@)rJ�filepathr�r�r[rNrNrOr[�szSosNode.make_archive_readable)NNT)F)r�FFFN)5�__name__�
__module__�__qualname__rP�propertyrDrEr<r\rirrrFrHr~r�rYr�r�r�rArvr�rIr�r�r�r�rBr�r�rdr r�rrrr	r
rrr(r>r#r�rKr�rUrYr�r`r�rer[rNrNrNrOr(st
�B


(


3	
	$
�')
,"r)rTr�r8rar��pipesr�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.utilitiesrrUrrNrNrNrO�<module>s,
�	

Spamworldpro Mini