Esempio n. 1
0
 def test_main(self):
     bridges = ['br-int', 'br-ex']
     ports = ['p1', 'p2', 'p3']
     conf = mock.Mock()
     conf.ovs_all_ports = False
     conf.ovs_integration_bridge = 'br-int'
     conf.external_network_bridge = 'br-ex'
     with contextlib.nested(
             mock.patch('neutron.common.config.setup_logging'),
             mock.patch('neutron.cmd.ovs_cleanup.setup_conf',
                        return_value=conf),
             mock.patch('neutron.agent.linux.ovs_lib.BaseOVS.get_bridges',
                        return_value=bridges),
             mock.patch('neutron.agent.linux.ovs_lib.OVSBridge'),
             mock.patch.object(util,
                               'collect_neutron_ports',
                               return_value=ports),
             mock.patch.object(
                 util, 'delete_neutron_ports')) as (_log, _conf, _get, ovs,
                                                    collect, delete):
         with mock.patch('neutron.common.config.setup_logging'):
             util.main()
             ovs.assert_has_calls(
                 [mock.call().delete_ports(all_ports=False)])
             collect.assert_called_once_with(set(bridges))
             delete.assert_called_once_with(ports)
Esempio n. 2
0
    def test_main(self, mock_delete, mock_collect, mock_ovs,
                  mock_get_bridges, mock_conf, mock_logging, mock_conn):
        bridges = ['br-int', 'br-ex']
        ports = ['p1', 'p2', 'p3']
        conf = mock.Mock()
        conf.ovs_all_ports = False
        conf.ovs_integration_bridge = 'br-int'
        conf.external_network_bridge = 'br-ex'
        mock_conf.return_value = conf
        mock_get_bridges.return_value = bridges
        mock_collect.return_value = ports

        util.main()
        mock_collect.assert_called_once_with(set(bridges))
        mock_delete.assert_called_once_with(ports)
Esempio n. 3
0
    def test_main(self, mock_delete, mock_collect, mock_ovs,
                  mock_get_bridges, mock_conf, mock_logging, mock_conn):
        bridges = ['br-int', 'br-ex']
        ports = ['p1', 'p2', 'p3']
        conf = mock.Mock()
        conf.ovs_all_ports = False
        conf.ovs_integration_bridge = 'br-int'
        conf.external_network_bridge = 'br-ex'
        mock_conf.return_value = conf
        mock_get_bridges.return_value = bridges
        mock_collect.return_value = ports

        util.main()
        mock_ovs.assert_has_calls([mock.call().delete_ports(
            all_ports=False)])
        mock_collect.assert_called_once_with(set(bridges))
        mock_delete.assert_called_once_with(ports)
Esempio n. 4
0
 def test_main(self):
     bridges = ["br-int", "br-ex"]
     ports = ["p1", "p2", "p3"]
     conf = mock.Mock()
     conf.AGENT.root_helper = "dummy_sudo"
     conf.ovs_all_ports = False
     conf.ovs_integration_bridge = "br-int"
     conf.external_network_bridge = "br-ex"
     with contextlib.nested(
         mock.patch("neutron.common.config.setup_logging"),
         mock.patch("neutron.cmd.ovs_cleanup.setup_conf", return_value=conf),
         mock.patch("neutron.agent.linux.ovs_lib.BaseOVS.get_bridges", return_value=bridges),
         mock.patch("neutron.agent.linux.ovs_lib.OVSBridge"),
         mock.patch.object(util, "collect_neutron_ports", return_value=ports),
         mock.patch.object(util, "delete_neutron_ports"),
     ) as (_log, _conf, _get, ovs, collect, delete):
         with mock.patch("neutron.common.config.setup_logging"):
             util.main()
             ovs.assert_has_calls([mock.call().delete_ports(all_ports=False)])
             collect.assert_called_once_with(set(bridges), "dummy_sudo")
             delete.assert_called_once_with(ports, "dummy_sudo")
Esempio n. 5
0
 def test_main(self):
     bridges = ['br-int', 'br-ex']
     ports = ['p1', 'p2', 'p3']
     conf = mock.Mock()
     conf.ovs_all_ports = False
     conf.ovs_integration_bridge = 'br-int'
     conf.external_network_bridge = 'br-ex'
     with contextlib.nested(
         mock.patch('neutron.common.config.setup_logging'),
         mock.patch('neutron.cmd.ovs_cleanup.setup_conf',
                    return_value=conf),
         mock.patch('neutron.agent.linux.ovs_lib.BaseOVS.get_bridges',
                    return_value=bridges),
         mock.patch('neutron.agent.linux.ovs_lib.OVSBridge'),
         mock.patch.object(util, 'collect_neutron_ports',
                           return_value=ports),
         mock.patch.object(util, 'delete_neutron_ports')
     ) as (_log, _conf, _get, ovs, collect, delete):
         with mock.patch('neutron.common.config.setup_logging'):
             util.main()
             ovs.assert_has_calls([mock.call().delete_ports(
                 all_ports=False)])
             collect.assert_called_once_with(set(bridges))
             delete.assert_called_once_with(ports)