# Path: vif_plug_ovs/constants.py
# PLUGIN_NAME = 'ovs'
# OVS_VHOSTUSER_INTERFACE_TYPE = 'dpdkvhostuser'
# OVS_VHOSTUSER_CLIENT_INTERFACE_TYPE = 'dpdkvhostuserclient'
# OVS_VHOSTUSER_PREFIX = 'vhu'
# OVS_DATAPATH_SYSTEM = 'system'
# OVS_DATAPATH_NETDEV = 'netdev'
# PLATFORM_LINUX = 'linux2'
# PLATFORM_WIN32 = 'win32'
# OVS_DPDK_INTERFACE_TYPE = 'dpdk'
# DEAD_VLAN = 4095
# 
# Path: vif_plug_ovs/linux_net.py
# LOG = logging.getLogger(__name__)
# VIRTFN_RE = re.compile(r"virtfn(\d+)")
# INT_RE = re.compile(r"^(\d+)$")
# VF_RE = re.compile(r"vf(\d+)", re.IGNORECASE)
# PF_RE = re.compile(r"pf(\d+)", re.IGNORECASE)
# PF_FUNC_RE = re.compile(r"\.(\d+)", 0)
# UPLINK_PORT_RE = re.compile(r"p(\d+)", re.IGNORECASE)
# _SRIOV_TOTALVFS = "sriov_totalvfs"
# NIC_NAME_LEN = 14
# def _update_device_mtu(dev, mtu):
# def delete_net_dev(dev):
# def create_veth_pair(dev1_name, dev2_name, mtu):
# def update_veth_pair(dev1_name, dev2_name, mtu):
# def _disable_ipv6(bridge):
# def _arp_filtering(bridge):
# def ensure_bridge(bridge):
# def delete_bridge(bridge, dev):
# def add_bridge_port(bridge, dev):
# def set_device_mtu(dev, mtu):
# def set_interface_state(interface_name, port_state):
# def _parse_vf_number(phys_port_name):
# def _parse_pf_number(phys_port_name):
# def get_function_by_ifname(ifname):
# def _get_pf_func(pf_ifname):
# def get_representor_port(pf_ifname, vf_num):
# def _get_sysfs_netdev_path(pci_addr, pf_interface):
# def _is_switchdev(netdev):
# def get_ifname_by_pci_address(pci_addr, pf_interface=False, switchdev=False):
# def get_vf_num_by_pci_address(pci_addr):
# def get_dpdk_representor_port_name(port_id):
# def get_pf_pci_from_vf(vf_pci):
# def _get_phys_port_name(ifname):
# def _get_phys_switch_id(ifname):
# 
# 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):


import sys
from oslo_log import log as logging
from vif_plug_ovs import constants
from vif_plug_ovs import linux_net
from vif_plug_ovs.ovsdb import api as ovsdb_api
        external_ids = {'iface-id': iface_id,
                        'iface-status': 'active',
                        'attached-mac': mac,
                        'vm-uuid': instance_id}
        col_values = [('external_ids', external_ids)] if set_ids else []
        if interface_type:
            col_values.append(('type', interface_type))
        if vhost_server_path:
            col_values.append(('options',
                               {'vhost-server-path': vhost_server_path}))
        if (interface_type == constants.OVS_DPDK_INTERFACE_TYPE and
                pf_pci and vf_num):
            devargs_string = "{PF_PCI},representor=[{VF_NUM}]".format(
                PF_PCI=pf_pci, VF_NUM=vf_num)
            col_values.append(('options',
                              {'dpdk-devargs': devargs_string}))
        with self.ovsdb.transaction() as txn:
            txn.add(self.ovsdb.add_port(bridge, dev))
            if tag:
                txn.add(self.ovsdb.db_set('Port', dev, ('tag', tag)))
            if col_values:
                txn.add(self.ovsdb.db_set('Interface', dev, *col_values))
        self.update_device_mtu(dev, mtu, interface_type=interface_type)

    def update_ovs_vif_port(self, dev, mtu=None, interface_type=None):
        self.update_device_mtu(dev, mtu, interface_type=interface_type)

    def delete_ovs_vif_port(self, bridge, dev, delete_netdev=True):
        self.ovsdb.del_port(dev, bridge=bridge, if_exists=True).execute()
        if delete_netdev:

