%PDF- %PDF-
Direktori : /lib/python3/dist-packages/sos/report/plugins/__pycache__/ |
Current File : //lib/python3/dist-packages/sos/report/plugins/__pycache__/gcp.cpython-312.pyc |
� i��d� � �h � d dl Z d dlmZ d dlmZ d dlmZ d dlmZ d dl m Z mZmZ G d� de e� Z y) � N)�HTTPResponse)�Any)�request)�URLError)�Plugin�IndependentPlugin� PluginOptc � � e Zd ZdZdZdZ eddd�� gZdZd Z d Z dZd� Zd � Z d� Zdefd�Zededefd�� 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�descz3http://metadata.google.internal/computeMetadata/v1/zBhttp://metadata.google.internal/computeMetadata/v1/?recursive=truez[--REDACTED--]zDDMI: Google Google Compute Engine/Google Compute Engine, BIOS Googlec �X � | j d� }|d dk7 ry| j |d v S )z� Checks if this plugin should be executed at all. In this case, it will check the `dmesg` command output to see if the system is running on a Google Cloud Compute instance. �dmesg�statusr F�output)�exec_cmd� GOOGLE_DMI)�selfr s �8/usr/lib/python3/dist-packages/sos/report/plugins/gcp.py� check_enabledzGCP.check_enabled( s4 � � � � �g�&����?�a������%��/�1�1� c �T � | j ddg�� | j ddg�� y)z� Collect the following info: * Metadata from the Metadata server * `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.setup3 s1 � � ���.�e�W��=� ���y��w��7r c �b � | j ddg�� 5 } | j � | _ | j � |j t j | j d�� � d d d � y # t $ r$}|j t |� � Y d }~�1d }~ww xY w# 1 sw Y y xY w)Nz metadata.jsonr r � )�indent) �collection_file�get_metadata�metadata�scrub_metadata�write�json�dumps�RuntimeError�str)r �mfile�errs r �collectzGCP.collectA s� � � � !� !�/��� !� @� &�E� &� $� 1� 1� 3�� ��#�#�%����D�J�J�t�}�}�Q�?�@� &� &�� � &����C��H�%�%�� &�� &� &�s/ �B%�AA5�5 B"�>B�B%�B"�"B%�%B.�returnc � � | j | j � }|j � j � }t j |� S )zq Retrieves metadata from the Metadata Server and transforms it into a dictionary object. )�_query_address�METADATA_QUERY�read�decoder* �loads)r �response� response_bodys r r&