from oslo_log import log as logging
import oslo_messaging
from oslo_service import loopingcall
+from oslo_service import systemd
import six
from six import moves
LOG.info(_LI('Agent has just been revived. '
'Doing a full sync.'))
self.fullsync = True
- self.agent_state.pop('start_flag', None)
+
+ if self.agent_state.pop('start_flag', None):
+ # On initial start, we notify systemd after initialization
+ # is complete.
+ systemd.notify_once()
except Exception:
LOG.exception(_LE("Failed reporting state!"))
notifier_cls = notifier_p.start()
self.notifier = mock.Mock()
notifier_cls.return_value = self.notifier
+ systemd_patch = mock.patch('oslo_service.systemd.notify_once')
+ self.systemd_notify = systemd_patch.start()
+
cfg.CONF.set_default('firewall_driver',
'neutron.agent.firewall.NoopFirewallDriver',
group='SECURITYGROUP')
with mock.patch.object(self.agent.state_rpc,
"report_state") as report_st:
self.agent.int_br_device_count = 5
+ self.systemd_notify.assert_not_called()
self.agent._report_state()
report_st.assert_called_with(self.agent.context,
self.agent.agent_state, True)
+ self.systemd_notify.assert_called_once_with()
+ self.systemd_notify.reset_mock()
self.assertNotIn("start_flag", self.agent.agent_state)
self.assertEqual(
self.agent.agent_state["configurations"]["devices"],
self.agent._report_state()
report_st.assert_called_with(self.agent.context,
self.agent.agent_state, True)
+ self.systemd_notify.assert_not_called()
def test_report_state_fail(self):
with mock.patch.object(self.agent.state_rpc,
self.agent._report_state()
report_st.assert_called_with(self.agent.context,
self.agent.agent_state, True)
+ self.systemd_notify.assert_not_called()
def test_report_state_revived(self):
with mock.patch.object(self.agent.state_rpc,