/usr/lib/python3/dist-packages/sos/upload/targets/__pycache__
Edit: /usr/lib/python3/dist-packages/sos/upload/targets/__pycache__/redhat.cpython-310.pyc (7878B)
o
G%@i)) @ s d dl Z d dlZd dlmZ d dlmZmZ d dlmZ d dl m
Z
d dlmZ
zd dlZdZW n ey; dZY nw G d d
d
eZdS ) N)UploadTarget)
convert_bytesTIMEOUT_DEFAULT)DeviceAuthorizationClass)
RHELPolicy)_sosTFc s e Zd ZdZdZdZdZd' fdd ZdZd Z e Z
d
ZdZdZ
dd
Z fddZdd Zdd Zdd Zdd Zd(ddZdd 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 TargetredhatNc s t j|||d d S )N)parserargscmdline)super__init__)selfr
r r __class__ ;/usr/lib/python3/dist-packages/sos/upload/targets/redhat.pyr ! s zRHELUploadTarget.__init__zhttps://api.access.redhat.comzsftp://sftp.access.redhat.composti @c C s t | jd tS )z.Return true if we are running in a RHEL systempolicy)
isinstancecommonsr r r r r check_distribution- s z#RHELUploadTarget.check_distributionc s t | | jd j| _d S )Ncmdlineopts)r
pre_workr upload_directory)r hook_commonsr r r r 1 s zRHELUploadTarget.pre_workc C sD | j d jr| jtd | j d js | j| _| jd d S 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 upload_userui_loginfo_case_idRH_SFTP_HOST
upload_urlr r r r prompt_for_upload_user7 s z'RHELUploadTarget.prompt_for_upload_userc C s$ | j d jr| jtd d S d S )Nr zVThe option --upload-pass has been deprecated in favour of device authorization in RHEL)r upload_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}z,| jr| jW S | j d jr| j d jW S | j d jdkr+| jW S | j d js5| jW S W n tyQ } z| jd| W Y d }~nd }~ww | j | S )Nz/support/v1/cases/r z/attachmentssftpz=There was a problem while setting the remote upload target: ) r r" r$ upload_protocolr# Exceptionr r RH_API_HOST)r rh_case_apier r r get_upload_urlJ s,
zRHELUploadTarget.get_upload_urlc C s d| j }d|iS )NzBearer
Authorization)
_device_token)r str_authr r r _get_upload_https_auth^ s z'RHELUploadTarget._get_upload_https_authTc C sh d|j dd || fi}t| j| j}| | _| j d|
tj|
|| |tdS )zIf 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 )filesheadersverifytimeout)namesplit_get_upload_headersr client_identifier_urltoken_endpointget_access_tokenr0 r r get_upload_url_stringrequestsr r. r2 r )r archiver9 r7 RHELAuthr r r _upload_https_postb s
z#RHELUploadTarget._upload_https_postc C s | | jr
dddS i S )Nfalsezno-cache) isPrivatez
cache-control)r.
startswithr+ r r r r r= { s
z$RHELUploadTarget._get_upload_headersc C s4 | | jr
dS | | jrdS | | jS )NzRed Hat Customer PortalzRed Hat Secure FTP)r. rH r+ r# _get_obfuscated_upload_urlr$ r r r r rA s
z&RHELUploadTarget.get_upload_url_stringc C sL | j dd }| jd jr| jd j d| }| jr$tj| j|}|S )zThe RH SFTP server will only automatically connect file uploads to
cases if the filename _starts_ with the case number
r4 r5 r r! )upload_archive_namer<