HEX
Server: Apache
System: Linux insrv.serversdaddy.com 5.14.0-362.24.2.el9_3.x86_64 #1 SMP PREEMPT_DYNAMIC Sat Mar 30 14:11:54 EDT 2024 x86_64
User: jsaha (1066)
PHP: 8.3.6
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/alt/python37/lib/python3.7/site-packages/clcommon/lib/__pycache__/cmt_utils.cpython-37.pyc
B

�C�1�\�@s�ddlZddlZddlZddlZddlZddlmZmZmZde	d�dd�Z
ded�dd�Zd	d
�Z
dd�Zd
d�Zed�dd�ZdS)�N)�DEFAULT_JWT_ES_TOKEN_PATH�PUSHGATEWAY_ADDRESS�DISABLE_CMT_FILEF)�returncCspy@ttd�����}tjt�d�d|idd�}|��|��}Wn*tj	tj
jtt
tfk
rj|rf�iSX|S)a3
    Check that client is activated.
    Absence of JWT token means that client can have volume license like GoDaddy
    In this case we return False.
    Also we return False in case of some errors:
    - Errors during request of status from CM
    - Malformed JWT token
    - Incorrect answer from CM
    �rz/api/cm/get_backend_activationzX-Auth�)ZheadersZtimeout)�openr�read�strip�requests�getrZraise_for_status�jsonZJSONDecodeError�
exceptionsZRequestException�OSError�KeyError�IOError)�raise_exception�tokenZreqZactivation_info�r��/builddir/build/BUILDROOT/alt-python27-cllib-3.4.1-1.el9.cloudlinux.x86_64/opt/alt/python37/lib/python3.7/site-packages/clcommon/lib/cmt_utils.py�client_activation_datas$
rcCst|��dd�S)NZactivateF)rr)rrrr�is_client_enabled7srcCs�g}t�d�}|rptj|dd|gdddd�}tj|dddgdddd�}tj|dddgdddd�}|�|||g�t�d	�}|r�tj|d
|gdddd�}|�|�d�dd
�|D��S)z|
    Several checks for CM
     - ping cmt domain
     - ping something that MUST be accessible
     - traceroute to CM
    Zpingz-c�5FT)ZcheckZcapture_output�textz
google.comzcloudlinux.comZ
traceroutez-T�
c
ss4|],}d|j�d|j�d|j�d|j�d�	VqdS)z	Command: z

Retcode: z	
Stdout: z	
Stderr: rN)�args�
returncode�stdout�stderr)�.0Zprocess_datarrr�	<genexpr>Ysz,collect_cmt_request_debug.<locals>.<genexpr>)�shutilZwhich�
subprocess�run�extend�append�join)Z
cmt_domainZprocess_resultsZping_binaryZping_processZping_external_processZping_cloudlinuxZtraceroute_binaryZtraceroute_processrrr�collect_cmt_request_debug;s2



r'cCsFt|�}t�pd}|jd||t|�t|�|dd||jj|gid�dS)z/
    Log debug info for request exceptions
    zN/AzM%s error while requesting %s: %s 

DNS info: %s 
Debug info for request: 
 %sZfingerprintz
{{ default }})ZextraN)r'�get_resolv_conf_info�error�str�	__class__�__name__)Z	componentZloggerr)ZurlZ
debug_infoZresolv_conf_inforrr�log_request_error_debug_info^s

r-c	Cs0d}tj�|�sdSt|��
}|��SQRXdS)z#
    Get info from revolv.conf
    z/etc/resolv.confN)�os�path�existsrr	)Zresolv_conf�frrrr(js

r(cCstj�t�S)z*
    Check that CM is disabled localy
    )r.r/r0rrrrr�is_cmt_disabledusr2)F)F)r
r.rr"r!Zclcommon.lib.constsrrr�dictr�boolrr'r-r(r2rrrr�<module>s!#