# 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
    @mock.patch.object(ip_lib, "exists", return_value=False)
    @mock.patch.object(ip_lib, "add")
    def test_ensure_bridge_addbr_exception(self, mock_add, mock_dev_exists):
        mock_add.side_effect = ValueError()
        with testtools.ExpectedException(ValueError):
            linux_net.ensure_bridge("br0", None, filtering=False)

    @mock.patch.object(ip_lib, "add")
    @mock.patch.object(ip_lib, "set")
    @mock.patch.object(linux_net, "_arp_filtering")
    @mock.patch.object(linux_net, "_set_device_mtu")
    @mock.patch.object(linux_net, "_disable_ipv6")
    @mock.patch.object(linux_net, "_update_bridge_routes")
    @mock.patch.object(ip_lib, "exists")
    def test_ensure_bridge_priv_mtu_not_called(self, mock_dev_exists,
            mock_routes, mock_disable_ipv6, mock_set_mtu, mock_arp_filtering,
            mock_ip_set, mock_add):
        """This test validates that mtus are updated only if an interface
           is added to the bridge
        """
        mock_dev_exists.return_value = False
        linux_net._ensure_bridge_privileged("fake-bridge", None,
                                            None, False, mtu=1500)
        mock_set_mtu.assert_not_called()
        mock_ip_set.assert_called_once_with('fake-bridge', state='up')

    @mock.patch.object(ip_lib, "add")
    @mock.patch.object(ip_lib, "set")
    @mock.patch.object(linux_net, "_arp_filtering")
    @mock.patch.object(linux_net, "_set_device_mtu")

# 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

    @mock.patch.object(ip_lib, "exists", return_value=False)
    @mock.patch.object(ip_lib, "add")
    def test_ensure_bridge_addbr_exception(self, mock_add, mock_dev_exists):
        mock_add.side_effect = ValueError()
        with testtools.ExpectedException(ValueError):
            linux_net.ensure_bridge("br0", None, filtering=False)

    @mock.patch.object(ip_lib, "add")
    @mock.patch.object(ip_lib, "set")
    @mock.patch.object(linux_net, "_arp_filtering")
    @mock.patch.object(linux_net, "_set_device_mtu")
    @mock.patch.object(linux_net, "_disable_ipv6")
    @mock.patch.object(linux_net, "_update_bridge_routes")
    @mock.patch.object(ip_lib, "exists")
    def test_ensure_bridge_priv_mtu_not_called(self, mock_dev_exists,
            mock_routes, mock_disable_ipv6, mock_set_mtu, mock_arp_filtering,
            mock_ip_set, mock_add):
        """This test validates that mtus are updated only if an interface
           is added to the bridge
        """
        mock_dev_exists.return_value = False
        linux_net._ensure_bridge_privileged("fake-bridge", None,
                                            None, False, mtu=1500)
        mock_set_mtu.assert_not_called()
        mock_ip_set.assert_called_once_with('fake-bridge', state='up')

    @mock.patch.object(ip_lib, "add")
    @mock.patch.object(ip_lib, "set")
    @mock.patch.object(linux_net, "_arp_filtering")
    @mock.patch.object(linux_net, "_set_device_mtu")

    @mock.patch.object(linux_net, "_disable_ipv6")