← Back
Editing: gcp.cpython-312.opt-1.pyc
� ܓ�i6 � �\ � d dl Z d dlmZ d dlmZ d dlmZ d dlmZm Z m Z G d� dee � Zy)� N)�Any)�request)�URLError)�Plugin�IndependentPlugin� PluginOptc � � e Zd ZdZdZdZ eddd�� gZdZd Z d Z dZd� Zd � Z d� Zdefd�Zdedefd�Zd� Zededefd�� Zy)�GCPzGoogle Cloud Platform�gcp)�virt�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 � � t | j d�� 5 }d|j � v cddd� S # 1 sw Y yxY w# t $ r Y yw xY w)zo Checks if this plugin should be executed based on the presence of GCE entry in sysfs. zutf-8)�encodingzGoogle Compute EngineNF)�open�PRODUCT_PATH�read�OSError)�self�sys_files �;/usr/lib/python3.12/site-packages/sos/report/plugins/gcp.py� check_enabledzGCP.check_enabled$ sD � � ��d�'�'�'�:�h�.�(�-�-�/�A� ;�:�:��� �� �s( �A �5� A �>�A �A � A �A c �T � | j ddg�� | j ddg�� y)z� Collect the following info: * `gcloud auth list` output * Any google services output from journal zgcloud auth listr ��tagszgoogle*)�unitsr N)�add_cmd_output�add_journal)r s r �setupz GCP.setup/ s1 � � ���.�e�W��=� ���y��w��7� c �� � | j ddg�� 5 } | j � | _ | j � |j t j | j d�� � d d d � d}| j j j d� }|r| j |� y y # t $ r$}|j t |� � Y d }~�ld }~ww xY w# 1 sw Y �uxY w)Nz metadata.jsonr r � )�indentzAcurl -v --connect-timeout 10https://rhui.googlecloud.com/zone.txtzgoogle-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 �collectzGCP.collect<