+
    i3  c                   sh    ^ RI t ^ RIt^ RIt^ RIt^ RIt^ RIHt ^ RIHt	 ^ RIH
t
  ! R R]4      tR# )i    N)SoSComponent)_sos)__version__c                   s"  a a ] tR t^t oRtRt/ RRbRRbRRbRR	bR
R	bRR	bRR	bRRbRRbRRbRRbRR	bRR	bRR	bRR	bRR	bRR	btR'V 3R llt]R 4       t	]R 4       t
R tR tR tR tR  t]R! 4       t]R" 4       t]R# 4       tR$ tR% tR&tVtV ;t# )(	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_priorityFZ
upload_urlNupload_directoryZupload_userZupload_passZupload_methodautoZupload_no_ssl_verifyZupload_protocolZupload_s3_endpointzhttps://s3.amazonaws.comZupload_s3_regionZupload_s3_bucketZupload_s3_access_keyZupload_s3_secret_keyZupload_s3_object_prefixupload_targetc                sT  < V'       g   \         SV `  WV4       R V n        MjVR,          V n        VR,          V n        VR,          V n        Wn        W0n        W n        W`n	        \        P                  ! R4      V n        RV n        W`n        V P                  4       V n        RV n        R# )TZoptionspolicymanifestZsos_uiFN)Zsuper__init__from_cmdlineoptsr   r   parsercmdlineargs_upload_fileloggingZ	getLoggerui_logarchiveload_upload_targetsupload_targetsr
   )selfr   r   r   Zin_placeZhook_commonsr   	__class__s   &&&&&&&8/usr/lib/python3.14/site-packages/sos/upload/__init__.pyr   ZSoSUpload.__init__5   s    GV73 $D
 %Y/DI&x0DK(4DM K"LI '!++H5DK %D"L"668!    c                s   R Vn         VP                  RR4      pVP                  RRRR7       VP                  RRR	R
R7       VP                  RRRR7       VP                  RRRR7       VP                  RRRR7       VP                  RRRRR7       VP                  RRRR7       VP                  RRRR7       VP                  RRRR7       VP                  RRRR7       VP                  RRR R7       VP                  R!RR"R7       VP                  R#R$. R1OR%R&7       VP                  R'R$. R2OR(R&7       VP                  R)R*R+R,R-7       VP                  R.R/. R3OR0R&7       R# )4zsos upload FILE [options]zUpload Optionsz.These options control how upload manages filesr   ZFILEzThe file or archive to upload)Zmetavarhelpz	--case-idZstorer   zspecify case identifier)actionZdestr   z--upload-urlNz&Upload the archive to specified server)defaultr   z--upload-userzUsername to authenticate withz--upload-passzPassword to authenticate withz--upload-directoryr   z$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-keyzAccess key for the S3 bucketz--upload-s3-secret-keyzSecret key for the S3 bucketz--upload-s3-object-prefixzPrefix for the S3 object/keyz--upload-methodr	   z HTTP method to use for uploading)r   Zchoicesr   z--upload-protocolz$Manually specify the upload protocolz--upload-no-ssl-verifyFZ
store_truez'Disable SSL verification for upload url)r   r   r   z--upload-targetlocalzmManually specify vendor-specific target for uploads. Supported options are:
redhat, canonical, generic, local)r	   ZputZpost)r	   ZhttpsZftpZsftpZs3)ZredhatZ	canonicalgenericr    )ZusageZadd_argument_groupZadd_argument)clsr   Z
upload_grps   && r   add_parser_optionsZSoSUpload.add_parser_optionsM   s   2..<
 	v%D 	  	FG)%> 	  	@%M 	  	O%D 	  	F%D 	  	F 4W%7%K 	  	M 	 6%J 	  	L 4d%H 	  	J 4d%I 	  	K 8$%C 	  	E 8$%C 	  	E ;T%C 	  	E 16(?%G 	  	I 	 3V(N%K 	  	M 	 8%'3%N 	  	P 	 17)-
'7 	  
	9r   c                sJ    VP                  R 4       VP                  R4       R# )zSoS Upload Detailed HelpzThe upload command is designed to upload already existing sos reports, as well as other files like logs and vmcores to a distribution specific location.N)Z	set_titleZadd_text)r"   Zsection   &&r   display_helpZSoSUpload.display_help   s$    453	
r   c                s   RpV P                   P                  R\         R24       V P                  V4      pV P                   P                  V4       RpV P                  P
                  '       g*    \        V4       V P                   P                  R4       R# R#   \         d    T P                  R^4        R# \         d   pT P                  T^4        Rp?R# Rp?ii ; i)z]Print 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)z,
Press ENTER to continue, or CTRL-C to quit
r   Exiting on user cancelN)
r   infor   Z_fmt_msgr   ZbatchZinputKeyboardInterrupt_exit	Exception)r   Z
disclaimerZ	intro_msgZprompte   &    r   introZSoSUpload.intro   s    
 	1+a@AMM*-	#Ayy!f  $  % :

