# Path: vif_plug_ovs/ovsdb/api.py
# def get_instance(context, iface_name=None):
#     def has_table_column(self, table, column):
# class ImplAPI(metaclass=abc.ABCMeta):
# 
# Path: vif_plug_ovs/privsep.py



import collections.abc
import itertools
import uuid
from oslo_concurrency import processutils
from oslo_log import log as logging
from oslo_serialization import jsonutils
from oslo_utils import excutils
from oslo_utils import uuidutils
from ovsdbapp import api as ovsdb_api
from vif_plug_ovs.ovsdb import api
from vif_plug_ovs import privsep
LOG = logging.getLogger(__name__)


def _val_to_py(val):
    """Convert a json ovsdb return value to native python object"""
    if isinstance(val, collections.abc.Sequence) and len(val) == 2:
        if val[0] == "uuid":
            return uuid.UUID(val[1])
        elif val[0] == "set":
            return [_val_to_py(x) for x in val[1]]
        elif val[0] == "map":
            return {_val_to_py(x): _val_to_py(y) for x, y in val[1]}
    return val


def _py_to_val(pyval):
    """Convert python value to ovs-vsctl value argument"""
    if isinstance(pyval, bool):
        return 'true' if pyval is True else 'false'
    elif pyval == '':
        return '""'
    else:
        # NOTE(twilson) If a Command object, return its record_id as a value
        return getattr(pyval, "record_id", pyval)


def api_factory(context):
    return OvsdbVsctl(context)



# Path: vif_plug_ovs/ovsdb/api.py
# def get_instance(context, iface_name=None):
#     def has_table_column(self, table, column):
# class ImplAPI(metaclass=abc.ABCMeta):
# 
# Path: vif_plug_ovs/privsep.py



# Path: vif_plug_ovs/ovsdb/impl_vsctl.py
import collections.abc
import itertools
import uuid
from oslo_concurrency import processutils
from oslo_log import log as logging
from oslo_serialization import jsonutils
from oslo_utils import excutils
from oslo_utils import uuidutils
from ovsdbapp import api as ovsdb_api
from vif_plug_ovs.ovsdb import api
from vif_plug_ovs import privsep

LOG = logging.getLogger(__name__)


def _val_to_py(val):
    """Convert a json ovsdb return value to native python object"""
    if isinstance(val, collections.abc.Sequence) and len(val) == 2:
        if val[0] == "uuid":
            return uuid.UUID(val[1])
        elif val[0] == "set":
            return [_val_to_py(x) for x in val[1]]
        elif val[0] == "map":
            return {_val_to_py(x): _val_to_py(y) for x, y in val[1]}
    return val


def _py_to_val(pyval):
    """Convert python value to ovs-vsctl value argument"""
    if isinstance(pyval, bool):
        return 'true' if pyval is True else 'false'
    elif pyval == '':
        return '""'
    else:
        # NOTE(twilson) If a Command object, return its record_id as a value
        return getattr(pyval, "record_id", pyval)


def api_factory(context):
    return OvsdbVsctl(context)



@privsep.vif_plug.entrypoint