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/transports/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

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

i��d�$�@sLddlZddlZddlZddlmZddlmZmZmZGdd�de�Z	dS)�N)�RemoteTransport)�
is_executable�sos_get_command_output�SoSTimeoutErrorcszeZdZdZdZdZdd�Zedd��Zdd	�Z	d
d�Z
�fdd
�Z		d�fdd�	Zdd�Z
edd��Zdd�Z�ZS)�OCTransportaq
    This transport leverages the execution of commands via a locally
    available and configured ``oc`` binary for OCPv4 environments.

    The location of the oc binary MUST be in the $PATH used by the locally
    loaded SoS policy. Specifically this means that the binary cannot be in the
    running user's home directory, such as ~/.local/bin.

    OCPv4 clusters generally discourage the use of SSH, so this transport may
    be used to remove our use of SSH in favor of the environment provided
    method of connecting to nodes and executing commands via debug pods.

    The debug pod created will be a privileged pod that mounts the host's
    filesystem internally so that sos report collections reflect the host, and
    not the container in which it runs.

    This transport will execute within a temporary 'sos-collect-tmp' project
    created by the OCP cluster profile. The project will be removed at the end
    of execution.

    In the event of failures due to a misbehaving OCP API or oc binary, it is
    recommended to fallback to the control_persist transport by manually
    setting the --transport option.
    �oczsos-collect-tmpcKstd|j|ffi|��S)z\Format and run a command with `oc` in the project defined for our
        execution
        zoc -n %s %s)r�project)�self�cmd�kwargs�r�=/usr/lib/python3/dist-packages/sos/collector/transports/oc.py�run_oc1s
��zOCTransport.run_occCs|�d|j�}|ddkS)Nz.wait --timeout=0s --for=condition=ready pod/%s�statusr�r�pod_name)r	�uprrr
�	connected:s�zOCTransport.connectedcCs�ddd|j�d�d|jd�ddd	d
d�d�d
dd
d�d�ddd
d�d�dddd�d�gd|jjs4dn|jjdgddd�giddd�d
dd�ddd�ddd�gddd�dddd�
g|jjr`dndd |jdddd!�d"�S)#z�Based on our template for the debug container, add the node-specific
        items so that we can deploy one of these on each node we're collecting
        from
        �Pod�v1z%s-sos-collector�.r)�name�	namespacezsystem-cluster-critical�host�/�	Directory)�path�type)r�hostPath�runz/run�varlogz/var/logz
machine-idz/etc/machine-id�Filezsos-collector-tmpz&registry.redhat.io/rhel8/support-toolsz	/bin/bash�HOSTz/host)r�value)r�	mountPathT)�
privileged�	runAsUser)
r�image�command�env�	resources�volumeMounts�securityContext�stdin�	stdinOnce�tty�Always�IfNotPresent�Never)�volumes�
containers�imagePullPolicy�
restartPolicy�nodeName�hostNetwork�hostPID�hostIPC)�kind�
apiVersion�metadata�priorityClassName�spec)�address�splitr�optsr'�force_pull_image�r	rrr
�get_node_pod_configAs����������� ������������+��zOCTransport.get_node_pod_configc
Cs`td�sdS|��}|dd|_tj|jd�\}|_t|d��}t�	||�Wd�n1s1wY|�
d|j�td|j�}|d	d
ksTd|j|dvrd|�d
�|�
d|d�dS|�
d|j�z|j
d|jdd�}|d	d
ks�|�d�WdSWdSty�|�d�YdSty�}z|�d|�WYd}~dSd}~ww)NrFr=r)�dir�wz%Starting sos collector container '%s'zoc create -f %srrzpod/%s created�outputz Unable to deploy sos collect podzDebug pod deployment failed: %szDPod '%s' successfully deployed, waiting for pod to enter ready statez/wait --for=condition=Ready pod/%s --timeout=30s�()�timeoutz"Pod not available after 30 secondsz'Timeout while polling for pod readinessz+Error while waiting for pod to be ready: %sT)rrEr�tempfile�mkstemp�tmpdir�pod_tmp_conf�open�json�dump�	log_debugr�	log_errorrr�	Exception)r	�password�podconf�fd�cfile�outr�errrrr
�_connect�sT���
���
��
���zOCTransport._connectcs,|�d�rd|j|j|fStt|��|�S)Nrz7oc -n %s exec --request-timeout=0 %s -- chroot /host %s)�
startswithrr�superr�_format_cmd_for_exec)r	r
��	__class__rr
r^�s

�z OCTransport._format_cmd_for_exec�FNcs$|r|d7}tt|��||||d�S)N�
F)r]r�run_command)r	r
rJ�	need_rootr)�get_ptyr_rr
rc�s
�zOCTransport.run_commandcCsRtj�|j�r
t�|j�|�d|j�}d|dvr'|�d|j|f�dSdS)Nz
delete pod %s�deletedrHz%Calling delete on pod '%s' failed: %sFT)�osr�existsrN�unlinkrrrR)r	�removedrrr
�_disconnect�s�zOCTransport._disconnectcCsd|j|jfS)Nz4oc -n %s exec --request-timeout=0 %s -- /bin/bash -c)rrrDrrr
�remote_exec�s
�zOCTransport.remote_execcCsF|jddd�}d|dvrdnd}|�d||j||f�}|d	d
kS)Nzcp --retriesT)�stderrzunknown flagrH�z--retries=5zcp %s %s:%s %srrr)r	�fname�dest�result�flagsr
rrr
�_retrieve_file�s�zOCTransport._retrieve_file)raFNF)�__name__�
__module__�__qualname__�__doc__rrr�propertyrrEr[r^rcrkrlrs�
__classcell__rrr_r
rs"	
`+�

r)
rPrKrg�sos.collector.transportsr�
sos.utilitiesrrrrrrrr
�<module>s


Spamworldpro Mini