HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/sos/report/plugins/__pycache__/pulpcore.cpython-310.pyc
o

i��d>�@sBddlmZmZmZddlmZddlmZGdd�dee�ZdS)�)�Plugin�IndependentPlugin�	PluginOpt)�quote)�matchc@sNeZdZdZdZdZdZedddd�gZd	d
�Z	dd�Z
ddd�Zdd�ZdS)�PulpCorezPulp-3 aka pulpcore�pulpcore)zpulpcore-manager)�/etc/pulp/settings.py�	task-days�zdays of task history)�default�desccCs^d}d|_d|_d|_d|_d|_d|_d d	d
�}z�td����dd
��dd��dd��	�D]m}|r8|ddkr9q.|�
d�rAd}q.d}|rQt|d|�rQ||�|_|r_t|d|�r_||�|_|rmt|d|�rm||�|_|r{t|d|�r{||�|_|r�d|vr�d}|�
d�r�||dd�|_|�
d�r�||dd�|_q.Wn	ty�Ynwd|ji|_
dS)!NF�	localhosti8r�z/var/lib/pulp/assetsz/var/lib/pulp/media/upload�:cSsP|�|�d���d�}|�d�r|�d�s |�d�r&|�d�r&|dd�}|S)N��,�"�'���)�split�lstrip�rstrip�
startswith�endswith)�line�sep�val�r�=/usr/lib/python3/dist-packages/sos/report/plugins/pulpcore.py�separate_value&s��z6PulpCore.parse_settings_config.<locals>.separate_valuer	rz,
�{z{
�}z
}r�#�	DATABASESTz\s*['|\"]%s['|\"]\s*:\s*\S+�HOST�PORT�NAME�PASSWORDzSTATIC_ROOT = �=)rzCHUNKED_UPLOAD_DIR = �
PGPASSWORD)r)�dbhost�dbport�dbname�dbpasswd�
staticroot�	uploaddir�open�read�replace�
splitlinesrr�IOError�env)�self�databases_scoper r�patternrrr�parse_settings_configsN
	
�






���zPulpCore.parse_settings_configcCs�|��|�ddg�|�d�|jddd�dddd	�}|jd
|d�|j|jfD]	}|�d|�q*|�d
�}dD]}d||f}|�|�}|j||j|d�q;|�d�}|j|d|jd�dS)Nr	z/etc/pki/pulp/*z/etc/pki/pulp/**/*.keyz.curl -ks https://localhost/pulp/api/v3/status/�pulp_status)�suggest_filenamezen_US.UTF-8zpulpcore.app.settings)�LC_ALL�
PULP_SETTINGS�DJANGO_SETTINGS_MODULE�
dynaconf list)r6zls -l %sr
)�	core_task�core_taskgroup�core_groupprogressreport�core_progressreportz`select * from %s where pulp_last_updated > NOW() - interval '%s days' order by pulp_last_updated)r6r<a[SELECT table_name, pg_size_pretty(total_bytes) AS total, pg_size_pretty(index_bytes) AS INDEX , pg_size_pretty(toast_bytes) AS toast, pg_size_pretty(table_bytes) AS TABLE FROM ( SELECT *, total_bytes-index_bytes-COALESCE(toast_bytes,0) AS table_bytes FROM (SELECT c.oid,nspname AS table_schema, relname AS TABLE_NAME, c.reltuples AS row_estimate, pg_total_relation_size(c.oid) AS total_bytes, pg_indexes_size(c.oid) AS index_bytes, pg_total_relation_size(reltoastrelid) AS toast_bytes FROM pg_class c LEFT JOIN pg_namespace n ON n.oid = c.relnamespace WHERE relkind = 'r') a) a order by total_bytes DESC�pulpcore_db_tables_sizes)r<r6)	r:�
add_copy_spec�add_forbidden_path�add_cmd_outputr/r0�
get_option�build_query_cmdr6)r7�dynaconf_env�_dir�	task_days�table�_query�_cmdrrr�setupTs:�
��
�
�
�zPulpCore.setupFcCs*|rd|}d}||j|j|jt|�fS)aI
        Builds the command needed to invoke the pgsql query as the postgres
        user.
        The query requires significant quoting work to satisfy both the
        shell and postgres parsing requirements. Note that this will generate
        a large amount of quoting in sos logs referencing the command being run
        z>COPY (%s) TO STDOUT WITH (FORMAT 'csv', DELIMITER ',', HEADER)z2psql --no-password -h %s -p %s -U pulp -d %s -c %s)r+r,r-r)r7�query�csv�_dbcmdrrrrJ�s�zPulpCore.build_query_cmdcCs<|�ddd�|�ddd�|�ddd�|�ddd�dS)	Nr	z(SECRET_KEY\s*=\s*)(.*)z
\1********z(PASSWORD\S*\s*:\s*)(.*?)(,|\})z\1********\3r@z(SECRET_KEY<str>\s*)'(.*)'z(PASSWORD\S*\s*:\s*)(.*))�do_path_regex_sub�do_cmd_output_sub)r7rrr�postproc�s(����zPulpCore.postprocN)F)
�__name__�
__module__�__qualname__�
short_desc�plugin_name�commands�filesr�option_listr:rQrJrWrrrrrs�9
/rN)	�sos.report.pluginsrrr�pipesr�rerrrrrr�<module>s