Файловый менеджер - Редактировать - /usr/lib/python3.9/site-packages/sos/upload/targets/__pycache__/redhat.cpython-39.pyc
�азад
a ([QhX) � @ s� d dl Z d dlZd dlmZ d dlmZmZ d dlmZ d dl m Z d dlmZ zd dlZdZW n eyv dZY n0 G d d � d e�ZdS )� N)�UploadTarget)� convert_bytes�TIMEOUT_DEFAULT)�DeviceAuthorizationClass)� RHELPolicy)�_sosTFc s� e Zd ZdZdZdZdZd'� fdd� ZdZd Z e Z d ZdZdZ dd � Z� fdd�Zdd� Zdd� Zdd� Zdd� Zd(dd�Zdd� Zdd� Zdd � Zd)� fd!d"� Zd#d$� Z� fd%d&�Z� ZS )*�RHELUploadTargetzVhttps://sso.redhat.com/auth/realms/redhat-external/protocol/openid-connect/auth/devicezPhttps://sso.redhat.com/auth/realms/redhat-external/protocol/openid-connect/tokenzRed Hat Upload TargetZredhatNc s t � j|||d� d S )N)�parser�args�cmdline)�super�__init__)�selfr r r �� __class__� �=/usr/lib/python3.9/site-packages/sos/upload/targets/redhat.pyr ! s zRHELUploadTarget.__init__zhttps://api.access.redhat.comzsftp://sftp.access.redhat.com�posti @c C s t | jd t�S )z.Return true if we are running in a RHEL system�policy)� isinstance�commonsr �r r r r �check_distribution- s z#RHELUploadTarget.check_distributionc s t � �|� | jd j| _d S )N�cmdlineopts)r �pre_workr �upload_directory)r Zhook_commonsr r r r 1 s zRHELUploadTarget.pre_workc C s@ | j d jr| j�td�� | j d js<| j| _| j�d� d S )Nr zVThe option --upload-user has been deprecated in favour of device authorization in RHELz&No case id provided, uploading to SFTP)r Zupload_user�ui_log�info�_�case_id�RH_SFTP_HOST� upload_urlr r r r �prompt_for_upload_user7 s �z'RHELUploadTarget.prompt_for_upload_userc C s | j d jr| j�td�� d S )Nr zVThe option --upload-pass has been deprecated in favour of device authorization in RHEL)r Zupload_passr r r r r r r �prompt_for_upload_passwordB s �z+RHELUploadTarget.prompt_for_upload_passwordc C s� d| j d j� d�}zn| jr$| jW S | j d jr>| j d jW S | j d jdkrV| jW S | j d js�| j d �| j d �s�| jW S W n6 ty� } z| j�d|� �� W Y d }~n d }~0 0 | j � |� �S )Nz/support/v1/cases/r z/attachments�sftpr z=There was a problem while setting the remote upload target: ) r r r! Zupload_protocolr Zprompt_for_case_id� Exceptionr r �RH_API_HOST)r Zrh_case_api�er r r �get_upload_urlJ s. � ����zRHELUploadTarget.get_upload_urlc C s d| j � �}d|iS )NzBearer Z Authorization)� _device_token)r Zstr_authr r r �_get_upload_https_auth` s z'RHELUploadTarget._get_upload_https_authTc C sh d|j �d�d || �� fi}t| j| j�}|�� | _| j� d| � � � �� tj| � � || �� |td�S )z�If upload_https() needs to use requests.post(), use this method. Policies should override this method instead of the base upload_https() :param archive: The open archive file object �file�/����/Device authorized correctly. Uploading file to )�files�headers�verify�timeout)�name�split�_get_upload_headersr �client_identifier_url�token_endpoint�get_access_tokenr) r r �get_upload_url_string�requestsr r( r* r )r �archiver1 r/ �RHELAuthr r r �_upload_https_postd s ��� ��z#RHELUploadTarget._upload_https_postc C s | � � �| j�rddd�S i S )NZfalsezno-cache)Z isPrivatez cache-control)r( � startswithr&