Sindbad~EG File Manager
3
�f� � @ 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 @ sV e Zd ZdZdZdZdZdZdZdZ dZ
dZdZdd � Z
ddd�Zd
d� Zdd� Zd
S )�
OVNCentralz
OVN NorthdZovn_central�network�virt�ovn-dbs-bundle.*�ovn_cluster_north_db_server� c C s� t jj||�}| jr�| jd| | jd�}|d dks@d|d krR| jd| j � n:tj|�}x.|d jd�D ]}|j |�rlt jj||�S qlW |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.6/ovn_central.py�
_find_sock# s
zOVNCentral._find_sockNc sP | j rzd| }| j|dd| j d�}|d dkrB| jd| j � dS ytj|d �}W n" tk
rv | jd | � dS X n�yZ| j|�}t|d
dd��8}ytj|�}W n" tk
r� | jd | � dS X W dQ R X W n4 t k
�r } z| jd
||f � dS d}~X nX y� fdd�t
j|d �D �S tk
�rJ | jd| � Y nX dS )z Get tables from schema zcat %sNT)�timeout�
foregroundr r
r z3Could not retrieve DB schema file from container %sr zCannot parse JSON file %s�rzUTF-8)�encodingz$Could not open DB schema file %s: %sc s g | ]}|� kr|�qS r r )�.0�table)�skipr r �
<listcomp>R s z5OVNCentral.get_tables_from_schema.<locals>.<listcomp>�tablesz DB schema %s has no 'tables' key)
r r r �json�loads� Exception� path_join�open�load�IOError�dict�keys�AttributeError) r r r'