L2 Agent Extensions handle unimplemented methods
If an L2 agent extension does not implement the handle_port or delete_port methods, we should check for that using hasattr() beforehand rather than catching any AttributeErrors. This is based on a conversation related to identical code in the L3 agent extensions: https://review.openstack.org/#/c/339246/15/neutron/agent/l3/l3_agent_extensions_manager.py@44 Change-Id: Ic0c5133a9f49c39f1f446328beb3e0ca7eb85095
This commit is contained in:
parent
c96f48162a
commit
2ae3916212
|
@ -38,23 +38,23 @@ class L2AgentExtensionsManager(agent_ext_manager.AgentExtensionsManager):
|
|||
def handle_port(self, context, data):
|
||||
"""Notify all agent extensions to handle port."""
|
||||
for extension in self:
|
||||
try:
|
||||
if hasattr(extension.obj, 'handle_port'):
|
||||
extension.obj.handle_port(context, data)
|
||||
except AttributeError:
|
||||
LOG.exception(
|
||||
_LE("Agent Extension '%(name)s' failed "
|
||||
"while handling port update"),
|
||||
else:
|
||||
LOG.error(
|
||||
_LE("Agent Extension '%(name)s' does not "
|
||||
"implement method handle_port"),
|
||||
{'name': extension.name}
|
||||
)
|
||||
|
||||
def delete_port(self, context, data):
|
||||
"""Notify all agent extensions to delete port."""
|
||||
for extension in self:
|
||||
try:
|
||||
if hasattr(extension.obj, 'delete_port'):
|
||||
extension.obj.delete_port(context, data)
|
||||
except AttributeError:
|
||||
LOG.exception(
|
||||
_LE("Agent Extension '%(name)s' failed "
|
||||
"while handling port deletion"),
|
||||
else:
|
||||
LOG.error(
|
||||
_LE("Agent Extension '%(name)s' does not "
|
||||
"implement method delete_port"),
|
||||
{'name': extension.name}
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue