| Current Path : /lib/python3/dist-packages/sos/report/plugins/__pycache__/ |
| Current File : //lib/python3/dist-packages/sos/report/plugins/__pycache__/ovn_central.cpython-38.pyc |
U
-�_g�% � @ sj d dl Z d dlZd dlZd dlmZmZmZmZ G dd� de�ZG dd� dee�Z G dd� deee�Z
dS ) � N)�Plugin�RedHatPlugin�DebianPlugin�UbuntuPluginc @ s\ e Zd ZdZdZdZdZdZdZdZ dZ
dZdZdZ
dd� Zg fdd �Zd
d� Zdd
� ZdS )�
OVNCentralz
OVN NorthdZovn_central)ZnetworkZvirt)zovn-dbs-bundle.*Zovn_cluster_north_db_server� c C s� | � ||�}| jr�| jd|� �| jd�}|d dks@d|d krT| �d| j� �� n8t�|�}|d �d�D ]}|�|�rl| � ||� S ql|S )Nzls )� container�statusr �
�outputz=Could not retrieve ovn_controller socket path from container )� path_join�container_name�exec_cmd�
_log_error�re�compile�split�match)�self�pathZ
regex_nameZ_sfile�res�pattern�filename� r �@/usr/lib/python3/dist-packages/sos/report/plugins/ovn_central.py�
_find_sock% s
�
zOVNCentral._find_sockc
sz | j r�d|� �}| j|dd| j d�}|d dkrF| �d| j � �� dS zt�|d �}W n& tk
r~ | �d |� �� Y dS X n�zj| �|�}t|d
dd��H}zt�|�}W n2 tk
r� | �d |� �� Y W 5 Q R � W dS X W 5 Q R X W n@ t k
�r, } z | �d
|� d|� �� W Y �dS d}~X Y nX z� fdd�t
�|d �D �W S tk
�rt | �d|� d�� Y nX dS )z Get tables from schema zcat NT)�timeout�
foregroundr r r z1Could not retrieve DB schema file from container r zCannot parse JSON file �rzUTF-8)�encodingzCould not open DB schema file z: c s g | ]}|� kr|�qS r r ��.0�table��skipr r �
<listcomp>S s �z5OVNCentral.get_tables_from_schema.<locals>.<listcomp>�tablesz
DB schema z has no 'tables' key)
r
r r �json�loads� Exceptionr �open�load�IOError�dict�keys�AttributeError) r r r$ �cmdr Z db_schema�fname�file�exr r# r �get_tables_from_schema6 sB
�
"��
z!OVNCentral.get_tables_from_schemac s |r� fdd�|D �S dS )z Collect OVN database output c s g | ]}� � d |� ��qS )z list r r ��ovn_cmdr r r% \ s z2OVNCentral.add_database_output.<locals>.<listcomp>Nr )r r&