Merge "Enable OVS and NETNS utilities to perform logging"

This commit is contained in:
Jenkins 2013-02-08 06:20:02 +00:00 committed by Gerrit Code Review
commit ffbef0a1c0
4 changed files with 42 additions and 36 deletions

View File

@ -68,11 +68,10 @@ def setup_conf():
help=_('Delete the namespace by removing all devices.')), help=_('Delete the namespace by removing all devices.')),
] ]
conf = cfg.ConfigOpts() conf = cfg.CONF
conf.register_opts(opts) conf.register_opts(opts)
agent_config.register_root_helper(conf) agent_config.register_root_helper(conf)
conf.register_opts(dhcp.OPTS) conf.register_opts(dhcp.OPTS)
config.setup_logging(conf)
return conf return conf
@ -168,6 +167,7 @@ def main():
conf = setup_conf() conf = setup_conf()
conf() conf()
config.setup_logging(conf)
root_helper = agent_config.get_root_helper(conf) root_helper = agent_config.get_root_helper(conf)
# Identify namespaces that are candidates for deletion. # Identify namespaces that are candidates for deletion.

View File

@ -43,12 +43,11 @@ def setup_conf():
'bridges.')) 'bridges.'))
] ]
conf = cfg.ConfigOpts() conf = cfg.CONF
conf.register_cli_opts(opts) conf.register_cli_opts(opts)
conf.register_opts(l3_agent.L3NATAgent.OPTS) conf.register_opts(l3_agent.L3NATAgent.OPTS)
conf.register_opts(interface.OPTS) conf.register_opts(interface.OPTS)
agent_config.register_root_helper(conf) agent_config.register_root_helper(conf)
config.setup_logging(conf)
return conf return conf
@ -81,6 +80,7 @@ def main():
conf = setup_conf() conf = setup_conf()
conf() conf()
config.setup_logging(conf)
configuration_bridges = set([conf.ovs_integration_bridge, configuration_bridges = set([conf.ovs_integration_bridge,
conf.external_network_bridge]) conf.external_network_bridge])

View File

@ -19,6 +19,7 @@ import mock
import unittest2 as unittest import unittest2 as unittest
from quantum.agent import netns_cleanup_util as util from quantum.agent import netns_cleanup_util as util
from quantum.openstack.common import cfg
class TestNullDelegate(unittest.TestCase): class TestNullDelegate(unittest.TestCase):
@ -28,10 +29,8 @@ class TestNullDelegate(unittest.TestCase):
class TestNetnsCleanup(unittest.TestCase): class TestNetnsCleanup(unittest.TestCase):
def test_setup_conf(self): def tearDown(self):
with mock.patch('quantum.common.config.setup_logging'): cfg.CONF.reset()
conf = util.setup_conf()
self.assertFalse(conf.force)
def test_kill_dhcp(self, dhcp_active=True): def test_kill_dhcp(self, dhcp_active=True):
conf = mock.Mock() conf = mock.Mock()
@ -213,6 +212,7 @@ class TestNetnsCleanup(unittest.TestCase):
with mock.patch.multiple(util, **methods_to_mock) as mocks: with mock.patch.multiple(util, **methods_to_mock) as mocks:
mocks['eligible_for_deletion'].return_value = True mocks['eligible_for_deletion'].return_value = True
mocks['setup_conf'].return_value = conf mocks['setup_conf'].return_value = conf
with mock.patch('quantum.common.config.setup_logging'):
util.main() util.main()
mocks['eligible_for_deletion'].assert_has_calls( mocks['eligible_for_deletion'].assert_has_calls(
@ -244,6 +244,7 @@ class TestNetnsCleanup(unittest.TestCase):
with mock.patch.multiple(util, **methods_to_mock) as mocks: with mock.patch.multiple(util, **methods_to_mock) as mocks:
mocks['eligible_for_deletion'].return_value = False mocks['eligible_for_deletion'].return_value = False
mocks['setup_conf'].return_value = conf mocks['setup_conf'].return_value = conf
with mock.patch('quantum.common.config.setup_logging'):
util.main() util.main()
ip_wrap.assert_has_calls( ip_wrap.assert_has_calls(

View File

@ -23,12 +23,15 @@ import unittest2 as unittest
from quantum.agent.linux import ip_lib from quantum.agent.linux import ip_lib
from quantum.agent.linux import ovs_lib from quantum.agent.linux import ovs_lib
from quantum.agent import ovs_cleanup_util as util from quantum.agent import ovs_cleanup_util as util
from quantum.openstack.common import cfg
from quantum.openstack.common import uuidutils from quantum.openstack.common import uuidutils
class TestOVSCleanup(unittest.TestCase): class TestOVSCleanup(unittest.TestCase):
def tearDown(self):
cfg.CONF.reset()
def test_setup_conf(self): def test_setup_conf(self):
with mock.patch('quantum.common.config.setup_logging'):
conf = util.setup_conf() conf = util.setup_conf()
self.assertEqual(conf.external_network_bridge, 'br-ex') self.assertEqual(conf.external_network_bridge, 'br-ex')
self.assertEqual(conf.ovs_integration_bridge, 'br-int') self.assertEqual(conf.ovs_integration_bridge, 'br-int')
@ -54,8 +57,10 @@ class TestOVSCleanup(unittest.TestCase):
return_value=ports), return_value=ports),
mock.patch.object(util, 'delete_quantum_ports') mock.patch.object(util, 'delete_quantum_ports')
) as (_log, _conf, _get, ovs, collect, delete): ) as (_log, _conf, _get, ovs, collect, delete):
with mock.patch('quantum.common.config.setup_logging'):
util.main() util.main()
ovs.assert_has_calls([mock.call().delete_ports(all_ports=False)]) ovs.assert_has_calls([mock.call().delete_ports(
all_ports=False)])
collect.assert_called_once_with(set(bridges), 'dummy_sudo') collect.assert_called_once_with(set(bridges), 'dummy_sudo')
delete.assert_called_once_with(ports, 'dummy_sudo') delete.assert_called_once_with(ports, 'dummy_sudo')