Current File : //usr/lib/python3/dist-packages/sos/report/plugins/__pycache__/pulpcore.cpython-312.pyc
�

-�_gx��H�ddlmZddlmZddlmZmZmZGd�dee�Zy)�)�match)�quote)�Plugin�IndependentPlugin�	PluginOptc�n�eZdZdZdZdZdZeddd��gZd	Z	d
Z
dZdZdZ
d
ZdeiZd�Zd�Zdd�Zd�Zy)�PulpCorezPulp-3 aka pulpcore�pulpcore)zpulpcore-manager)�/etc/pulp/settings.py�	task-days�zdays of task history)�default�desc�	localhosti8�z/var/lib/pulp/assetsz/var/lib/pulp/media/upload�
PGPASSWORDc��d}dd�}	tddd��5}|j�jdd�jd	d
�jdd�j�D]�}|r|d
dk(r�|j	d�rd}�"d}|rt|dz|�r
||�|_|rt|dz|�r
||�|_|rt|dz|�r
||�|_|rt|dz|�r
||�|_	|rd|vrd}|j	d�r||d��|_
|j	d�s��||d��|_��	ddd�d|ji|_
y#1swY�xYw#t$rY�+wxYw)z Parse pulp settings Fc��|j|�dj�jd�}|jd�r|j	d�s"|jd�r|j	d�r|dd}|S)N��,�"�'���)�split�lstrip�rstrip�
startswith�endswith)�line�sep�vals   �=/usr/lib/python3/dist-packages/sos/report/plugins/pulpcore.py�separate_valuez6PulpCore.parse_settings_config.<locals>.separate_value'sh���*�*�S�/�!�$�+�+�-�4�4�S�9�C����s�#����S�(9����t�$����d�);��!�B�i���J�r�rzUTF-8)�encodingrz,
�{z{
�}z
}r�#�	DATABASESTz\s*['|\"]%s['|\"]\s*:\s*\S+�HOST�PORT�NAME�PASSWORDzSTATIC_ROOT = �=)r zCHUNKED_UPLOAD_DIR = Nr)�:)�open�read�replace�
splitlinesrr�dbhost�dbport�dbname�dbpasswd�
staticroot�	uploaddir�IOError�env)�self�databases_scoper#�filer�patterns      r"�parse_settings_configzPulpCore.parse_settings_config#s�����	� 	��-�s�W�E�
G�� �I�I�K� ���e�,�W�W�S�%�-@� ���e�,�Z�Z�\�G�D� �4��7�c�>� ����{�3�*.�� �=�G�&�5��6�1A�4�+H�&4�T�&:���&�5��6�1A�4�+H�&4�T�&:���&�5��6�1A�4�+H�&4�T�&:���&�5��:�1E�t�+L�(6�t�(<��
�&�3�$�;�*/�����'7�8�*8��3�*G������'>�?�)7��#�)F���5G�
G�F!�$�-�-�0���G
G�
G��:�	��	�s/�E5�D$E)�;E)�
E5�)E2�.E5�5	F�Fc��|j�|jddg�|jd�|jdd��dddd	�}|jd
|��|j|j
fD]}|j
|��|jd�}d
D]~}d|�d�}|j|j|�|j��}|ddk(r|dnd}d|�d|�d|�d�}|j|�}|j||j|����|jd�}|j|d|j��y)Nrz/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)r<r)�	core_task�core_taskgroup�core_groupprogressreport�core_progressreportz]COPY (SELECT STRING_AGG(column_name, ', ') FROM information_schema.columns WHERE table_name='zl'AND table_schema = 'public' AND column_name NOT IN ('args', 'kwargs', 'enc_args', 'enc_kwargs')) TO STDOUT;�statusr�output�*zselect z from z, where pulp_last_updated> NOW() - interval 'z! days' order by pulp_last_updated)r<rDa[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)rDr<)rA�
add_copy_spec�add_forbidden_path�add_cmd_outputr9r:�add_dir_listing�
get_option�exec_cmd�build_query_cmdr<)	r=�dynaconf_env�_dir�	task_days�table�_query�col_out�columns�_cmds	         r"�setupzPulpCore.setupVs����"�"�$����#��
�	�
	
��� 8�9����L�-:�	�	<�"/�)@�2I�K��	
���O���>��_�_�d�n�n�5�	'�D�� � ��&�	'��O�O�K�0�	�I�
	L�E�F�FK�W�M$�$�F�
�m�m�D�$8�$8��$@�d�h�h�m�O�G�+2�8�+<��+A�g�h�'�s�G���y��u�g�6-�-6�K�8+�+�F��'�'��/�D�����$�(�(�U��K�
	L� �#�#�
�
��	
���D�3M� $���	�	*r$c�v�|rd|�d�}d}||j|j|jt|�fzS)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
        zCOPY (z6) TO STDOUT WITH (FORMAT 'csv', DELIMITER ',', HEADER)z2psql --no-password -h %s -p %s -U pulp -d %s -c %s)r5r6r7r)r=�query�csv�_dbcmds    r"rWzPulpCore.build_query_cmd�sE����U�G�$A�A�E�E������d�k�k�4�;�;��e��M�M�Mr$c�X�d}d}|jd||�|jd||�y)Nz_((?:SECRET_KEY|AUTH_LDAP_BIND_PASSWORD)(?:\<.+\>)?(\s*=)?|(password|PASSWORD)(\"|'|:)+)\s*(\S*)z\1 ********rrH)�do_path_regex_sub�do_cmd_output_sub)r=�key_pass_re�repls   r"�postproczPulpCore.postproc�s5��,�������6��T�J������T�Br$N)F)�__name__�
__module__�__qualname__�
short_desc�plugin_name�commands�filesr�option_listr5r6r7r8r9r:r<rAr`rWrj�r$r"r	r	sl��&�J��K�$�H�&�E��+�q�/E�F��K��F�
�F�
�F��H�'�J�,�I���
"�C�11�f4*�lN�Cr$r	N)	�rer�shlexr�sos.report.pluginsrrrr	rsr$r"�<module>rws&����C�C�VC�v�(�VCr$