+
    Û1j6  ã                   ó^   € ^ RI t ^ RIHt ^ RIHt ^ RIHt ^ RIHtH	t	H
t
  ! R R]]	4      tR# )é    N©ÚAny)Úrequest)ÚURLError)ÚPluginÚIndependentPluginÚ	PluginOptc                   ó¬   a € ] tR t^t o RtRtRt]! RRRR7      .tRt	Rt
R	tR
tR tR tR tV 3R lR ltV 3R lR ltR t]V 3R lR l4       tRtV tR
# )ÚGCPzGoogle Cloud PlatformÚgcpúkeep-piiFzyStop the plugin from removing PIIs like project name or organization ID from the metadata retrieved from Metadata server.)ÚdefaultÚdescz(/sys/devices/virtual/dmi/id/product_namezBhttp://metadata.google.internal/computeMetadata/v1/?recursive=truez[--REDACTED--]Nc                óÊ   €  \        V P                  RR7      ;_uu_ 4       pRVP                  4       9   uuRRR4       #   + '       g   i     R# ; i  \         d     R# i ; i)zW
Checks if this plugin should be executed based on the presence of
GCE entry in sysfs.
zutf-8)ÚencodingzGoogle Compute EngineNF)ÚopenÚPRODUCT_PATHÚreadÚOSError)ÚselfÚsys_files   & Ú8/usr/lib/python3/dist-packages/sos/report/plugins/gcp.pyÚcheck_enabledÚGCP.check_enabled$   sJ   € ð
	Ü�d×'Ñ'°'×:Õ:¸hØ.°(·-±-³/ÑA÷ ;×:×:Ó:ûäô 	Úð	ús+   ‚A ¡?´
A ¿A	Á
A ÁA ÁA"Á!A"c                óV   € V P                  RR.R7       V P                  RR.R7       R# )ze
Collect the following info:
 * `gcloud auth list` output
 * Any google services output from journal
zgcloud auth listr   ©Útagszgoogle*)Úunitsr   N)Úadd_cmd_outputÚadd_journal)r   s   &r   ÚsetupÚ	GCP.setup/   s1   € ð 	×ÑÐ.°e°WÐÔ=ð 	×Ñ˜y°¨wÐÖ7ó    c           	     ó  € V P                  R R.R7      ;_uu_ 4       p V P                  4       V n        V P                  4        VP	                  \
        P                  ! V P                  ^R7      4       RRR4       RpV P                  P                  P                  R4      pV'       d   V P                  V4       R# R#   \         d%   pTP	                  \        T4      4        Rp?LvRp?ii ; i  + '       g   i     L†; i)zmetadata.jsonr   r   )ÚindentNzAcurl -v --connect-timeout 10https://rhui.googlecloud.com/zone.txtzgoogle-rhui-client)Úcollection_fileÚget_metadataÚmetadataÚscrub_metadataÚwriteÚjsonÚdumpsÚRuntimeErrorÚstrÚpolicyÚpackage_managerÚall_pkgs_by_name_regexÚcollect_cmd_output)r   ÚmfileÚerrÚcurl_commandÚrhui_packages   &    r   ÚcollectÚGCP.collect<   sÊ   € à×!Ñ! /¸¸Ð!×@Ô@ÀEð&Ø $× 1Ñ 1Ó 3�”Ø×#Ñ#Ô%Ø—‘œDŸJšJ t§}¡}¸QÔ?Ô@÷	 Að@ˆð —{‘{×2Ñ2×IÑIØ!ó#ˆçØ×#Ñ# LÖ1ñ øô  ô &Ø—‘œC ›H×%Ñ%ûð&ú÷ A×@ús/   �C3ŸACÃC0ÃC+Ã&C3Ã+C0Ã0C3Ã3D	c                ó    <€ V ^8„  d   QhRS[ /# )é   Úreturn)Údict)ÚformatÚ__classdict__s   "€r   Ú__annotate__ÚGCP.__annotate__O   s   ø€ ÷ )ñ )™dñ )r#   c                ód   € V P                  V P                  4      p\        P                  ! V4      # )zY
Retrieves metadata from the Metadata Server and transforms it into a
dictionary object.
)Ú_query_addressÚMETADATA_QUERYr+   Úloads)r   Úresponse_bodys   & r   r'   ÚGCP.get_metadataO   s)   € ð
 ×+Ñ+¨D×,?Ñ,?Ó@ˆÜ�zŠz˜-Ó(Ð(r#   c                ó&   <€ V ^8„  d   QhRS[ RS[ /# )r:   Úurlr;   )r.   )r=   r>   s   "€r   r?   r@   W   s   ø€ ÷ ñ ¡#ð ©#ñ r#   c                óæ  €  \         P                  ! VRR/R7      p\         P                  ! V4      ;_uu_ 4       pVP                  ^È8w  d=   \	        RVP                   R2VP                  4       P                  4       ,           4      hVP                  4       P                  4       uuRRR4       #   + '       g   i     R# ; i  \         d"   p\	        R\        T4      ,           4      ThRp?ii ; i)zN
Query the given url address with headers required by Google Metadata
Server.
zMetadata-FlavorÚGoogle)Úheadersz2Failed to communicate with Metadata Server (code: z): Nz,Failed to communicate with Metadata Server: )	r   ÚRequestÚurlopenÚcoder-   r   Údecoder   r.   )r   rH   ÚreqÚresponser4   s   &&   r   rB   ÚGCP._query_addressW   sÄ   € ð
	Ü—/’/ #Ð0AÀ8Ð/LÔMˆCÜ—’ ×%Ô%¨Ø—=‘= CÔ'Ü&ð"Ø"*§-¡- °ð5à Ÿ™›×.Ñ.Ó0õ1ó2ð 2ð  —}‘}“×-Ñ-Ó/÷ &×%×%Ó%ûô ô 	ÜØ>ÄÀSÃÕIóKàðûð	ús5   ‚8C ºA+B0Â%
