File: //usr/lib/python3/dist-packages/sos/report/plugins/__pycache__/ovn_central.cpython-38.pyc
U
i��d� � @ 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�||�}| jr�| jd| | jd�}|d dks@d|d krR| �d| j � n:t�|�}|d �d�D ] }|� |�rjt j�||� S qj|S )Nzls %s)� container�statusr �
�outputz?Could not retrieve ovn_controller socket path from container %s)
�os�path�join�_container_name�exec_cmd�
_log_error�re�compile�split�match)�selfr Z
regex_nameZ_sfile�res�pattern�filename� r �@/usr/lib/python3/dist-packages/sos/report/plugins/ovn_central.py�
_find_sock s ��
zOVNCentral._find_sockc
sb | j r|d| }| j|d d| j d�}|d dkrB| �d| j � d S zt�|d �}W n$ tk
rx | �d| � Y d S X n�z`t| �|�d ��F}zt�|�}W n0 tk
r� | �d| � Y W 5 Q R � W d S X W 5 Q R X W n< t k
�r } z| �d
||f � W Y �d S d }~X Y nX z� fdd�t
�|d
�D �W S tk
�r\ | �d| � Y nX 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 | ]}|� kr|�qS r r )�.0�table��skipr r �
<listcomp>J 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"