HEX
Server: Apache
System: Linux nc-ph-4101.simplemoneygoals.com 5.14.0-503.21.1.el9_5.x86_64 #1 SMP PREEMPT_DYNAMIC Sun Jan 12 09:45:05 EST 2025 x86_64
User: dailygoldindex (1004)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //lib/python3.9/site-packages/sos/upload/__pycache__/__init__.cpython-39.pyc
a

\��h�3�@s`ddlZddlZddlZddlZddlZddlmZddlmZ	ddlm
Z
Gdd�de�ZdS)�N)�SoSComponent)�_sos)�__version__cs�eZdZdZdZdddddddddddddddddd�Zd#�fd	d
�	Zedd��Zed
d��Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zedd��Zedd��Zedd��Zdd �Zd!d"�Z�ZS)$�	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�FN�autozhttps://s3.amazonaws.com)�upload_file�case_id�low_priorityZ
upload_url�upload_directoryZupload_userZupload_passZ
upload_methodZupload_no_ssl_verifyZupload_protocolZupload_s3_endpointZupload_s3_regionZupload_s3_bucketZupload_s3_access_keyZupload_s3_secret_keyZupload_s3_object_prefix�
upload_targetcs~|st��|||�d|_nN|d|_|d|_|d|_||_||_||_||_	t
�d�|_d|_||_
|��|_d|_dS)NT�options�policy�manifestZsos_uiF)�super�__init__�from_cmdline�optsrr�parser�cmdline�argsZ_upload_file�loggingZ	getLogger�ui_log�archive�load_upload_targets�upload_targetsr)�selfrrrZin_placeZhook_commonsr��	__class__��7/usr/lib/python3.9/site-packages/sos/upload/__init__.pyr5s



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�storer	zspecify case identifier)�action�destr#z--upload-urlz&Upload the archive to specified server)�defaultr#z
--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)rZputZpostz HTTP method to use for uploading)r'�choicesr#z--upload-protocol)r�https�ftp�sftpZs3z$Manually specify the upload protocolz--upload-no-ssl-verifyF�
store_truez'Disable SSL verification for upload url)r'r%r#z--upload-target�local)ZredhatZ	canonical�genericr-zmManually specify vendor-specific target for uploads. Supported options are:
redhat, canonical, generic, local)�usage�add_argument_group�add_argument)�clsrZ
upload_grprrr �add_parser_optionsMst��
���������������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.)Z	set_title�add_text)r2�sectionrrr �display_help�s
�zSoSUpload.display_helpc
Cs�d}|j�dt�d��|�|�}|j�|�d}|jjs�zt|�|j�d�WnLtyp|�dd�Yn0t	y�}z|�|d�WYd	}~n
d	}~00d	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
r�Exiting on user cancel��N)
r�inforZ_fmt_msgrZbatch�input�KeyboardInterrupt�_exit�	Exception)rZ
disclaimerZ	intro_msg�prompt�errr �intro�s
zSoSUpload.introcCs|j|j|jj|jjd�S)N)�cmdlineoptsrr	r)rrr	r)rrrr �get_commons�s
�zSoSUpload.get_commonscCs
||_dS)zMSet common host data for the Upload targets
            to reference
        N)�commons)rrErrr �set_commons�szSoSUpload.set_commonscCs�t|j���}|j��D]B}|�|�|��r|jj}|j�d|�d��||_	|�
�|_q|j	sz|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 targetsr.zUpload target set to N)
�listr�values�removeZcheck_distributionr�__name__r�debugr�nameZupload_namer;)rZchecksrZcnamerrr �determine_upload_target�s	

�z!SoSUpload.determine_upload_targetcCsXddl}i}|�|jjd�D]6}|d|j|j|jd�}|�|���|||�	�<q|S)zELoads all upload targets supported by the local installation
        rN�targetsr:)rrr)
Zsos.upload.targets�
_load_modulesZuploadrNrrrrFrDZ
get_target_id)r�sosZsupported_upload_tgtsrZtarget_classrrr r�s�zSoSUpload.load_upload_targetscCs2g}|jD]"}tj�|�r
|�|�||��q
|S)zHelper to import upload targets)�__path__�os�path�isdir�extend�_find_modules_in_path)r2�packageZsubmod�modulesrSrrr rO�s

zSoSUpload._load_modulescCsng}tj�|�rjtt�|��D]J}|�d�s.qd|vr8qtj�|�\}}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.�.)	rRrS�exists�sorted�listdir�endswith�splitextrU�_import_modules)r2rSZ
modulenamerXZpyfile�fname�_�modnamerrr rV�s
zSoSUpload._find_modules_in_pathcCs&t�|�}dd�t�|tj�D�}|S)z/Import and return all found classes in a modulecSs$g|]\}}|j�d�r||f�qS)zsos.upload.targets)�
__module__�
startswith)�.0rLr2rrr �
<listcomp>s�z-SoSUpload._import_modules.<locals>.<listcomp>)�	importlib�
import_module�inspectZ
getmembersZisclass)r2rc�modulerXrrr r`�s

�zSoSUpload._import_modulescCs(|��|_|jd}|jr$|j��dS)NrC)rDrEr
rZ_configure_low_priority)r�cmdline_optsrrr �pre_work
s

zSoSUpload.pre_workcCs��z�|��|jr6|��|jj|_|jj|jd�|_|jj	}|rX|dkrX|j
||_	n|��|j	s||j�
d�t�d�|j	�|���z�t�|j�jdk�rBtj�|j��r(z,|j	�|j�|j�td|j�d���WnFt�y$}z,|j�
td|����t�d�WYd}~n
d}~00n|j�
t|j�d	���n|j�
td|j�d
���WnFt�y�}z,|j�
td|j�d|�d
���WYd}~n
d}~00Wn t�y�|�dd�Yn0dS)N)rlr-z|No upload target set via command line options or autodetected.
Please specify one using the option --upload-target.
Exiting.r:rzFile z uploaded successfullyzUpload attempt failed: z is not a file.z
 is empty.zCannot upload z: � r8r9)rmrrBrrrrZprompt_for_case_idZcaseidrrrMr�error�sys�exitrDrR�stat�st_sizerS�isfileZupload_archiver;rbr?r=r>)rZcmdline_target�errrArrr �executesJ
��
��":zSoSUpload.execute)NNNFNN)rJrd�__qualname__�__doc__ZdescZarg_defaultsr�classmethodr3r6rBrDrFrMrrOrVr`rmrv�
__classcell__rrrr rsP��
4
	



r)rRrprrjrhZ
sos.componentrrPrrbrrrrrr �<module>s