Beispiel #1
0
    def test_delete_bridge_none(self, mock_dev_exists, mock_execute):
        linux_net.delete_bridge("br0", "vnet1")

        self.assertEqual(mock_execute.mock_calls, [])
        self.assertEqual(mock_dev_exists.mock_calls, [
            mock.call("br0")
        ])
    def test_delete_bridge_exists(self, mock_dev_exists, mock_delete,
                                  mock_set_state):
        linux_net.delete_bridge("br0", "vnet1")

        mock_dev_exists.assert_has_calls([mock.call("br0"),
                                          mock.call("vnet1")])
        mock_delete.assert_called_once_with("br0", check_exit_code=[0, 2, 254])
        mock_set_state.assert_called_once_with("vnet1", "down")
Beispiel #3
0
    def test_delete_interface_not_present(self, mock_interface_br,
                                          mock_dev_exists, mock_execute,
                                          mock_ip_set):
        linux_net.delete_bridge("br0", "vnet1")

        mock_execute.assert_called_once_with('brctl', 'delbr', 'br0')
        mock_dev_exists.assert_has_calls([mock.call("br0")])
        mock_interface_br.assert_called_once_with("br0", "vnet1")
        mock_ip_set.assert_called_once_with('br0', state='down')
Beispiel #4
0
    def test_delete_bridge_exists(self, mock_dev_exists, mock_execute):
        linux_net.delete_bridge("br0", "vnet1")

        self.assertEqual(mock_execute.mock_calls, [
            mock.call('brctl', 'delif', 'br0', 'vnet1'),
            mock.call('ip', 'link', 'set', 'br0', 'down'),
            mock.call('brctl', 'delbr', 'br0'),
        ])
        self.assertEqual(mock_dev_exists.mock_calls, [mock.call("br0")])
Beispiel #5
0
    def test_delete_bridge_exists(self, mock_dev_exists, mock_execute):
        linux_net.delete_bridge("br0", "vnet1")

        self.assertEqual(mock_execute.mock_calls, [
            mock.call('brctl', 'delif', 'br0', 'vnet1'),
            mock.call('ip', 'link', 'set', 'br0', 'down'),
            mock.call('brctl', 'delbr', 'br0'),
        ])
        self.assertEqual(mock_dev_exists.mock_calls, [
            mock.call("br0")
        ])
    def test_delete_interface_not_present(self, mock_dev_exists, mock_delete,
                                          mock_set_state):
        mock_dev_exists.return_value = next(lambda: (yield True),
                                            (yield False))

        linux_net.delete_bridge("br0", "vnet1")

        mock_dev_exists.assert_has_calls([mock.call("br0"),
                                          mock.call("vnet1")])
        mock_delete.assert_called_once_with("br0", check_exit_code=[0, 2, 254])
        mock_set_state.assert_not_called()
Beispiel #7
0
    def test_delete_bridge_none(
        self,
        mock_interface_br,
        mock_dev_exists,
        mock_execute,
    ):
        linux_net.delete_bridge("br0", "vnet1")

        mock_execute.assert_not_called()
        mock_dev_exists.assert_has_calls([mock.call("br0")])
        mock_interface_br.assert_not_called()
Beispiel #8
0
    def test_delete_interface_not_present(self, mock_interface_br,
                                          mock_dev_exists, mock_execute):
        linux_net.delete_bridge("br0", "vnet1")

        calls = [
            mock.call('ip', 'link', 'set', 'br0', 'down'),
            mock.call('brctl', 'delbr', 'br0')
        ]
        mock_execute.assert_has_calls(calls)
        mock_dev_exists.assert_has_calls([mock.call("br0")])
        mock_interface_br.assert_called_once_with("br0", "vnet1")
Beispiel #9
0
    def _unplug_bridge(self, vif, instance_info):
        """UnPlug using hybrid strategy

        Unhook port from OVS, unhook port from bridge, delete
        bridge, and delete both veth devices.
        """

        v1_name, v2_name = self.get_veth_pair_names(vif)

        linux_net.delete_bridge(vif.bridge_name, v1_name)

        self.ovsdb.delete_ovs_vif_port(vif.network.bridge, v2_name)
Beispiel #10
0
    def _unplug_bridge(self, vif, instance_info):
        """UnPlug using hybrid strategy

        Unhook port from OVS, unhook port from bridge, delete
        bridge, and delete both veth devices.
        """

        v1_name, v2_name = self.get_veth_pair_names(vif)

        linux_net.delete_bridge(vif.bridge_name, v1_name)

        linux_net.delete_ovs_vif_port(vif.network.bridge, v2_name,
                                      timeout=self.config.ovs_vsctl_timeout)
    def test_delete_bridge_none(self, mock_dev_exists, mock_delete):
        linux_net.delete_bridge("br0", "vnet1")

        mock_delete.assert_not_called()
        mock_dev_exists.assert_called_once_with("br0")
Beispiel #12
0
    def test_delete_bridge_none(self, mock_dev_exists, mock_execute):
        linux_net.delete_bridge("br0", "vnet1")

        self.assertEqual(mock_execute.mock_calls, [])
        self.assertEqual(mock_dev_exists.mock_calls, [mock.call("br0")])