Your IP : 216.73.216.172


Current Path : /lib/python3/dist-packages/sos/report/plugins/__pycache__/
Upload File :
Current File : //lib/python3/dist-packages/sos/report/plugins/__pycache__/pulpcore.cpython-38.pyc

U

-�_gx�@sBddlmZddlmZddlmZmZmZGdd�dee�ZdS)�)�match)�quote)�Plugin�IndependentPlugin�	PluginOptc@sneZdZdZdZdZdZedddd�gZd	Z	d
Z
dZdZdZ
d
ZdeiZdd�Zdd�Zddd�Zdd�ZdS)�PulpCorezPulp-3 aka pulpcoreZpulpcore)zpulpcore-manager)�/etc/pulp/settings.py�	task-days�zdays of task history)�defaultZdescZ	localhosti8�z/var/lib/pulp/assetsz/var/lib/pulp/media/upload�
PGPASSWORDc	CsZd}ddd�}�z"tdddd���}|���d	d
��dd��d
d���D]�}|rH|ddkr^qH|�d�rnd}qHd}|r�t|d|�r�||�|_|r�t|d|�r�||�|_|r�t|d|�r�||�|_|r�t|d|�r�||�|_	|r�d
|kr�d}|�d��r||dd�|_
|�d�rH||dd�|_qHW5QRXWntk
�rHYnXd|j	i|_
dS)z Parse pulp settings F�:cSsP|�|�d���d�}|�d�r,|�d�s@|�d�rL|�d�rL|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�rzUTF-8)�encodingrz,
�{z{
�}z
}r�#Z	DATABASESTz\s*['|\"]%s['|\"]\s*:\s*\S+ZHOSTZPORT�NAMEZPASSWORDzSTATIC_ROOT = �=)rzCHUNKED_UPLOAD_DIR = r
N)r)�open�read�replace�
splitlinesrr�dbhost�dbport�dbname�dbpasswd�
staticroot�	uploaddir�IOError�env)�selfZdatabases_scoper�filer�patternrrr�parse_settings_config#sJ
	���





zPulpCore.parse_settings_configc	Cs|��|�ddg�|�d�|jddd�dddd	�}|jd
|d�|j|jfD]}|�|�qT|�d�}d
D]r}d|�d�}|j|�	|�|j
d�}|ddkr�|dnd}d|�d|�d|�d�}|�	|�}|j||j
|d�qr|�	d�}|j|d|j
d�dS)Nrz/etc/pki/pulp/*z/etc/pki/pulp/**/*.keyz.curl -ks https://localhost/pulp/api/v3/status/Zpulp_status)�suggest_filenamezen_US.UTF-8zpulpcore.app.settings)�LC_ALLZ
PULP_SETTINGSZDJANGO_SETTINGS_MODULE�
dynaconf list)r1r	)Z	core_taskZcore_taskgroupZcore_groupprogressreportZcore_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;Zstatusr�output�*zselect z from z, where pulp_last_updated> NOW() - interval 'z! days' order by pulp_last_updated)r1r6a[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 DESCZpulpcore_db_tables_sizes)r6r1)r5Z
add_copy_specZadd_forbidden_pathZadd_cmd_outputr.r/Zadd_dir_listingZ
get_optionZexec_cmd�build_query_cmdr1)	r2Zdynaconf_envZ_dirZ	task_days�tableZ_queryZcol_out�columnsZ_cmdrrr�setupVs<�
��

��zPulpCore.setupFcCs.|rd|�d�}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
        zCOPY (z6) TO STDOUT WITH (FORMAT 'csv', DELIMITER ',', HEADER)z2psql --no-password -h %s -p %s -U pulp -d %s -c %s)r*r+r,r)r2ZqueryZcsvZ_dbcmdrrrr;�szPulpCore.build_query_cmdcCs(d}d}|�d||�|�d||�dS)Nz_((?:SECRET_KEY|AUTH_LDAP_BIND_PASSWORD)(?:\<.+\>)?(\s*=)?|(password|PASSWORD)(\"|'|:)+)\s*(\S*)z\1 ********rr8)Zdo_path_regex_subZdo_cmd_output_sub)r2Zkey_pass_re�replrrr�postproc�szPulpCore.postprocN)F)�__name__�
__module__�__qualname__Z
short_descZplugin_nameZcommands�filesrZoption_listr*r+r,r-r.r/r1r5r>r;r@rrrrrs"�36
rN)	�rerZshlexrZsos.report.pluginsrrrrrrrr�<module>s