Merge "Add a new method ha_state_change to L3 agent extension"
This commit is contained in:
commit
73cb539a4c
neutron
releasenotes/notes
@ -109,9 +109,9 @@ class AgentMixin(object):
|
||||
return self.conf.ha_vrrp_advert_int
|
||||
|
||||
def enqueue_state_change(self, router_id, state):
|
||||
state_change_data = {"router_id": router_id, "state": state}
|
||||
LOG.info('Router %(router_id)s transitioned to %(state)s',
|
||||
{'router_id': router_id,
|
||||
'state': state})
|
||||
state_change_data)
|
||||
|
||||
ri = self._get_router_info(router_id)
|
||||
if ri is None:
|
||||
@ -127,6 +127,7 @@ class AgentMixin(object):
|
||||
self._update_radvd_daemon(ri, state)
|
||||
self.pd.process_ha_state(router_id, state == 'master')
|
||||
self.state_change_notifier.queue_event((router_id, state))
|
||||
self.l3_ext_manager.ha_state_change(self.context, state_change_data)
|
||||
|
||||
def _configure_ipv6_params_on_ext_gw_port_if_necessary(self, ri, state):
|
||||
# If ipv6 is enabled on the platform, ipv6_gateway config flag is
|
||||
|
@ -53,3 +53,13 @@ class L3AgentCoreResourceExtension(agent_extension.AgentExtension):
|
||||
:param context: rpc context
|
||||
:param data: router data
|
||||
"""
|
||||
|
||||
@abc.abstractmethod
|
||||
def ha_state_change(self, context, data):
|
||||
"""Change router state from agent extension.
|
||||
|
||||
Called on HA router state change.
|
||||
|
||||
:param context: rpc context
|
||||
:param data: dict of router_id and new state
|
||||
"""
|
||||
|
@ -70,3 +70,15 @@ class L3AgentExtensionsManager(agent_ext_manager.AgentExtensionsManager):
|
||||
"implement method delete_router",
|
||||
{'name': extension.name}
|
||||
)
|
||||
|
||||
def ha_state_change(self, context, data):
|
||||
"""Notify all agent extensions for HA router state change."""
|
||||
for extension in self:
|
||||
if hasattr(extension.obj, 'ha_state_change'):
|
||||
extension.obj.ha_state_change(context, data)
|
||||
else:
|
||||
LOG.warning(
|
||||
"Agent Extension '%(name)s' does not "
|
||||
"implement method ha_state_change",
|
||||
{'name': extension.name}
|
||||
)
|
||||
|
@ -216,6 +216,17 @@ class TestBasicRouterOperations(BasicRouterOperationsFramework):
|
||||
agent.enqueue_state_change(router.id, 'master')
|
||||
self.assertFalse(agent._update_metadata_proxy.call_count)
|
||||
|
||||
def test_enqueue_state_change_l3_extension(self):
|
||||
agent = l3_agent.L3NATAgent(HOSTNAME, self.conf)
|
||||
router = mock.Mock()
|
||||
router_info = mock.MagicMock()
|
||||
agent.router_info[router.id] = router_info
|
||||
agent.l3_ext_manager.ha_state_change = mock.Mock()
|
||||
agent.enqueue_state_change(router.id, 'master')
|
||||
agent.l3_ext_manager.ha_state_change.assert_called_once_with(
|
||||
agent.context,
|
||||
{'router_id': router.id, 'state': 'master'})
|
||||
|
||||
def _test__configure_ipv6_params_on_ext_gw_port_if_necessary_helper(
|
||||
self, state, enable_expected):
|
||||
agent = l3_agent.L3NATAgent(HOSTNAME, self.conf)
|
||||
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
A new method ``ha_state_change`` has been added to
|
||||
``L3AgentExtensionsManager``.
|
Loading…
x
Reference in New Issue
Block a user