[OVN] Fix get/update/delete of non-OVN agents
At some point, KeyError stopped being raised by get_agent and instead the AgentNotFound exception. This meant that the patched plugin methods would not be called for {get,update,delete}_agent calls for non-OVN agents. Change-Id: Id755a9eec08414d7a77e67a426d7796fae693ac7 Closes-Bug: #1895033
This commit is contained in:
parent
215a541bd4
commit
0a785e90c3
|
@ -1145,7 +1145,7 @@ class OVNMechanismDriver(api.MechanismDriver):
|
||||||
new_method = types.MethodType(new_fn, self._plugin)
|
new_method = types.MethodType(new_fn, self._plugin)
|
||||||
try:
|
try:
|
||||||
return new_method(*args, _driver=self, **kwargs)
|
return new_method(*args, _driver=self, **kwargs)
|
||||||
except KeyError:
|
except n_exc.NotFound:
|
||||||
return old_method(*args, **kwargs)
|
return old_method(*args, **kwargs)
|
||||||
|
|
||||||
setattr(self._plugin, method_name, types.MethodType(fn, self._plugin))
|
setattr(self._plugin, method_name, types.MethodType(fn, self._plugin))
|
||||||
|
|
|
@ -742,3 +742,24 @@ class TestProvnetPorts(base.TestOVNFunctionalBase):
|
||||||
ovn_localnetport = self._find_port_row_by_name(
|
ovn_localnetport = self._find_port_row_by_name(
|
||||||
utils.ovn_provnet_port_name(seg_2['id']))
|
utils.ovn_provnet_port_name(seg_2['id']))
|
||||||
self.assertIsNone(ovn_localnetport)
|
self.assertIsNone(ovn_localnetport)
|
||||||
|
|
||||||
|
|
||||||
|
class TestAgentApi(base.TestOVNFunctionalBase):
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
super().setUp()
|
||||||
|
self.host = 'test-host'
|
||||||
|
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)
|
||||||
|
|
||||||
|
def get_agent(self, agent_type):
|
||||||
|
return next(iter(self.plugin.get_agents(
|
||||||
|
self.context, filters={'agent_type': agent_type})))
|
||||||
|
|
||||||
|
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']))
|
||||||
|
|
Loading…
Reference in New Issue