From: Moshe Levi Date: Thu, 17 Dec 2015 16:03:00 +0000 (+0200) Subject: SR-IOV agent: display loaded extensions X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=66a91c6c386e2e6cd9653dc02fa382c13f68e14a;p=openstack-build%2Fneutron-build.git SR-IOV agent: display loaded extensions 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 Closes-Bug: #1527307 DocImpact update the agent configuration to show l2 agent extensions Change-Id: I5dcb79ef539e4f18693e4a8eff03fff40873d3fa --- diff --git a/neutron/plugins/ml2/drivers/mech_sriov/agent/sriov_nic_agent.py b/neutron/plugins/ml2/drivers/mech_sriov/agent/sriov_nic_agent.py index b0432eb37..4fe5879a3 100644 --- a/neutron/plugins/ml2/drivers/mech_sriov/agent/sriov_nic_agent.py +++ b/neutron/plugins/ml2/drivers/mech_sriov/agent/sriov_nic_agent.py @@ -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 diff --git a/neutron/tests/unit/plugins/ml2/drivers/mech_sriov/agent/test_sriov_nic_agent.py b/neutron/tests/unit/plugins/ml2/drivers/mech_sriov/agent/test_sriov_nic_agent.py index ab31dee21..a794d8764 100644 --- a/neutron/tests/unit/plugins/ml2/drivers/mech_sriov/agent/test_sriov_nic_agent.py +++ b/neutron/tests/unit/plugins/ml2/drivers/mech_sriov/agent/test_sriov_nic_agent.py @@ -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 index 000000000..8387f88be --- /dev/null +++ b/releasenotes/notes/sriov_show_l2_agent_extensions-ca852e155a529e99.yaml @@ -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