%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/sos/collector/clusters/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/sos/collector/clusters/__pycache__/ovirt.cpython-312.pyc

�

i��d� ��j�ddlZddlmZddlmZdZGd�de�ZGd�de�ZGd	�d
e�Zy)�N)�quote)�Clusterz(/etc/pki/ovirt-engine/keys/engine_id_rsac�Z�eZdZdZdZdZdZgd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zy)�ovirta�
    This cluster profile is for the oVirt/RHV project which provides for a
    virtualization cluster built ontop of KVM.

    Nodes enumerated will be hypervisors within the envrionment, not virtual
    machines running on those hypervisors. By default, ALL hypervisors within
    the environment are returned. This may be influenced by the 'cluster' and
    'datacenter' cluster options, which will limit enumeration to hypervisors
    within the specific cluster and/or datacenter. The spm-only cluster option
    may also be used to only collect from hypervisors currently holding the
    SPM role.

    Optionally, to only collect an archive from manager and the postgresql
    database, use the no-hypervisors cluster option.

    By default, a second archive from the manager will be collected that is
    just the postgresql plugin configured in such a way that a dump of the
    manager's database that can be explored and restored to other systems will
    be collected.

    The ovirt profile focuses on the upstream, community ovirt project.

    The rhv profile is for Red Hat customers running RHV (formerly RHEV).

    The rhhi_virt profile is for Red Hat customers running RHV in a
    hyper-converged setup and enables gluster collections.
    zCommunity oVirt)zovirt-enginez3/usr/share/ovirt-engine/dbscripts/engine-psql.sh -c))�no-databaseFzDo not collect a database dump)�cluster�z'Only collect from hosts in this cluster)�
datacenterr	z*Only collect from hosts in this datacenter)�no-hypervisorsFzDo not collect from hypervisors)�spm-onlyFzOnly collect from SPM host(s)c�\�|j�dt|���}|j|d��S)z�
        Wrapper for running DB queries on the manager. Any scrubbing of the
        query should be done _before_ passing the query to this method.
        � T��	need_root)�db_execr�exec_primary_cmd)�self�query�cmds   �>/usr/lib/python3/dist-packages/sos/collector/clusters/ovirt.py�
_run_db_queryzovirt._run_db_query<s,��
���u�U�|�4���$�$�S�D�$�9�9�c�h��|sygd��t�fd�|D��r|jd|z�y|S)z�
        Manually sanitize SQL queries since we can't leave this up to the
        driver since we do not have an actual DB connection
        �%)��\�
�
��"�'c3�&�K�|]}|�v���
y�w)N�)�.0�x�
invalid_charss  �r�	<genexpr>z#ovirt._sql_scrub.<locals>.<genexpr>Ms�����/�a�q�M�!�/�s�zMWARNING: Cluster option '%s' contains invalid characters. Using '%%' instead.)�any�log_warn)r�valr&s  @r�
_sql_scrubzovirt._sql_scrubDsA���
��E�
��/�3�/�/��M�M�<�>A�B�
C���
rc�T�|jjr�t|jj|jj
|jjg�sG|jjt�r'|jt�|jd�yyyy)a
        Checks for the presence of the VDSM ssh keys the manager uses for
        communication with hypervisors.

        This only runs if we're locally on the RHV-M, *and* if no ssh-keys are
        called out on the command line, *and* no --password option is given.
        z]Found engine SSH key. User command line does not specify a key or password, using engine key.N)�primary�localr(�opts�ssh_key�password�password_per_node�file_exists�
ENGINE_KEY�add_default_ssh_key�	log_debug�rs r�_check_for_engine_keyszovirt._check_for_engine_keysTs����<�<�����	�	�)�)�4�9�9�+=�+=��	�	�3�3�5�6��<�<�+�+�J�7��,�,�Z�8��N�N�$2�3�8�6�rc��d|_|jd�s|j�|_|j	�|j�y)NFr)�pg_pass�
get_option�
parse_db_conf�conf�
format_db_cmdr8r7s r�setupzovirt.setupes=��������}�-��*�*�,�D�I������#�#�%rc�(�|j|jd��}|j|jd��}d|�d|�d�|_|jd�r|xjdz
c_|jd|jz�y)	Nrr
z_SELECT host_name from vds where cluster_id in (select cluster_id FROM cluster WHERE name like 'zG' and storage_pool_id in (SELECT id FROM storage_pool WHERE name like 'z'))rz AND spm_status = 2z%Query command for ovirt DB set to: %s)r+r;�dbqueryr6)rrr
s   rr>zovirt.format_db_cmdlsv���/�/�$�/�/�)�"<�=���_�_�T�_�_�\�%B�C�
�5<�Z�I����?�?�:�&�

