관리-도구
편집 파일: __init__.cpython-39.pyc
a -�_g A � @ sZ d dl Z d dlZd dlZd dlmZ d dlZd dlmZmZ d dl m Z G dd� d�ZdS )� N)�quote)�ConnectionException�CommandTimeoutException)�boldc @ s e Zd ZdZdZdZdd� Zdd� Zdd � Zd d� Z dd � Z edd� �Zedd� �Z edd� �Zedd� �Zedd� �Zdd� Zdd� Zdd� Zdd� Zd d!� Zed"d#� �Zd=d'd(�Zd)d*� Zd+d,� Zd-d.� Zd/d0� Zd1d2� Zd3d4� Zd5d6� Zd7d8� Z d9d:� Z!d;d<� Z"dS )>�RemoteTransportaO The base class used for defining supported remote transports to connect to remote nodes in conjunction with `sos collect`. This abstraction is used to manage the backend connections to nodes so that SoSNode() objects can be leveraged generically to connect to nodes, inspect those nodes, and run commands on them. Z undefinedNc C sF || _ |d | _|d | _|d | _d | _t�d�| _t�d�| _d S )NZcmdlineopts�tmpdir� need_sudoZsosZsos_ui) �address�optsr r � _hostname�loggingZ getLogger�soslogZui_log)�selfr Zcommons� r �E/usr/lib/python3.9/site-packages/sos/collector/transports/__init__.py�__init__# s zRemoteTransport.__init__c C s d}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)r �msgZregr r r �_sanitize_log_msg, s z!RemoteTransport._sanitize_log_msgc C s8 t �� d d }d| j� d|� d|� �}| j�|� dS )z#Used to print and log info messages� � �[�:�] N)�inspect�stack�hostnamer �info�r r �callerZlmsgr r r �log_info2 s zRemoteTransport.log_infoc C s8 t �� d d }d| j� d|� d|� �}| j�|� dS )z$Used to print and log error messagesr r r r r N)r r r r �errorr r r r � log_error8 s zRemoteTransport.log_errorc C sB | � |�}t�� d d }d| j� d|� d|� �}| j�|� dS )z$Used to print and log debug messagesr r r r r N)r r r r r �debug)r r r r r r � log_debug>