# Path: vif_plug_ovs/constants.py
# PLUGIN_NAME = 'ovs'
# OVS_VHOSTUSER_INTERFACE_TYPE = 'dpdkvhostuser'
# OVS_VHOSTUSER_CLIENT_INTERFACE_TYPE = 'dpdkvhostuserclient'
# OVS_VHOSTUSER_PREFIX = 'vhu'
# OVS_DATAPATH_SYSTEM = 'system'
# OVS_DATAPATH_NETDEV = 'netdev'
# PLATFORM_LINUX = 'linux2'
# PLATFORM_WIN32 = 'win32'
# OVS_DPDK_INTERFACE_TYPE = 'dpdk'
# DEAD_VLAN = 4095
# 
# Path: vif_plug_ovs/linux_net.py
# LOG = logging.getLogger(__name__)
# VIRTFN_RE = re.compile(r"virtfn(\d+)")
# INT_RE = re.compile(r"^(\d+)$")
# VF_RE = re.compile(r"vf(\d+)", re.IGNORECASE)
# PF_RE = re.compile(r"pf(\d+)", re.IGNORECASE)
# PF_FUNC_RE = re.compile(r"\.(\d+)", 0)
# UPLINK_PORT_RE = re.compile(r"p(\d+)", re.IGNORECASE)
# _SRIOV_TOTALVFS = "sriov_totalvfs"
# NIC_NAME_LEN = 14
# def _update_device_mtu(dev, mtu):
# def delete_net_dev(dev):
# def create_veth_pair(dev1_name, dev2_name, mtu):
# def update_veth_pair(dev1_name, dev2_name, mtu):
# def _disable_ipv6(bridge):
# def _arp_filtering(bridge):
# def ensure_bridge(bridge):
# def delete_bridge(bridge, dev):
# def add_bridge_port(bridge, dev):
# def set_device_mtu(dev, mtu):
# def set_interface_state(interface_name, port_state):
# def _parse_vf_number(phys_port_name):
# def _parse_pf_number(phys_port_name):
# def get_function_by_ifname(ifname):
# def _get_pf_func(pf_ifname):
# def get_representor_port(pf_ifname, vf_num):
# def _get_sysfs_netdev_path(pci_addr, pf_interface):
# def _is_switchdev(netdev):
# def get_ifname_by_pci_address(pci_addr, pf_interface=False, switchdev=False):
# def get_vf_num_by_pci_address(pci_addr):
# def get_dpdk_representor_port_name(port_id):
# def get_pf_pci_from_vf(vf_pci):
# def _get_phys_port_name(ifname):
# def _get_phys_switch_id(ifname):
# 
# 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/ovsdb/ovsdb_lib.py
import sys
from oslo_log import log as logging
from vif_plug_ovs import constants
from vif_plug_ovs import linux_net
from vif_plug_ovs.ovsdb import api as ovsdb_api

        external_ids = {'iface-id': iface_id,
                        'iface-status': 'active',
                        'attached-mac': mac,
                        'vm-uuid': instance_id}
        col_values = [('external_ids', external_ids)] if set_ids else []
        if interface_type:
            col_values.append(('type', interface_type))
        if vhost_server_path:
            col_values.append(('options',
                               {'vhost-server-path': vhost_server_path}))
        if (interface_type == constants.OVS_DPDK_INTERFACE_TYPE and
                pf_pci and vf_num):
            devargs_string = "{PF_PCI},representor=[{VF_NUM}]".format(
                PF_PCI=pf_pci, VF_NUM=vf_num)
            col_values.append(('options',
                              {'dpdk-devargs': devargs_string}))
        with self.ovsdb.transaction() as txn:
            txn.add(self.ovsdb.add_port(bridge, dev))
            if tag:
                txn.add(self.ovsdb.db_set('Port', dev, ('tag', tag)))
            if col_values:
                txn.add(self.ovsdb.db_set('Interface', dev, *col_values))
        self.update_device_mtu(dev, mtu, interface_type=interface_type)

    def update_ovs_vif_port(self, dev, mtu=None, interface_type=None):
        self.update_device_mtu(dev, mtu, interface_type=interface_type)

    def delete_ovs_vif_port(self, bridge, dev, delete_netdev=True):
        self.ovsdb.del_port(dev, bridge=bridge, if_exists=True).execute()
        if delete_netdev:

            linux_net.delete_net_dev(dev)