Merge "ovs: log config options when all of them are registered"
This commit is contained in:
commit
f926cd124f
@ -23,7 +23,6 @@ from oslo_utils import importutils
|
||||
|
||||
from neutron.common import config as common_config
|
||||
from neutron.common import profiler
|
||||
from neutron.common import utils as n_utils
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
@ -46,6 +45,5 @@ def main():
|
||||
mod = importutils.import_module(mod_name)
|
||||
mod.init_config()
|
||||
common_config.setup_logging()
|
||||
n_utils.log_opt_values(LOG)
|
||||
profiler.setup("neutron-ovs-agent", cfg.CONF.host)
|
||||
mod.main()
|
||||
|
@ -53,6 +53,7 @@ from neutron.api.rpc.handlers import securitygroups_rpc as sg_rpc
|
||||
from neutron.common import config
|
||||
from neutron.common import constants as c_const
|
||||
from neutron.common import topics
|
||||
from neutron.common import utils as n_utils
|
||||
from neutron.conf.agent import xenapi_conf
|
||||
from neutron.plugins.common import constants as p_const
|
||||
from neutron.plugins.common import utils as p_utils
|
||||
@ -125,7 +126,7 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin,
|
||||
# 1.4 Added support for network_update
|
||||
target = oslo_messaging.Target(version='1.4')
|
||||
|
||||
def __init__(self, bridge_classes, conf=None):
|
||||
def __init__(self, bridge_classes, ext_manager, conf=None):
|
||||
'''Constructor.
|
||||
|
||||
:param bridge_classes: a dict for bridge classes.
|
||||
@ -134,6 +135,7 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin,
|
||||
super(OVSNeutronAgent, self).__init__()
|
||||
self.conf = conf or cfg.CONF
|
||||
self.ovs = ovs_lib.BaseOVS()
|
||||
self.ext_manager = ext_manager
|
||||
agent_conf = self.conf.AGENT
|
||||
ovs_conf = self.conf.OVS
|
||||
|
||||
@ -203,7 +205,9 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin,
|
||||
self.setup_tunnel_br(ovs_conf.tunnel_bridge)
|
||||
self.setup_tunnel_br_flows()
|
||||
|
||||
self.init_extension_manager(self.connection)
|
||||
agent_api = ovs_ext_api.OVSAgentExtensionAPI(self.int_br, self.tun_br)
|
||||
self.ext_manager.initialize(
|
||||
self.connection, constants.EXTENSION_DRIVER_TYPE, agent_api)
|
||||
|
||||
self.dvr_agent = ovs_dvr_neutron_agent.OVSDVRNeutronAgent(
|
||||
self.context,
|
||||
@ -404,16 +408,6 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin,
|
||||
start_listening=False
|
||||
)
|
||||
|
||||
def init_extension_manager(self, connection):
|
||||
ext_manager.register_opts(self.conf)
|
||||
self.ext_manager = (
|
||||
ext_manager.L2AgentExtensionsManager(self.conf))
|
||||
self.agent_api = ovs_ext_api.OVSAgentExtensionAPI(self.int_br,
|
||||
self.tun_br)
|
||||
self.ext_manager.initialize(
|
||||
connection, constants.EXTENSION_DRIVER_TYPE,
|
||||
self.agent_api)
|
||||
|
||||
def port_update(self, context, **kwargs):
|
||||
port = kwargs.get('port')
|
||||
# Put the port identifier in the updated_ports set.
|
||||
@ -2192,10 +2186,17 @@ def prepare_xen_compute():
|
||||
def main(bridge_classes):
|
||||
prepare_xen_compute()
|
||||
ovs_capabilities.register()
|
||||
ext_manager.register_opts(cfg.CONF)
|
||||
|
||||
ext_mgr = ext_manager.L2AgentExtensionsManager(cfg.CONF)
|
||||
|
||||
# now that all extensions registered their options, we can log them
|
||||
n_utils.log_opt_values(LOG)
|
||||
|
||||
validate_tunnel_config(cfg.CONF.AGENT.tunnel_types, cfg.CONF.OVS.local_ip)
|
||||
|
||||
try:
|
||||
agent = OVSNeutronAgent(bridge_classes, cfg.CONF)
|
||||
agent = OVSNeutronAgent(bridge_classes, ext_mgr, cfg.CONF)
|
||||
capabilities.notify_init_event(n_const.AGENT_TYPE_OVS, agent)
|
||||
except (RuntimeError, ValueError) as e:
|
||||
LOG.error("%s Agent terminated!", e)
|
||||
|
@ -110,8 +110,9 @@ class OVSAgentTestFramework(base.BaseOVSLinuxTestCase):
|
||||
self.config.set_override('bridge_mappings', bridge_mappings, "OVS")
|
||||
# Physical bridges should be created prior to running
|
||||
self._bridge_classes()['br_phys'](self.br_phys).create()
|
||||
ext_mgr = ext_manager.L2AgentExtensionsManager(self.config)
|
||||
agent = ovs_agent.OVSNeutronAgent(self._bridge_classes(),
|
||||
self.config)
|
||||
ext_mgr, self.config)
|
||||
self.addCleanup(self.ovs.delete_bridge, self.br_int)
|
||||
if tunnel_types:
|
||||
self.addCleanup(self.ovs.delete_bridge, self.br_tun)
|
||||
|
@ -143,8 +143,9 @@ class TestOvsNeutronAgent(object):
|
||||
mock.patch(
|
||||
'neutron.agent.common.ovs_lib.OVSBridge.' 'get_vif_ports',
|
||||
return_value=[]):
|
||||
ext_manager = mock.Mock()
|
||||
agent = self.mod_agent.OVSNeutronAgent(self._bridge_classes(),
|
||||
cfg.CONF)
|
||||
ext_manager, cfg.CONF)
|
||||
agent.tun_br = self.br_tun_cls(br_name='br-tun')
|
||||
return agent
|
||||
|
||||
@ -204,8 +205,9 @@ class TestOvsNeutronAgent(object):
|
||||
cfg.CONF.set_override('datapath_type',
|
||||
expected,
|
||||
group='OVS')
|
||||
ext_manager = mock.Mock()
|
||||
self.agent = self.mod_agent.OVSNeutronAgent(self._bridge_classes(),
|
||||
cfg.CONF)
|
||||
ext_manager, cfg.CONF)
|
||||
self.assertEqual(expected, self.agent.int_br.datapath_type)
|
||||
|
||||
def test_agent_type_ovs(self):
|
||||
@ -248,8 +250,9 @@ class TestOvsNeutronAgent(object):
|
||||
cfg.CONF.set_override('agent_type',
|
||||
expected,
|
||||
group='AGENT')
|
||||
ext_manager = mock.Mock()
|
||||
self.agent = self.mod_agent.OVSNeutronAgent(self._bridge_classes(),
|
||||
cfg.CONF)
|
||||
ext_manager, cfg.CONF)
|
||||
self.assertEqual(expected,
|
||||
self.agent.agent_state['agent_type'])
|
||||
|
||||
@ -2214,8 +2217,9 @@ class AncillaryBridgesTest(object):
|
||||
mock.patch(
|
||||
'neutron.agent.common.ovs_lib.OVSBridge.' 'get_vif_ports',
|
||||
return_value=[]):
|
||||
ext_manager = mock.Mock()
|
||||
self.agent = self.mod_agent.OVSNeutronAgent(self._bridge_classes(),
|
||||
cfg.CONF)
|
||||
ext_manager, cfg.CONF)
|
||||
self.assertEqual(len(ancillary), len(self.agent.ancillary_brs))
|
||||
if ancillary:
|
||||
bridges = [br.br_name for br in self.agent.ancillary_brs]
|
||||
@ -2251,8 +2255,9 @@ class AncillaryBridgesTest(object):
|
||||
mock.patch('neutron.agent.common.ovs_lib.OVSBridge.'
|
||||
'get_vif_port_set',
|
||||
return_value=vif_port_set):
|
||||
ext_manager = mock.Mock()
|
||||
self.agent = self.mod_agent.OVSNeutronAgent(self._bridge_classes(),
|
||||
cfg.CONF)
|
||||
ext_manager, cfg.CONF)
|
||||
return self.agent.scan_ancillary_ports(registered_ports, sync)
|
||||
|
||||
def test_scan_ancillary_ports_returns_cur_only_for_unchanged_ports(self):
|
||||
@ -2325,8 +2330,9 @@ class TestOvsDvrNeutronAgent(object):
|
||||
mock.patch(
|
||||
'neutron.agent.common.ovs_lib.OVSBridge.' 'get_vif_ports',
|
||||
return_value=[]):
|
||||
ext_manager = mock.Mock()
|
||||
self.agent = self.mod_agent.OVSNeutronAgent(self._bridge_classes(),
|
||||
cfg.CONF)
|
||||
ext_manager, cfg.CONF)
|
||||
self.agent.tun_br = self.br_tun_cls(br_name='br-tun')
|
||||
self.agent.sg_agent = mock.Mock()
|
||||
|
||||
|
@ -301,7 +301,9 @@ class TunnelTest(object):
|
||||
for k, v in config_opts_agent.items():
|
||||
cfg.CONF.set_override(k, v, 'AGENT')
|
||||
|
||||
return self.mod_agent.OVSNeutronAgent(bridge_classes, cfg.CONF)
|
||||
ext_mgr = mock.Mock()
|
||||
return self.mod_agent.OVSNeutronAgent(
|
||||
bridge_classes, ext_mgr, cfg.CONF)
|
||||
|
||||
def _verify_mock_call(self, mock_obj, expected):
|
||||
mock_obj.assert_has_calls(expected)
|
||||
|
Loading…
x
Reference in New Issue
Block a user