]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Adds configurable agent type
authorSean Mooney <sean.k.mooney@intel.com>
Fri, 26 Jun 2015 11:37:22 +0000 (12:37 +0100)
committerSean Mooney <sean.k.mooney@intel.com>
Tue, 22 Sep 2015 12:01:58 +0000 (13:01 +0100)
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
neutron/plugins/ml2/drivers/openvswitch/agent/common/config.py
neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py
neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/test_ovs_neutron_agent.py

index 664aa0a1f31db59f0d71cab52a4cad4f738947e8..ad096871f678e46c2d547457e9b295e99ef277af 100644 (file)
 #
 # 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.
index 300c1a8369579564292ce2b5b0b20e6acf870cee..5fcdb56234beef5c2a53bf38f298e4772fd5adc4 100644 (file)
@@ -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"))
 ]
 
 
index ee54f3e01cbe4c28dcbb24de6520a2f75bca45d8..fc7e0c832b60c612018797ab6dc72084cbbf4c4e 100644 (file)
@@ -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:
index 9869fa1e317d940b9dd23dde6ce124521b208f60..bc0ea9dad17ff199bea2b7284f7692b776fb71b5 100644 (file)
@@ -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)