diff --git a/neutron/db/agents_db.py b/neutron/db/agents_db.py index ff39f8d21e1..c4766d4536b 100644 --- a/neutron/db/agents_db.py +++ b/neutron/db/agents_db.py @@ -430,6 +430,7 @@ class AgentDbMixin(ext_agent.AgentPluginBase, AgentAvailabilityZoneMixin): agent_state['agent_status'] = status agent_state['admin_state_up'] = agent.admin_state_up + agent_state['id'] = agent.id registry.publish(resources.AGENT, event_type, self, payload=events.DBEventPayload( context=context, metadata={ diff --git a/neutron/tests/functional/plugins/ml2/drivers/ovn/mech_driver/test_mech_driver.py b/neutron/tests/functional/plugins/ml2/drivers/ovn/mech_driver/test_mech_driver.py index f7135bb0a05..e50b013b7c7 100644 --- a/neutron/tests/functional/plugins/ml2/drivers/ovn/mech_driver/test_mech_driver.py +++ b/neutron/tests/functional/plugins/ml2/drivers/ovn/mech_driver/test_mech_driver.py @@ -749,19 +749,18 @@ class TestAgentApi(base.TestOVNFunctionalBase): def setUp(self): super().setUp() self.host = 'test-host' - self.add_fake_chassis(self.host) + self.controller_agent = self.add_fake_chassis(self.host) self.plugin = self.mech_driver._plugin agent = {'agent_type': 'test', 'binary': '/bin/test', 'host': self.host, 'topic': 'test_topic'} - self.plugin.create_or_update_agent(self.context, agent) + _, status = self.plugin.create_or_update_agent(self.context, agent) + self.test_agent = status['id'] mock.patch.object(self.mech_driver, 'ping_all_chassis', return_value=False).start() - def get_agent(self, agent_type): - return next(iter(self.plugin.get_agents( - self.context, filters={'agent_type': agent_type}))) + def test_agent_show_non_ovn(self): + self.assertTrue(self.plugin.get_agent(self.context, self.test_agent)) - def test_agent_show(self): - for agent_type in ('test', ovn_const.OVN_CONTROLLER_AGENT): - agent = self.get_agent(agent_type) - self.assertTrue(self.plugin.get_agent(self.context, agent['id'])) + def test_agent_show_ovn_controller(self): + self.assertTrue(self.plugin.get_agent(self.context, + self.controller_agent))