From 58c0e498b45b20be936cdfbf9f8c748dba2c2c47 Mon Sep 17 00:00:00 2001 From: Sean Mooney Date: Fri, 26 Jun 2015 12:37:22 +0100 Subject: [PATCH] Adds configurable agent type This change introduces a new agent_type config option which allows the ovs agent to be reused by out of tree mechanism drivers. DocImpact Change-Id: I48f4be4b1d51bcff62e86e5814c12bd9bfa3c902 Closes-Bug: #1469871 --- etc/neutron/plugins/ml2/openvswitch_agent.ini | 7 ++++ .../openvswitch/agent/common/config.py | 7 ++-- .../openvswitch/agent/ovs_neutron_agent.py | 2 +- .../agent/test_ovs_neutron_agent.py | 32 +++++++++++++++++++ 4 files changed, 45 insertions(+), 3 deletions(-) diff --git a/etc/neutron/plugins/ml2/openvswitch_agent.ini b/etc/neutron/plugins/ml2/openvswitch_agent.ini index 664aa0a1f..ad096871f 100644 --- a/etc/neutron/plugins/ml2/openvswitch_agent.ini +++ b/etc/neutron/plugins/ml2/openvswitch_agent.ini @@ -168,6 +168,13 @@ # # tunnel_csum = False +# (StrOpt) agent_type to report. +# This config entry allows configuration of the neutron agent type reported +# by the default ovs l2 agent. This allows multiple ovs mechanism drivers +# to share a common ovs agent implementation. NOTE: this value will be +# removed in the mitaka cycle. +# +# agent_type = 'Open vSwitch agent' [securitygroup] # Firewall driver for realizing neutron security group function. diff --git a/neutron/plugins/ml2/drivers/openvswitch/agent/common/config.py b/neutron/plugins/ml2/drivers/openvswitch/agent/common/config.py index 300c1a836..5fcdb5623 100644 --- a/neutron/plugins/ml2/drivers/openvswitch/agent/common/config.py +++ b/neutron/plugins/ml2/drivers/openvswitch/agent/common/config.py @@ -15,6 +15,7 @@ from oslo_config import cfg from neutron.agent.common import config +from neutron.common import constants as n_const from neutron.plugins.common import constants as p_const from neutron.plugins.ml2.drivers.openvswitch.agent.common \ import constants @@ -122,8 +123,10 @@ agent_opts = [ "cause brief traffic interruption.")), cfg.BoolOpt('tunnel_csum', default=False, help=_("Set or un-set the tunnel header checksum on " - "outgoing IP packet carrying GRE/VXLAN tunnel.")) - + "outgoing IP packet carrying GRE/VXLAN tunnel.")), + cfg.StrOpt('agent_type', default=n_const.AGENT_TYPE_OVS, + deprecated_for_removal=True, + help=_("Selects the Agent Type reported")) ] diff --git a/neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py b/neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py index ee54f3e01..fc7e0c832 100644 --- a/neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py +++ b/neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py @@ -215,7 +215,7 @@ class OVSNeutronAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin, self.enable_distributed_routing, 'log_agent_heartbeats': self.conf.AGENT.log_agent_heartbeats}, - 'agent_type': n_const.AGENT_TYPE_OVS, + 'agent_type': self.conf.AGENT.agent_type, 'start_flag': True} if tunnel_types: diff --git a/neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/test_ovs_neutron_agent.py b/neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/test_ovs_neutron_agent.py index 9869fa1e3..bc0ea9dad 100644 --- a/neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/test_ovs_neutron_agent.py +++ b/neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/test_ovs_neutron_agent.py @@ -226,6 +226,38 @@ class TestOvsNeutronAgent(object): **kwargs) self.assertEqual(expected, self.agent.int_br.datapath_type) + def test_agent_type_ovs(self): + # verify agent_type is default + expected = n_const.AGENT_TYPE_OVS + self.assertEqual(expected, + self.agent.agent_state['agent_type']) + + def test_agent_type_alt(self): + with mock.patch.object(self.mod_agent.OVSNeutronAgent, + 'setup_integration_br'),\ + mock.patch.object(self.mod_agent.OVSNeutronAgent, + 'setup_ancillary_bridges', + return_value=[]), \ + mock.patch('neutron.agent.linux.utils.get_interface_mac', + return_value='00:00:00:00:00:01'), \ + mock.patch( + 'neutron.agent.common.ovs_lib.BaseOVS.get_bridges'), \ + mock.patch('oslo_service.loopingcall.FixedIntervalLoopingCall', + new=MockFixedIntervalLoopingCall), \ + mock.patch( + 'neutron.agent.common.ovs_lib.OVSBridge.' 'get_vif_ports', + return_value=[]): + # validate setting non default agent_type + expected = 'alt agent type' + cfg.CONF.set_override('agent_type', + expected, + group='AGENT') + kwargs = self.mod_agent.create_agent_config_map(cfg.CONF) + self.agent = self.mod_agent.OVSNeutronAgent(self._bridge_classes(), + **kwargs) + self.assertEqual(expected, + self.agent.agent_state['agent_type']) + def test_restore_local_vlan_map_with_device_has_tag(self): self._test_restore_local_vlan_maps(2) -- 2.45.2