def test_ensure_bridge_exists(self, mock_dev_exists, mock_execute): linux_net.ensure_bridge("br0") self.assertEqual(mock_execute.mock_calls, []) self.assertEqual(mock_dev_exists.mock_calls, [ mock.call("br0") ])
def _plug_bridge(self, vif, instance_info): """Plug using hybrid strategy Create a per-VIF linux bridge, then link that bridge to the OVS integration bridge via a veth device, setting up the other end of the veth device just like a normal OVS port. Then boot the VIF on the linux bridge using standard libvirt mechanisms. """ v1_name, v2_name = self.get_veth_pair_names(vif) linux_net.ensure_bridge(vif.bridge_name) mtu = self._get_mtu(vif) if not linux_net.device_exists(v2_name): linux_net.create_veth_pair(v1_name, v2_name, mtu) linux_net.add_bridge_port(vif.bridge_name, v1_name) linux_net.ensure_ovs_bridge(vif.network.bridge, self._get_vif_datapath_type(vif), timeout=self.config.ovs_vsctl_timeout, ovsdb_connection=self.config.ovsdb_connection) self._create_vif_port(vif, v2_name, instance_info) else: linux_net.update_veth_pair(v1_name, v2_name, mtu) self._update_vif_port(vif, v2_name)
def test_ensure_bridge_exists(self, mock_dev_exists, mock_ip_set): linux_net.ensure_bridge("br0") mock_ip_set.assert_called_once_with('br0', state='up', check_exit_code=[0, 2, 254]) mock_dev_exists.assert_has_calls([mock.call("br0")])
def test_ensure_bridge_new_ipv6(self, mock_dev_exists, mock_execute, mock_path_exists): linux_net.ensure_bridge("br0") calls = [ mock.call('brctl', 'addbr', 'br0'), mock.call('brctl', 'setfd', 'br0', 0), mock.call('brctl', 'stp', 'br0', "off"), mock.call('brctl', 'setageing', 'br0', 0), mock.call('tee', '/sys/class/net/br0/bridge/multicast_snooping', check_exit_code=[0, 1], process_input='0'), mock.call('tee', '/proc/sys/net/ipv6/conf/br0/disable_ipv6', check_exit_code=[0, 1], process_input='1'), mock.call('ip', 'link', 'set', 'br0', 'up', check_exit_code=[0, 2, 254]) ] mock_execute.assert_has_calls(calls) mock_dev_exists.assert_has_calls([mock.call("br0")])
def test_ensure_bridge(self, mock_dev_exists, mock_add, mock_disable_ipv6, mock_set_state, mock_arp_filtering): linux_net.ensure_bridge("br0") mock_dev_exists.assert_called_once_with("br0") mock_add.assert_called_once_with("br0", "bridge", ageing=0) mock_disable_ipv6.assert_called_once_with("br0") mock_set_state.assert_called_once_with("br0", "up") mock_arp_filtering.assert_called_once_with("br0")
def test_ensure_bridge_exists(self, mock_dev_exists, mock_execute): linux_net.ensure_bridge("br0") self.assertEqual(mock_execute.mock_calls, [ mock.call('ip', 'link', 'set', 'br0', 'up'), ]) self.assertEqual(mock_dev_exists.mock_calls, [ mock.call("br0"), ])
def test_ensure_bridge_exists(self, mock_dev_exists, mock_execute): linux_net.ensure_bridge("br0") mock_execute.assert_has_calls([ mock.call('ip', 'link', 'set', 'br0', 'up', check_exit_code=[0, 2, 254]) ]) mock_dev_exists.assert_has_calls([mock.call("br0")])
def test_ensure_bridge_new_ipv4(self, mock_dev_exists, mock_execute, mock_path_exists): linux_net.ensure_bridge("br0") self.assertEqual(mock_execute.mock_calls, [ mock.call('brctl', 'addbr', 'br0'), mock.call('brctl', 'setfd', 'br0', 0), mock.call('brctl', 'stp', 'br0', "off"), mock.call('tee', '/sys/class/net/br0/bridge/multicast_snooping', check_exit_code=[0, 1], process_input='0'), ]) self.assertEqual(mock_dev_exists.mock_calls, [ mock.call("br0") ])
def test_ensure_bridge_new_ipv4(self, mock_dev_exists, mock_execute, mock_path_exists): linux_net.ensure_bridge("br0") self.assertEqual(mock_execute.mock_calls, [ mock.call('brctl', 'addbr', 'br0'), mock.call('brctl', 'setfd', 'br0', 0), mock.call('brctl', 'stp', 'br0', "off"), mock.call('tee', '/sys/class/net/br0/bridge/multicast_snooping', check_exit_code=[0, 1], process_input='0'), ]) self.assertEqual(mock_dev_exists.mock_calls, [mock.call("br0")])
def test_ensure_bridge_new_ipv4(self, mock_dev_exists, mock_execute, mock_path_exists, mock_ip_set): linux_net.ensure_bridge("br0") calls = [ mock.call('brctl', 'addbr', 'br0'), mock.call('brctl', 'setfd', 'br0', 0), mock.call('brctl', 'stp', 'br0', "off"), mock.call('brctl', 'setageing', 'br0', 0), mock.call('tee', '/sys/class/net/br0/bridge/multicast_snooping', check_exit_code=[0, 1], process_input='0'), ] mock_execute.assert_has_calls(calls) mock_dev_exists.assert_has_calls([mock.call("br0")]) mock_ip_set.assert_called_once_with('br0', state='up', check_exit_code=[0, 2, 254])
def _plug_bridge(self, vif, instance_info): """Plug using hybrid strategy Create a per-VIF linux bridge, then link that bridge to the OVS integration bridge via a veth device, setting up the other end of the veth device just like a normal OVS port. Then boot the VIF on the linux bridge using standard libvirt mechanisms. """ v1_name, v2_name = self.get_veth_pair_names(vif) linux_net.ensure_bridge(vif.bridge_name) if not linux_net.device_exists(v2_name): linux_net.create_veth_pair(v1_name, v2_name, self.config.network_device_mtu) linux_net.add_bridge_port(vif.bridge_name, v1_name) linux_net.ensure_ovs_bridge(vif.network.bridge, constants.OVS_DATAPATH_SYSTEM) self._create_vif_port(vif, v2_name, instance_info)
def _plug_bridge(self, vif, instance_info): """Plug using hybrid strategy Create a per-VIF linux bridge, then link that bridge to the OVS integration bridge via a veth device, setting up the other end of the veth device just like a normal OVS port. Then boot the VIF on the linux bridge using standard libvirt mechanisms. """ v1_name, v2_name = self.get_veth_pair_names(vif) linux_net.ensure_bridge(vif.bridge_name) if not linux_net.device_exists(v2_name): if vif.network and vif.network.mtu: mtu = vif.network.mtu else: mtu = self.config.network_device_mtu linux_net.create_veth_pair(v1_name, v2_name, mtu) linux_net.add_bridge_port(vif.bridge_name, v1_name) linux_net.ensure_ovs_bridge(vif.network.bridge, constants.OVS_DATAPATH_SYSTEM) self._create_vif_port(vif, v2_name, instance_info)
def test_ensure_bridge_exists(self, mock_dev_exists, mock_execute): linux_net.ensure_bridge("br0") self.assertEqual(mock_execute.mock_calls, []) self.assertEqual(mock_dev_exists.mock_calls, [mock.call("br0")])