]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Removed configuration option for qos agent driver selection
authorIhar Hrachyshka <ihrachys@redhat.com>
Mon, 10 Aug 2015 06:29:52 +0000 (08:29 +0200)
committerIhar Hrachyshka <ihrachys@redhat.com>
Mon, 10 Aug 2015 16:08:16 +0000 (18:08 +0200)
There is no (general) use case to allow users to configure qos driver to
load by qos l2 agent extension. So instead of getting the driver name
from the configuration file, hardcode it and potentially reuse for other
extensions that may also be interested in splitting extension into
agent agnostic and agent specific pieces.

Added driver_type parameter to AgentCoreResourceExtension.initialize().
Also updated the method signature to reflect that we expect l2
extensions to receive connection.

Finally, removed #noqa import for openvswitch.common.config from qos
extension unit test since it seems unneeded.

Change-Id: Iae4dcc20c967d1da216772a3a3660e0421263527
Partially-Implements: quantum-qos-api

etc/neutron/plugins/ml2/openvswitch_agent.ini
neutron/agent/l2/agent_extension.py
neutron/agent/l2/extensions/manager.py
neutron/agent/l2/extensions/qos.py
neutron/plugins/ml2/drivers/openvswitch/agent/common/config.py
neutron/plugins/ml2/drivers/openvswitch/agent/common/constants.py
neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py
neutron/tests/unit/agent/l2/extensions/test_manager.py
neutron/tests/unit/agent/l2/extensions/test_qos.py

index 5a23d1ea2f9f2530f2ec8a1fb75a97c4f0a6268e..b6fd3e01a2d11cbd034d505fb89c5cea6a2b0079 100644 (file)
 # It should be false when you use nova security group.
 # enable_security_group = True
 
-[qos]
-# QoS agent driver
-# agent_driver = ovs
-
 #-----------------------------------------------------------------------------
 # Sample Configurations.
 #-----------------------------------------------------------------------------
index 125a9bc0594ff55f03675637530c19e066e8b69a..c80fb3fa4607336fff95279613439c6ac724becc 100644 (file)
@@ -25,9 +25,15 @@ class AgentCoreResourceExtension(object):
     An agent extension extends the agent core functionality.
     """
 
-    def initialize(self):
+    def initialize(self, connection, driver_type):
         """Perform agent core resource extension initialization.
 
+        :param connection: RPC connection that can be reused by the extension
+                           to define its RPC endpoints
+        :param driver_type: a string that defines the agent type to the
+                            extension. Can be used to choose the right backend
+                            implementation.
+
         Called after all extensions have been loaded.
         No port handling will be called before this method.
         """
index 2c77adbf8e935194bd81c6671767a2849fcf0862..1fa71ebbfcffec37e3c8ab8a276c4163b4cd24e9 100644 (file)
@@ -43,11 +43,19 @@ class AgentExtensionsManager(stevedore.named.NamedExtensionManager):
             invoke_on_load=True, name_order=True)
         LOG.info(_LI("Loaded agent extensions: %s"), self.names())
 
-    def initialize(self, connection):
+    def initialize(self, connection, driver_type):
+        """Initialize enabled L2 agent extensions.
+
+        :param connection: RPC connection that can be reused by extensions to
+                           define their RPC endpoints
+        :param driver_type: a string that defines the agent type to the
+                            extension. Can be used by the extension to choose
+                            the right backend implementation.
+        """
         # Initialize each agent extension in the list.
         for extension in self:
             LOG.info(_LI("Initializing agent extension '%s'"), extension.name)
-            extension.obj.initialize(connection)
+            extension.obj.initialize(connection, driver_type)
 
     def handle_port(self, context, data):
         """Notify all agent extensions to handle port."""
index 891084bf77aabfd0c3b5e93c3bf41007526c3576..2acf1efc97972770f16ab649e0d7ad08eede415a 100644 (file)
@@ -17,7 +17,6 @@ import abc
 import collections
 
 from oslo_concurrency import lockutils
-from oslo_config import cfg
 import six
 
 from neutron.agent.l2 import agent_extension
@@ -30,7 +29,7 @@ from neutron import manager
 
 @six.add_metaclass(abc.ABCMeta)
 class QosAgentDriver(object):
-    """Define stable abstract interface for QoS Agent Driver.
+    """Defines stable abstract interface for QoS Agent Driver.
 
     QoS Agent driver defines the interface to be implemented by Agent
     for applying QoS Rules on a port.
@@ -40,7 +39,6 @@ class QosAgentDriver(object):
     def initialize(self):
         """Perform QoS agent driver initialization.
         """
-        pass
 
     @abc.abstractmethod
     def create(self, port, qos_policy):
@@ -51,7 +49,6 @@ class QosAgentDriver(object):
         """
         #TODO(QoS) we may want to provide default implementations of calling
         #delete and then update
-        pass
 
     @abc.abstractmethod
     def update(self, port, qos_policy):
