self._queue.add(update)
def after_start(self):
+ # Note: the FWaaS' vArmourL3NATAgent is a subclass of L3NATAgent. It
+ # calls this method here. So Removing this after_start() would break
+ # vArmourL3NATAgent. We need to find out whether vArmourL3NATAgent
+ # can have L3NATAgentWithStateReport as its base class instead of
+ # L3NATAgent.
eventlet.spawn_n(self._process_routers_loop)
LOG.info(_LI("L3 agent started"))
# When L3 agent is ready, we immediately do a full sync
class L3NATAgentWithStateReport(L3NATAgent):
def __init__(self, host, conf=None):
+ self.use_call = True
super(L3NATAgentWithStateReport, self).__init__(host=host, conf=conf)
self.state_rpc = agent_rpc.PluginReportStateAPI(topics.PLUGIN)
self.agent_state = {
'start_flag': True,
'agent_type': l3_constants.AGENT_TYPE_L3}
report_interval = self.conf.AGENT.report_interval
- self.use_call = True
if report_interval:
self.heartbeat = loopingcall.FixedIntervalLoopingCall(
self._report_state)
except Exception:
LOG.exception(_LE("Failed reporting state!"))
+ def after_start(self):
+ eventlet.spawn_n(self._process_routers_loop)
+ LOG.info(_LI("L3 agent started"))
+ # Do the report state before we do the first full sync.
+ self._report_state()
+
+ # When L3 agent is ready, we immediately do a full sync
+ self.periodic_sync_routers_task(self.context)
+
def agent_updated(self, context, payload):
"""Handle the agent_updated notification event."""
self.fullsync = True
from neutron.agent.linux import interface
from neutron.agent.linux import ra
from neutron.agent.metadata import driver as metadata_driver
+from neutron.agent import rpc as agent_rpc
from neutron.callbacks import manager
from neutron.callbacks import registry
from neutron.common import config as base_config
self.conf = agent_config.setup_conf()
self.conf.register_opts(base_config.core_opts)
log.register_options(self.conf)
+ self.conf.register_opts(agent_config.AGENT_STATE_OPTS, 'AGENT')
self.conf.register_opts(l3_config.OPTS)
self.conf.register_opts(ha.OPTS)
agent_config.register_interface_driver_opts_helper(self.conf)
agent.after_start()
router_sync.assert_called_once_with(agent.context)
+ def test_l3_initial_report_state_done(self):
+ with mock.patch.object(l3_agent.L3NATAgentWithStateReport,
+ 'periodic_sync_routers_task'),\
+ mock.patch.object(agent_rpc.PluginReportStateAPI,
+ 'report_state') as report_state,\
+ mock.patch.object(eventlet, 'spawn_n'):
+
+ agent = l3_agent.L3NATAgentWithStateReport(host=HOSTNAME,
+ conf=self.conf)
+
+ self.assertEqual(agent.agent_state['start_flag'], True)
+ use_call_arg = agent.use_call
+ agent.after_start()
+ report_state.assert_called_once_with(agent.context,
+ agent.agent_state,
+ use_call_arg)
+ self.assertTrue(agent.agent_state.get('start_flag') is None)
+
def test_periodic_sync_routers_task_call_clean_stale_namespaces(self):
agent = l3_agent.L3NATAgent(HOSTNAME, self.conf)
self.plugin_api.get_routers.return_value = []