File: //usr/lib/python3.6/site-packages/sos/report/plugins/__pycache__/ovn_central.cpython-36.opt-1.pyc
3
-�_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 fd
d�Zdd
� Zdd� ZdS )�
OVNCentralz
OVN NorthdZovn_central�network�virt�ovn-dbs-bundle.*�ovn_cluster_north_db_server� c C s� | j ||�}| jr�| jd|� �| jd�}|d dks@d|d krT| jd| j� �� n8tj|�}x,|d jd�D ]}|j|�rn| j ||�S qnW |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.6/ovn_central.py�
_find_sock% s
zOVNCentral._find_sockc s` | j r�d|� �}| j|dd| j d�}|d dkrF| jd| j � �� dS ytj|d �}W n$ tk
r| | jd |� �� dS X n�y\| j|�}t|d
dd��:}ytj|�}W n$ tk
r� | jd |� �� dS X W dQ R X W n8 t k
�r } z| jd
|� d|� �� dS d}~X nX y� fdd�t
j|d �D �S tk
�rZ | jd|� 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&