HEX
Server: Apache
System: Linux pdx1-shared-a1-38 6.6.104-grsec-jammy+ #3 SMP Tue Sep 16 00:28:11 UTC 2025 x86_64
User: mmickelson (3396398)
PHP: 8.1.31
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/sos/upload/__pycache__/__init__.cpython-310.pyc
o

([Qhn3�@sXddlZddlZddlZddlZddlmZddlmZddlm	Z	Gdd�de�Z
dS)�N)�SoSComponent)�_sos)�__version__cseZdZdZdZidd�dd�dd�dd	�d
d	�dd	�dd	�d
d�dd�dd�dd�dd	�dd	�dd	�dd	�dd	�dd	�Z			d3�fdd�	Zedd��Zedd��Z	dd �Z
d!d"�Zd#d$�Zd%d&�Z
d'd(�Zed)d*��Zed+d,��Zed-d.��Zd/d0�Zd1d2�Z�ZS)4�	SoSUploadz�
    This class is designed to upload files to a distribution
    defined location. These files can be either sos reports,
    sos collections, or other kind of files like: vmcores,
    application cores, logs, etc.

    z9Upload a file to a user or policy defined remote location�upload_file��case_id�low_priorityF�
upload_urlN�upload_directory�upload_user�upload_pass�
upload_method�auto�upload_no_ssl_verify�upload_protocol�upload_s3_endpointzhttps://s3.amazonaws.com�upload_s3_region�upload_s3_bucket�upload_s3_access_key�upload_s3_secret_key�upload_s3_object_prefix�
upload_targetcs~|st��|||�d|_n'|d|_|d|_|d|_||_||_||_||_	t
�d�|_d|_||_
|��|_d|_dS)NT�options�policy�manifest�sos_uiF)�super�__init__�from_cmdline�optsrr�parser�cmdline�args�_upload_file�logging�	getLogger�ui_log�archive�load_upload_targets�upload_targetsr)�selfr!r#r"�in_place�hook_commonsr(��	__class__��5/usr/lib/python3/dist-packages/sos/upload/__init__.pyr4s




zSoSUpload.__init__cCs.d|_|�dd�}|jdddd�|jdd	d
dd�|jd
ddd�|jdddd�|jdddd�|jdd	ddd�|jdddd�|jdddd�|jdddd�|jdddd�|jddd d�|jd!dd"d�|jd#d$gd%�d&d'�|jd(d$gd)�d*d'�|jd+d,d-d.d/�|jd0d1gd2�d3d'�dS)4Nzsos upload FILE [options]zUpload Optionsz.These options control how upload manages filesr�FILEzThe file or archive to upload)�metavar�helpz	--case-id�storerzspecify case identifier)�action�destr4z--upload-urlz&Upload the archive to specified server)�defaultr4z
--upload-userzUsername to authenticate withz
--upload-passzPassword to authenticate withz--upload-directoryrz$Specify upload directory for archivez--upload-s3-endpointz#Endpoint to upload to for S3 bucketz--upload-s3-regionz!Region to upload to for S3 bucketz--upload-s3-bucketz"Name of the S3 bucket to upload toz--upload-s3-access-keyzAccess key for the S3 bucketz--upload-s3-secret-keyzSecret key for the S3 bucketz--upload-s3-object-prefixzPrefix for the S3 object/keyz--upload-methodr)r�put�postz HTTP method to use for uploading)r8�choicesr4z--upload-protocol)r�https�ftp�sftp�s3z$Manually specify the upload protocolz--upload-no-ssl-verifyF�
store_truez'Disable SSL verification for upload url)r8r6r4z--upload-target�local)�redhat�	canonical�genericrAzmManually specify vendor-specific target for uploads. Supported options are:
redhat, canonical, generic, local)�usage�add_argument_group�add_argument)�clsr!�
upload_grpr0r0r1�add_parser_optionsLst��
��������������
�zSoSUpload.add_parser_optionscCs|�d�|�d�dS)NzSoS Upload Detailed Helpz�The upload command is designed to upload already existing sos reports, as well as other files like logs and vmcores to a distribution specific location.)�	set_title�add_text)rH�sectionr0r0r1�display_help�s
�zSoSUpload.display_helpc
Cs�d}|j�dt�d��|�|�}|j�|�d}|jjsSz
t|�|j�d�Wd	Sty:|�dd�Yd	St	yR}z
|�|d�WYd	}~d	Sd	}~wwd	S)
zmPrint the intro message and prompts for a case ID if one is not
        provided on the command line
        a}This utility is used to upload files to a target location based either on a command line option or detecting the local distribution.

The archive to be uploaded may contain data considered sensitive and its content should be reviewed by the originating organization before being passed to any third party.

