# Path: os_vif/internal/ip/api.py
# LOG = logging.getLogger(__name__)
# 
# Path: vif_plug_linux_bridge/linux_net.py
# LOG = logging.getLogger(__name__)
# _IPTABLES_MANAGER = None
#     _IPTABLES_MANAGER = iptables_mgr
# def _set_device_mtu(dev, mtu):
# def _ip_bridge_cmd(action, params, device):
# def ensure_vlan_bridge(vlan_num, bridge, bridge_interface,
#                        net_attrs=None, mac_address=None,
#                        mtu=None):
# def _ensure_vlan_privileged(vlan_num, bridge_interface, mac_address, mtu):
# def ensure_bridge(bridge, interface, net_attrs=None, gateway=True,
#                   filtering=True, mtu=None):
# def _disable_ipv6(bridge):
# def _arp_filtering(bridge):
# def _update_bridge_routes(interface, bridge):
# def _ensure_bridge_privileged(bridge, interface, net_attrs, gateway,
#                               filtering=True, mtu=None):
# def _ensure_bridge_filtering(bridge, gateway):
# def configure(iptables_mgr):
# 
# Path: vif_plug_linux_bridge/privsep.py



from unittest import mock
from oslo_concurrency import lockutils
from oslo_concurrency import processutils
from oslo_config import cfg
from oslo_config import fixture as config_fixture
from oslo_log.fixture import logging_error as log_fixture
from os_vif.internal.ip.api import ip as ip_lib
from vif_plug_linux_bridge import linux_net
from vif_plug_linux_bridge import privsep
import fixtures
import testtools



CONF = cfg.CONF


class LinuxNetTest(testtools.TestCase):

    def setUp(self):
        super(LinuxNetTest, self).setUp()

        privsep.vif_plug.set_client_mode(False)
        lock_path = self.useFixture(fixtures.TempDir()).path
        self.fixture = self.useFixture(
            config_fixture.Config(lockutils.CONF))
        self.fixture.config(lock_path=lock_path,
                            group='oslo_concurrency')
        self.useFixture(log_fixture.get_logging_handle_error_fixture())

    @mock.patch.object(ip_lib, "set")
    def test_set_device_mtu(self, mock_ip_set):
        linux_net._set_device_mtu(dev='fakedev', mtu=1500)
        mock_ip_set.assert_called_once_with('fakedev', mtu=1500,
                                            check_exit_code=[0, 2, 254])

    @mock.patch.object(processutils, "execute")
    def test_set_device_invalid_mtu(self, mock_exec):
        linux_net._set_device_mtu(dev='fakedev', mtu=None)
        mock_exec.assert_not_called()


# Path: os_vif/internal/ip/api.py
# LOG = logging.getLogger(__name__)
# 
# Path: vif_plug_linux_bridge/linux_net.py
# LOG = logging.getLogger(__name__)
# _IPTABLES_MANAGER = None
#     _IPTABLES_MANAGER = iptables_mgr
# def _set_device_mtu(dev, mtu):
# def _ip_bridge_cmd(action, params, device):
# def ensure_vlan_bridge(vlan_num, bridge, bridge_interface,
#                        net_attrs=None, mac_address=None,
#                        mtu=None):
# def _ensure_vlan_privileged(vlan_num, bridge_interface, mac_address, mtu):
# def ensure_bridge(bridge, interface, net_attrs=None, gateway=True,
#                   filtering=True, mtu=None):
# def _disable_ipv6(bridge):
# def _arp_filtering(bridge):
# def _update_bridge_routes(interface, bridge):
# def _ensure_bridge_privileged(bridge, interface, net_attrs, gateway,
#                               filtering=True, mtu=None):
# def _ensure_bridge_filtering(bridge, gateway):
# def configure(iptables_mgr):
# 
# Path: vif_plug_linux_bridge/privsep.py



# Path: vif_plug_linux_bridge/tests/unit/test_linux_net.py
from unittest import mock
from oslo_concurrency import lockutils
from oslo_concurrency import processutils
from oslo_config import cfg
from oslo_config import fixture as config_fixture
from oslo_log.fixture import logging_error as log_fixture
from os_vif.internal.ip.api import ip as ip_lib
from vif_plug_linux_bridge import linux_net
from vif_plug_linux_bridge import privsep
import fixtures
import testtools




CONF = cfg.CONF


class LinuxNetTest(testtools.TestCase):

    def setUp(self):
        super(LinuxNetTest, self).setUp()

        privsep.vif_plug.set_client_mode(False)
        lock_path = self.useFixture(fixtures.TempDir()).path
        self.fixture = self.useFixture(
            config_fixture.Config(lockutils.CONF))
        self.fixture.config(lock_path=lock_path,
                            group='oslo_concurrency')
        self.useFixture(log_fixture.get_logging_handle_error_fixture())

    @mock.patch.object(ip_lib, "set")
    def test_set_device_mtu(self, mock_ip_set):
        linux_net._set_device_mtu(dev='fakedev', mtu=1500)
        mock_ip_set.assert_called_once_with('fakedev', mtu=1500,
                                            check_exit_code=[0, 2, 254])

    @mock.patch.object(processutils, "execute")
    def test_set_device_invalid_mtu(self, mock_exec):
        linux_net._set_device_mtu(dev='fakedev', mtu=None)
        mock_exec.assert_not_called()


    @mock.patch.object(ip_lib, "add")