]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
SR-IOV agent: display loaded extensions
authorMoshe Levi <moshele@mellanox.com>
Thu, 17 Dec 2015 16:03:00 +0000 (18:03 +0200)
committerMoshe Levi <moshele@mellanox.com>
Wed, 6 Jan 2016 08:45:09 +0000 (10:45 +0200)
The SR-IOV agent support l2 agent extension due to
this patch https://review.openstack.org/#/c/210483/

This patch allow to show the loaded l2 agent extensions
when executing neutron agent-show <SR-IOV agent id>

Closes-Bug: #1527307
DocImpact update the agent configuration to show
          l2 agent extensions
Change-Id: I5dcb79ef539e4f18693e4a8eff03fff40873d3fa

neutron/plugins/ml2/drivers/mech_sriov/agent/sriov_nic_agent.py
neutron/tests/unit/plugins/ml2/drivers/mech_sriov/agent/test_sriov_nic_agent.py
releasenotes/notes/sriov_show_l2_agent_extensions-ca852e155a529e99.yaml [new file with mode: 0644]

index b0432eb371df522b55651a601633b56efd950b6b..4fe5879a37ab19f08370600ebe32aba10820f201 100644 (file)
@@ -93,14 +93,6 @@ class SriovNicSwitchAgent(object):
         self.conf = cfg.CONF
         self.setup_eswitch_mgr(physical_devices_mappings,
                                exclude_devices)
-        configurations = {'device_mappings': physical_devices_mappings}
-        self.agent_state = {
-            'binary': 'neutron-sriov-nic-agent',
-            'host': self.conf.host,
-            'topic': n_constants.L2_AGENT_TOPIC,
-            'configurations': configurations,
-            'agent_type': n_constants.AGENT_TYPE_NIC_SWITCH,
-            'start_flag': True}
 
         # Stores port update notifications for processing in the main loop
         self.updated_devices = set()
@@ -114,6 +106,17 @@ class SriovNicSwitchAgent(object):
         self._setup_rpc()
         self.ext_manager = self._create_agent_extension_manager(
             self.connection)
+
+        configurations = {'device_mappings': physical_devices_mappings,
+                          'extensions': self.ext_manager.names()}
+        self.agent_state = {
+            'binary': 'neutron-sriov-nic-agent',
+            'host': self.conf.host,
+            'topic': n_constants.L2_AGENT_TOPIC,
+            'configurations': configurations,
+            'agent_type': n_constants.AGENT_TYPE_NIC_SWITCH,
+            'start_flag': True}
+
         # The initialization is complete; we can start receiving messages
         self.connection.consume_in_threads()
         # Initialize iteration counter
index ab31dee21dfe366701a6b0a302ec41e532938b14..a794d87640d7cc55835ba667b3f18951a75732a2 100644 (file)
@@ -18,6 +18,8 @@ import mock
 from oslo_config import cfg
 from oslo_utils import uuidutils
 
+from neutron.agent.l2.extensions import manager as l2_ext_manager
+from neutron.agent import rpc as agent_rpc
 from neutron.extensions import portbindings
 from neutron.plugins.ml2.drivers.mech_sriov.agent.common import config  # noqa
 from neutron.plugins.ml2.drivers.mech_sriov.agent.common import exceptions
@@ -307,3 +309,24 @@ class TestSriovNicSwitchRpcCallbacks(base.BaseTestCase):
         kwargs = {'context': self.context, 'port': port}
         self.sriov_rpc_callback.port_update(**kwargs)
         self.assertEqual(set(), self.agent.updated_devices)
+
+
+class TestSRIOVAgentExtensionConfig(base.BaseTestCase):
+    def setUp(self):
+        super(TestSRIOVAgentExtensionConfig, self).setUp()
+        l2_ext_manager.register_opts(cfg.CONF)
+        # disable setting up periodic state reporting
+        cfg.CONF.set_override('report_interval', 0, group='AGENT')
+        cfg.CONF.set_override('extensions', ['qos'], group='agent')
+
+    @mock.patch("neutron.plugins.ml2.drivers.mech_sriov.agent.eswitch_manager"
+               ".ESwitchManager.get_assigned_devices_info", return_value=[])
+    def test_report_loaded_extension(self, *args):
+        with mock.patch.object(agent_rpc.PluginReportStateAPI,
+                               'report_state') as mock_report_state:
+            agent = sriov_nic_agent.SriovNicSwitchAgent({}, {}, 0)
+            agent._report_state()
+            mock_report_state.assert_called_with(
+                agent.context, agent.agent_state)
+            self.assertEqual(
+                ['qos'], agent.agent_state['configurations']['extensions'])
diff --git a/releasenotes/notes/sriov_show_l2_agent_extensions-ca852e155a529e99.yaml b/releasenotes/notes/sriov_show_l2_agent_extensions-ca852e155a529e99.yaml
new file mode 100644 (file)
index 0000000..8387f88
--- /dev/null
@@ -0,0 +1,3 @@
+---
+fixes:
+  - Loaded agent extensions of SR-IOV agent are now shown in agent state API.
\ No newline at end of file