�L�L�1�1�L����>����M�Nrc�&�|jd�rgS|j|j�}|ddk(rF|dj�dd}|D�cgc]$}|j	d�dj���&c}St
d|dz��cc}w)	Nr�statusr�output�����(z&database query failed, return code: %s)r;rrA�
splitlines�split�strip�	Exception)r�res�nodes�ns    r�	get_nodeszovirt.get_nodes{s����?�?�+�,��I�� � ����.���x�=�A����M�,�,�.�q��4�E�5:�;��A�G�G�C�L��O�)�)�+�;�;��D�!�(�m�,�-�
-��<s�)Bc�^�|jd�s|jr|j�Sy)NrF)r;r=�collect_databaser7s r�
run_extra_cmdzovirt.run_extra_cmd�s&�����}�-�$�)�)��(�(�*�*�rc�>�i}d}|jd|zd��}|ddk(rl|dj�}|D]R}	t|jd�d�}t|jd�d	j	d
d��}|||<�T|Sy#t
$rY�cwxYw)
Nz6/etc/ovirt-engine/engine.conf.d/10-setup-database.confzcat %sTrrCrrD�=�r r	F)rrH�strrI�replace�
IndexError)rr=�engconfrL�config�line�k�vs        rr<zovirt.parse_db_conf�s�����J���#�#�H�w�$6�$�#�G���x�=�A����]�-�-�/�F��
����D�J�J�s�O�A�.�/�A��D�J�J�s�O�A�.�6�6�s�B�?�@�A��D��G�	
��K���"����s�AB�	B�Bc��djd|jd|jd|jd|jd��}dj|jd	|�}|j|d
��}|dj�D]d}t	j|d
�s�|j�}|jjjd|jd�d�|cS|jd�y)Nzn-k {plugin}.dbname={db} -k {plugin}.dbhost={dbhost} -k {plugin}.dbport={dbport} -k {plugin}.username={dbuser} �
postgresql�ENGINE_DB_DATABASE�ENGINE_DB_HOST�ENGINE_DB_PORT�ENGINE_DB_USER)�plugin�db�dbhost�dbport�dbuserzLPGPASSWORD={} /usr/sbin/sosreport --name=postgresql --batch -o postgresql {}�ENGINE_DB_PASSWORDTrrDz*sosreport-*tar*�postgresql_dump�/rFzFailed to gather database dumpF)�formatr=rrH�fnmatchrJr-�manifest�	add_fieldrI�	log_error)r�sos_optr�db_sosr[�_pg_dumps      rrQzovirt.collect_database�s��4��V�<�#�y�y�)=�>�#'�9�9�-=�#>�#'�9�9�-=�#>�#'�9�9�-=�#>�	��	�*����	�	�"6�7��A�	��&�&�s�d�&�;���8�$�/�/�1�	 �D����t�%7�8��:�:�<�����%�%�/�/�0A�08���s�0C�B�0G�I���	 �	
���7�8�rN)�__name__�
__module__�__qualname__�__doc__�cluster_name�packagesr�option_listrr+r8r?r>rOrRr<rQr#rrrrsM���8%�L� �H�C�G��K�:�� 3�"&�
O�	-��
� rrc��eZdZdZdZdZd�Zy)�rhvzRed Hat Virtualization)�rhevm�rhvmc�p�|j|jjk(ry|jd�ryy)N�managerzovirt-node-ng-nodectl�rhvh�rhelh)�addressr-�is_installed)r�nodes  r�set_node_labelzrhv.set_node_label�s0���<�<�4�<�<�/�/�/�����4�5��rN)rtrurvrxry�
sos_presetr�r#rrr|r|�s��+�L� �H��J�rr|c�,�eZdZdZdZddiZdZd�Zd�Zy)	�	rhhi_virtz6Red Hat Hyperconverged Infrastructure - Virtualization)�glusterzgluster.dump�onr|c�\�|jjd�xr|j�S)Nr~)r-r��_check_for_rhhivr7s r�
check_enabledzrhhi_virt.check_enabled�s%�����)�)�&�1�M�d�6K�6K�6M�Nrc��|jd�}|ddk(r'|dj�dj�dk7Sy)Nz+SELECT count(server_id) FROM gluster_serverrCrrDrE�0F)rrHrJ)r�rets  rr�zrhhi_virt._check_for_rhhiv�sH��� � �!N�O���x�=�A���x�=�+�+�-�a�0�6�6�8�C�?�?�rN)	rtrurvrx�sos_plugins�sos_plugin_optionsr�r�r�r#rrr�r��s'��K�L��K�(�$�/���J�O�rr�)	rm�pipesr�sos.collector.clustersrr4rr|r�r#rr�<module>r�s<����*�
7�
�_�G�_�D�%����r

Zerion Mini Shell 1.0