No configuration changes will be made to the system running this utility.
z
sos upload (version �)z,
Press ENTER to continue, or CTRL-C to quit
rzExiting on user cancel��N)
r'�infor�_fmt_msgr �batch�input�KeyboardInterrupt�_exit�	Exception)r+�
disclaimer�	intro_msg�prompt�er0r0r1�intro�s 
���zSoSUpload.introcCs|j|j|jj|jjd�S)N)�cmdlineoptsrrr)r rrr)r+r0r0r1�get_commons�s
�zSoSUpload.get_commonscCs
||_dS)zMSet common host data for the Upload targets
            to reference
        N)�commons)r+r`r0r0r1�set_commons�s
zSoSUpload.set_commonscCs�t|j���}|j��D]!}|�|�|��r-|jj}|j�d|�d��||_	|�
�|_q|j	s=|jd|_	|j	�
�|_|j�d|j���dS)aThis sets the upload target and loads that target's options.

        If no upload target is matched and no target is provided by
        the user, then we abort.

        If an upload target is provided in the command line,
        this will not run.
        zInstallation matches z, checking for upload targetsrDzUpload target set to N)
�listr*�values�remove�check_distributionr/�__name__r'�debugr�name�upload_namerR)r+�checksr�cnamer0r0r1�determine_upload_target�s	

�
�z!SoSUpload.determine_upload_targetcCsXddl}i}|�|jjd�D]}|d|j|j|jd�}|�|���|||�	�<q|S)zELoads all upload targets supported by the local installation
        rN�targetsrQ)r!r#r")
�sos.upload.targets�
_load_modules�uploadrmr!r#r"rar_�
get_target_id)r+�sos�supported_upload_tgtsr�target_classr0r0r1r)�s�zSoSUpload.load_upload_targetscCs2g}|jD]}tj�|�r|�|�||��q|S)zHelper to import upload targets)�__path__�os�path�isdir�extend�_find_modules_in_path)rH�package�submod�modulesrwr0r0r1ro�s
�zSoSUpload._load_modulescCsng}tj�|�r5tt�|��D]%}|�d�sqd|vrqtj�|�\}}d|�d|��}|�|�|��q|S)aUGiven a path and a module name, find everything that can be imported
        and then import it

            path - the filesystem path of the package
            modulename - the name of the module in the package

        E.G. a path of 'targets', and a modulename of 'redhat' equates to
        importing sos.upload.targets.redhat
        z.py�__zsos.upload.�.)	rvrw�exists�sorted�listdir�endswith�splitextry�_import_modules)rHrw�
modulenamer}�pyfile�fname�_�modnamer0r0r1rz�s
zSoSUpload._find_modules_in_pathc
Csz|�d�d}zt|t�t�|g�}Wnty!}z|�d}~wwt�|tj�}|��D]
}|ddvr:|�	|�q-|S)z/Import and return all found classes in a moduler�Nr)�DeviceAuthorizationClass�Upload�
RHELPolicy�UbuntuPolicy)
�split�
__import__�globals�locals�ImportError�inspect�
getmembers�isclass�copyrd)rHr��mod_short_name�moduler\r}�modr0r0r1r��s��
�zSoSUpload._import_modulescCs,|��|_|jd}|jr|j��dSdS)Nr^)r_r`r	r�_configure_low_priority)r+�cmdline_optsr0r0r1�pre_works


�zSoSUpload.pre_workcCs�|��|jr|��|jj|_|jj|jd�|_|jj	}|r*|dkr*|j
||_	n|��|j	s<|j�
d�t�d�|j	�|���zlt�|j�jdkr�tj�|j�r�z|j	�|j�|j�td|j�d���WWdSty�}z|j�
td|����t�d�WYd}~WdSd}~ww|j�
t|j�d	���WdS|j�
td|j�d
���WdSty�}z|j�
td|j�d|�d
���WYd}~dSd}~ww)N)r�rAz|No upload target set via command line options or autodetected.
Please specify one using the option --upload-target.
Exiting.rQrzFile z uploaded successfullyzUpload attempt failed: z is not a file.z
 is empty.zCannot upload z: � )r�rr]r rr(r�prompt_for_case_id�caseidrr*rlr'�error�sys�exitr_rv�stat�st_sizerw�isfile�upload_archiverRr�rX)r+�cmdline_target�errr\r0r0r1�executesH
��
��� .��zSoSUpload.execute)NNNFNN)rf�
__module__�__qualname__�__doc__�desc�arg_defaultsr�classmethodrJrNr]r_rarlr)rorzr�r�r��
__classcell__r0r0r.r1rst��������	�
���
������
4
	


r)rvr�r%r��
sos.componentrrrrr�rrr0r0r0r1�<module>s