3S9 !

1a  !s$   1&B C";C"C"CC"c                s    R V P                   RV P                  RV P                   P                  RV P                   P                  /# )cmdlineoptsr   r   r   )r   r   r   r   )r   s   &r   get_commonsZSoSUpload.get_commons   s<    499dkktyy((		 : :	
 	
r   c                s    Wn         R# )z9Set common host data for the Upload targets
to reference
N)commons)r   r0   r$   r   set_commonsZSoSUpload.set_commons   s	     r   c                sb   \        V P                  P                  4       4      pV P                  P                  4        F|  pVP                  V4       VP	                  4       '       g   K,  VP
                  P                  pV P                  P                  RV R24       W n	        VP                  4       V n        K~  	  V P                  '       g8   V P                  R,          V n	        V P                  P                  4       V n        V P                  P                  RV P                   24       R# )zThis 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.
zInstallation matches z, checking for upload targetsr!   zUpload target set to N)Zlistr   ZvaluesZremoveZcheck_distributionr   __name__r   Zdebugr
   nameupload_namer'   )r   Zchecksr
   Zcname   &   r   determine_upload_targetZ!SoSUpload.determine_upload_target   s     d))0023!00779MMM-(//11%//88!!$9% A4 #4 5%2"#0#5#5#7  : !!!!%!4!4Y!?D#11668D+D,<,<+=>	@r   c                s.   ^ RI p/ pV P                  VP                  P                  R4       Fd  pV^,          ! V P                  V P
                  V P                  R7      pVP                  V P                  4       4       WBVP                  4       &   Kf  	  V# )zELoads all upload targets supported by the local installation
        Ntargets)r   r   r   )
Zsos.upload.targets_load_modulesZuploadr7   r   r   r   r1   r/   Zget_target_id)r   sosZsupported_upload_tgtsr
   Ztarget_classr,   r   r   ZSoSUpload.load_upload_targets   s     	" "!//

0B0BINM(+#';;!%$(LLL
 $$T%5%5%78BN,"<"<">? O %$r   c                s    . pVP                    FJ  p\        P                  P                  V4      '       g   K*  VP	                  V P                  WB4      4       KL  	  V# )zHelper to import upload targets)Z__path__ospathZisdirextend_find_modules_in_path)r"   ZpackageZsubmodmodulesr;   s   &&&  r   r8   ZSoSUpload._load_modules   sJ     $$Dww}}T""s88FG % r   c                sv   . p\         P                  P                  V4      '       d   \        \         P                  ! V4      4       Fn  pVP                  R4      '       g   K  RV9   d   K%  \         P                  P                  V4      w  rVRV RV 2pVP                  V P                  V4      4       Kp  	  V# )a%  Given 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.pyZ__zsos.upload.Z.)	r:   r;   ZexistsZsortedZlistdirZendswithZsplitextr<   _import_modules)r"   r;   Z