C Â0C	Â;C ÃC ÃC0ÃC+Ã+C0c                ó°  a aaaa€ S P                  R4      '       d   R# S P                  R,          R,          oS P                  R,          R,          o\        S4      oR VVVVV 3R lloS! S P                  4      S n        S P                  S P                  R,          R,          R	4       S P                  S P                  R,          R,          R
4       R# )zò
Remove all PII information from metadata, unless a keep-pii option
is specified.

Note: PII information collected by this plugin, like
project number, account names etc. might be required by Google
Cloud Support for faster issue resolution.
r   NÚprojectÚ	projectIdÚnumericProjectIdc                ó0   € V ^8„  d   QhR\         R\         /# )r:   Údatar;   r   )r=   s   "r   r?   Ú(GCP.scrub_metadata.<locals>.__annotate__z   s   € ÷ 	ñ 	œð 	¤ñ 	r#   c                 ó"  <€ \        V \        4      '       dH   R V 9   d   SP                  V R &   V P                  4        UUu/ uF  w  rS! V4      S! V4      bK  	  upp# \        V \        4      '       d   V  Uu. uF  pS! V4      NK  	  up# \        V \
        4      '       d7   V P                  SSP                  4      P                  SSP                  4      # \        V \        4      '       d   V S8X  d   SP                  # T # V # u uppi u upi )Útoken)Ú
isinstancer<   ÚREDACTEDÚitemsÚlistr.   ÚreplaceÚint)	rX   ÚkÚvÚvalueÚ
project_idÚproject_numberÚproject_number_intÚscrubr   s	   &   €€€€€r   rh   Ú!GCP.scrub_metadata.<locals>.scrubz   sÜ   ø€ Ü˜$¤×%Ò%Ø˜d”?ð %)§M¡M�D˜‘MØ7;·z±z´|ÔD±|©t¨q™˜a›¡%¨£(Ò*±|ÒDÐDÜ˜$¤×%Ò%Ù26Ó7±$¨™˜ež±$Ñ7Ð7Ü˜$¤×$Ò$Ø—|‘| N°D·M±MÓBß#™G J°·±Ó>ð?ä˜$¤×$Ò$Ø(,Ð0BÔ(B�t—}‘}ÐLÈÐLØˆKùó Eùâ7s   ÁDÁ9DÚ
attributeszssh-keysÚsshKeys)Ú
get_optionr(   r.   Úsafe_redact_key)r   re   rf   rg   rh   s   f@@@@r   r)   ÚGCP.scrub_metadataj   s¨   ü€ ð �?‰?˜:×&Ò&Ùà—]‘] 9Õ-¨kÕ:ˆ
Ø!Ÿ]™]¨9Õ5Ð6HÕIÐÜÐ/Ó0ˆ÷	ô 	ñ  ˜dŸm™mÓ,ˆŒà×Ñ˜TŸ]™]¨9Õ5°lÕCØ'ô	)à×Ñ˜TŸ]™]¨9Õ5°lÕCØ&ö	(r#   c                ó&   <€ V ^8„  d   QhRS[ RS[/# )r:   Údict_objÚkey)r<   r.   )r=   r>   s   "€r   r?   r@   ’   s   ø€ ÷ )ñ )¡tð )±#ñ )r#   c                ó2   € W!9   d   V P                   W&   R# R# )zRedact keys N)r]   )Úclsrp   rq   s   &&&r   rm   ÚGCP.safe_redact_key‘   s   € ð Œ?ØŸL™LˆH‹Mñ r#   )r(   )Úvirt)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú
short_descÚplugin_nameÚprofilesr	   Úoption_listr   rC   r]   r(   r   r!   r7   r'   rB   r)   Úclassmethodrm   Ú__static_attributes__Ú__classdictcell__)r>   s   @r   r   r      sƒ   ø‡ € à(€JØ€KØ€Hñ 	�* eð*ô	+ð€Kð >€Lð'€Nà€HØ€Hò	ò8ò2÷&)ð )÷ð ò&%(ðN ÷)ó ö)r#   r   )r+   Útypingr   Úurllibr   Úurllib.errorr   Úsos.report.pluginsr   r   r	   r   © r#   r   Ú<module>r†      s*   ðó Ý Ý Ý !ç CÑ CôE)ˆ&Ð#ö E)r#   