@@ -60,7 +57,6 @@ class QosAgentDriver(object):
         :param port: port object.
         :param qos_policy: the QoS policy to be applied on port.
         """
-        pass
 
     @abc.abstractmethod
     def delete(self, port, qos_policy):
@@ -69,21 +65,18 @@ class QosAgentDriver(object):
         :param port: port object.
         :param qos_policy: the QoS policy to be removed from port.
         """
-        pass
 
 
 class QosAgentExtension(agent_extension.AgentCoreResourceExtension):
     SUPPORTED_RESOURCES = [resources.QOS_POLICY]
 
-    def initialize(self, connection):
+    def initialize(self, connection, driver_type):
         """Perform Agent Extension initialization.
 
         """
-        super(QosAgentExtension, self).initialize()
-
         self.resource_rpc = resources_rpc.ResourcesPullRpcApi()
         self.qos_driver = manager.NeutronManager.load_class_for_provider(
-            'neutron.qos.agent_drivers', cfg.CONF.qos.agent_driver)()
+            'neutron.qos.agent_drivers', driver_type)()
         self.qos_driver.initialize()
 
         # we cannot use a dict of sets here because port dicts are not hashable
index c9afccff67cfb4e4655ee000dd5aead920072163..98b6210f937d68fad6510aa6d136e04c0e56052c 100644 (file)
@@ -100,12 +100,7 @@ agent_opts = [
                       "timeout won't be changed"))
 ]
 
-qos_opts = [
-    cfg.StrOpt('agent_driver', default='ovs', help=_('QoS agent driver.')),
-]
-
 
 cfg.CONF.register_opts(ovs_opts, "OVS")
 cfg.CONF.register_opts(agent_opts, "AGENT")
-cfg.CONF.register_opts(qos_opts, "qos")
 config.register_agent_state_opts_helper(cfg.CONF)
index 40fa8f0f07f98f89c5fe54aaa54ed8f142862a80..ad6b897c267c6b51cde208cac8b5f97b26fc4bbc 100644 (file)
@@ -88,3 +88,5 @@ ARP_RESPONDER_ACTIONS = ('move:NXM_OF_ETH_SRC[]->NXM_OF_ETH_DST[],'
 OVS_RESTARTED = 0
 OVS_NORMAL = 1
 OVS_DEAD = 2
+
+EXTENSION_DRIVER_TYPE = 'ovs'
index a5190f9a39657756fcaf463ba780eea13f809e4d..73b5cab3901c363c4c87a81678f8391774fec858 100644 (file)
@@ -371,7 +371,8 @@ class OVSNeutronAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin,
         ext_manager.register_opts(self.conf)
         self.ext_manager = (
             ext_manager.AgentExtensionsManager(self.conf))
-        self.ext_manager.initialize(connection)
+        self.ext_manager.initialize(
+            connection, constants.EXTENSION_DRIVER_TYPE)
 
     def get_net_uuid(self, vif_id):
         for network_id, vlan_mapping in six.iteritems(self.local_vlan_map):
index 3aa8ea58ba162d40450efda7c7b99a2c58b5720a..5768205d5cacbc59631b4fa92479169f109ca257 100644 (file)
@@ -33,9 +33,9 @@ class TestAgentExtensionsManager(base.BaseTestCase):
 
     def test_initialize(self):
         connection = object()
-        self.manager.initialize(connection)
+        self.manager.initialize(connection, 'fake_driver_type')
         ext = self._get_extension()
-        ext.initialize.assert_called_once_with(connection)
+        ext.initialize.assert_called_once_with(connection, 'fake_driver_type')
 
     def test_handle_port(self):
         context = object()
index d78fc3121b18b68197f1f15901f03376e3193c45..ef3d1095f6479b999118efabda79bca77b90505a 100755 (executable)
@@ -22,7 +22,7 @@ from neutron.api.rpc.callbacks import events
 from neutron.api.rpc.callbacks import resources
 from neutron.api.rpc.handlers import resources_rpc
 from neutron import context
-from neutron.plugins.ml2.drivers.openvswitch.agent.common import config  # noqa
+from neutron.plugins.ml2.drivers.openvswitch.agent.common import constants
 from neutron.tests import base
 
 
@@ -48,7 +48,8 @@ class QosExtensionRpcTestCase(QosExtensionBaseTestCase):
 
     def setUp(self):
         super(QosExtensionRpcTestCase, self).setUp()
-        self.qos_ext.initialize(self.connection)
+        self.qos_ext.initialize(
+            self.connection, constants.EXTENSION_DRIVER_TYPE)
 
         self.pull_mock = mock.patch.object(
             self.qos_ext.resource_rpc, 'pull',
@@ -158,7 +159,8 @@ class QosExtensionInitializeTestCase(QosExtensionBaseTestCase):
     @mock.patch.object(registry, 'subscribe')
     @mock.patch.object(resources_rpc, 'ResourcesPushRpcCallback')
     def test_initialize_subscribed_to_rpc(self, rpc_mock, subscribe_mock):
-        self.qos_ext.initialize(self.connection)
+        self.qos_ext.initialize(
+            self.connection, constants.EXTENSION_DRIVER_TYPE)
         self.connection.create_consumer.assert_has_calls(
             [mock.call(
                  resources_rpc.resource_type_versioned_topic(resource_type),