# Path: os_vif/internal/ip/api.py
# LOG = logging.getLogger(__name__)
# 
# 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/exception.py
# class AgentError(osv_exception.ExceptionBase):
# class MissingPortProfile(osv_exception.ExceptionBase):
# class WrongPortProfile(osv_exception.ExceptionBase):
# class RepresentorNotFound(osv_exception.ExceptionBase):
# class PciDeviceNotFoundById(osv_exception.ExceptionBase):
# 
# Path: vif_plug_ovs/privsep.py



import glob
import os
import re
import sys
from os_vif.internal.ip.api import ip as ip_lib
from oslo_concurrency import processutils
from oslo_log import log as logging
from oslo_utils import excutils
from vif_plug_ovs import constants
from vif_plug_ovs import exception
from vif_plug_ovs import privsep
        set_device_mtu(dev, mtu)


@privsep.vif_plug.entrypoint
def delete_net_dev(dev):
    """Delete a network device only if it exists."""
    if ip_lib.exists(dev):
        try:
            ip_lib.delete(dev, check_exit_code=[0, 2, 254])
            LOG.debug("Net device removed: '%s'", dev)
        except processutils.ProcessExecutionError:
            with excutils.save_and_reraise_exception():
                LOG.error("Failed removing net device: '%s'", dev)


@privsep.vif_plug.entrypoint
def create_veth_pair(dev1_name, dev2_name, mtu):
    """Create a pair of veth devices with the specified names,
    deleting any previous devices with those names.
    """
    for dev in [dev1_name, dev2_name]:
        delete_net_dev(dev)

    ip_lib.add(dev1_name, 'veth', peer=dev2_name)
    for dev in [dev1_name, dev2_name]:
        ip_lib.set(dev, state='up')
        ip_lib.set(dev, promisc='on')
        _update_device_mtu(dev, mtu)



# Path: os_vif/internal/ip/api.py
# LOG = logging.getLogger(__name__)
# 
# 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/exception.py
# class AgentError(osv_exception.ExceptionBase):
# class MissingPortProfile(osv_exception.ExceptionBase):
# class WrongPortProfile(osv_exception.ExceptionBase):
# class RepresentorNotFound(osv_exception.ExceptionBase):
# class PciDeviceNotFoundById(osv_exception.ExceptionBase):
# 
# Path: vif_plug_ovs/privsep.py



# Path: vif_plug_ovs/linux_net.py
import glob
import os
import re
import sys
from os_vif.internal.ip.api import ip as ip_lib
from oslo_concurrency import processutils
from oslo_log import log as logging
from oslo_utils import excutils
from vif_plug_ovs import constants
from vif_plug_ovs import exception
from vif_plug_ovs import privsep

        set_device_mtu(dev, mtu)


@privsep.vif_plug.entrypoint
def delete_net_dev(dev):
    """Delete a network device only if it exists."""
    if ip_lib.exists(dev):
        try:
            ip_lib.delete(dev, check_exit_code=[0, 2, 254])
            LOG.debug("Net device removed: '%s'", dev)
        except processutils.ProcessExecutionError:
            with excutils.save_and_reraise_exception():
                LOG.error("Failed removing net device: '%s'", dev)


@privsep.vif_plug.entrypoint
def create_veth_pair(dev1_name, dev2_name, mtu):
    """Create a pair of veth devices with the specified names,
    deleting any previous devices with those names.
    """
    for dev in [dev1_name, dev2_name]:
        delete_net_dev(dev)

    ip_lib.add(dev1_name, 'veth', peer=dev2_name)
    for dev in [dev1_name, dev2_name]:
        ip_lib.set(dev, state='up')
        ip_lib.set(dev, promisc='on')
        _update_device_mtu(dev, mtu)



@privsep.vif_plug.entrypoint