File: //usr/lib/python3.9/site-packages/sos/report/plugins/__pycache__/ovn_central.cpython-39.pyc
a
^��c" � @ sj d dl mZmZmZmZ d dlZd dlZd dlZG dd� de�ZG dd� dee�Z G dd� deee�Z
dS ) � )�Plugin�RedHatPlugin�DebianPlugin�UbuntuPluginNc @ s@ e Zd ZdZdZdZdZdd� Zg fdd�Zd d
� Z dd� Z
d
S )�
OVNCentralz
OVN NorthdZovn_central)ZnetworkZvirt)zovn-dbs-bundle.*Zovn_cluster_north_db_serverc C s� t j�| j| j�}| jr�| jd| j | jd�}|d dksFd|d vrX| �d| j � n>t� | j�}|d �
d�D ]"}|�|�rrt j�| j|� S qr|S )Nzls %s)� container�statusr �
�outputz?Could not retrieve ovn_controller socket path from container %s)�os�path�join�ovn_controller_sock_path�ovn_controller_sock_regex�_container_name�exec_cmd�
_log_error�re�compile�split�match)�selfZ_sfile�res�pattern�filename� r �B/usr/lib/python3.9/site-packages/sos/report/plugins/ovn_central.py�_find_ovn_controller_sock s(
����
�
z$OVNCentral._find_ovn_controller_sockc
sp | j rzd| }| j|d d| j d�}|d dkrB| �d| j � d S zt�|d �}W n" tyv | �d| � Y d S 0 n�ztt| �|�d ��P}zt�|�}W n0 ty� | �d| � Y W d � W d S 0 W d � n1 s�0 Y W n: t �y( } z | �d
||f � W Y d }~d S d }~0 0 z� fdd�t
�|d
�D �W S t�yj | �d| � Y n0 d S )Nzcat %sT)�timeout�
foregroundr r r z3Could not retrieve DB schema file from container %sr
zCannot parse JSON file %s�rz$Could not open DB schema file %s: %sc s g | ]}|� vr|�qS r r )�.0�table��skipr r �
<listcomp>M s �z5OVNCentral.get_tables_from_schema.<locals>.<listcomp>�tablesz DB schema %s has no 'tables' key)
r r r �json�loads� Exception�open� path_join�load�IOError�dict�keys�AttributeError)r r r$ �cmdr Zdb�f�exr r# r �get_tables_from_schema1 sF
��
�8
��
z!OVNCentral.get_tables_from_schemac C s( |sd S |D ]}|� d||f � qd S )Nz
%s list %s)�append)r r&