modulenamer>   ZpyfileZfname_modnames   &&&     r   r=   ZSoSUpload._find_modules_in_path   s     77>>$ D!12u--6>77++F3'
|1UG<s227;< 3 r   c                s    \         P                  ! V4      p\        P                  ! V\        P                  4       UU u. uF+  w  r0V P
                  P                  R4      '       g   K(  W03NK-  	  ppp V# u up pi )z/Import and return all found classes in a modulezsos.upload.targets)	importlibZimport_moduleinspectZ
getmembersZisclass
__module__Z
startswith)r"   rA   Zmoduler3   r>   s   &&   r   r?   ZSoSUpload._import_modules   sl     ((1 %//H
H	~~(()=> TKH 	 

 
s   %A5)A5c                s    V P                  4       V n        V P                  R ,          pVP                  '       d   V P                  P	                  4        R# R# )r.   N)r/   r0   r   r   Z_configure_low_priority)r   cmdline_optss   & r   pre_workZSoSUpload.pre_work
  sA    '')||M2$$$KK//1 %r   c           
     s8    V P                  4        V P                  '       dW   V P                  4        V P                  P                  V n        V P                  P                  V P                  R 7      V n        V P                  P                  pV'       d!   VR8w  d   V P                  V,          V n	        MV P                  4        V P                  '       g2   V P                  P                  R4       \        P                  ! ^4       V P                  P                  V P!                  4       4        \"        P$                  ! V P
                  4      P&                  ^ 8  d   \"        P(                  P+                  V P
                  4      '       d[    V P                  P-                  V P
                  4       V P                  P/                  \1        RV P
                   R24      4       R# V P                  P                  \1        V P
                   R24      4       R# V P                  P                  \1        RV P
                   R24      4       R#   \2         dI   pT P                  P                  \1        RT 24      4       \        P                  ! ^4        Rp?R# Rp?ii ; i  \2         dA   pT P                  P                  \1        R	T P
                   R
T R24      4        Rp?R# Rp?ii ; i  \4         d    T P7                  R^4        R# i ; i))rE   r    z|No upload target set via command line options or autodetected.
Please specify one using the option --upload-target.
Exiting.zFile z uploaded successfullyzUpload attempt failed: Nz is not a file.z
 is empty.zCannot upload z: Z r&   )rF   r   r-   r   r   r   r   Zprompt_for_case_idcaseidr
   r   r6   r   ZerrorsysZexitr/   r:   ZstatZst_sizer;   ZisfileZupload_archiver'   r@   r*   r(   r)   )r   Zcmdline_targetZerrr+   r5   r   executeZSoSUpload.execute  sG   +	6MMO   

#yy44"kk<<!% =  "YY44N.G";%)%8%8%H",,.%%% !! ''(8(8(:;L774<<(0014ww~~dll33( ..==dllK KK,, !E$,,7M"N O ))!t||nO,L*MNKK%%a%~Z(H&IJ  ) ( KK--a"9# ?/A BHHQKK(  L!!!nT\\N"QCq$I"JKKL  	6JJ/5	6s{   !K8 A3K8 AK8 AK8 5AJ* AI -1J*  2J* J'=J"J* "J''J* *K555K0*K8 0K55K8 8LL)r   r   r   rG   r   r0   r   r   r   r   r   r   r4   r
   r   )NNNFNN)r2   rD   Z__qualname__Z__firstlineno__Z__doc__ZdescZarg_defaultsr   Zclassmethodr#   r%   r-   r/   r1   r6   r   r8   r=   r?   rF   rI   Z__static_attributes__Z__classdictcell__Z__classcell__)r   Z__classdict__s   @@r   r   r      su     KDr2 	 	d	
 	D 	t 	t 	 	 	6 	8 	D 	D 	 	  	"4!" 	#L("0 29 29h 
 
!<
@0%    ,  2,6 ,6r   r   )r:   rH   r   rC   rB   Zsos.componentr    r9   r   r@   r   r   ) r   r   <module>rJ      s-    
 
    &  h6 h6r   