def test_clear_deferred_hooks(self): deferred_events.set_deferred_hook('config-changed') deferred_events.set_deferred_hook('leader-settings-changed') self.assertEqual(deferred_events.get_deferred_hooks(), ['config-changed', 'leader-settings-changed']) deferred_events.clear_deferred_hooks() self.assertEqual(deferred_events.get_deferred_hooks(), [])
def test_set_deferred_hook(self): deferred_events.set_deferred_hook('config-changed') self.assertEqual(self.db.get('deferred-hooks'), ['config-changed']) deferred_events.set_deferred_hook('leader-settings-changed') self.assertEqual( self.db.get('deferred-hooks'), ['config-changed', 'leader-settings-changed'])
def install(self, check_deferred_events=True): """Run install if permitted. :param check_deferred_events: Whether to check if restarts are permitted before running hook. :type check_deferred_events: bool """ changed = reactive.flags.is_flag_set( 'config.changed.enable-auto-restarts') # Run method if enable-auto-restarts has changed, irrespective of what # it was changed to. This ensure that this method is not immediately # deferred when enable-auto-restarts is initially set to False. if ((not check_deferred_events) or changed or deferred_events.is_restart_permitted()): deferred_events.clear_deferred_hook('install') super().install() else: deferred_events.set_deferred_hook('install')
def configure_ovs(self, sb_conn, mlockall_changed, check_deferred_events=True): """Run configure_ovs if permitted. :param sb_conn: Comma separated string of OVSDB connection methods. :type sb_conn: str :param mlockall_changed: Whether the mlockall param has changed. :type mlockall_changed: bool :param check_deferred_events: Whether to check if restarts are permitted before running hook. :type check_deferred_events: bool """ changed = reactive.flags.is_flag_set( 'config.changed.enable-auto-restarts') # Run method if enable-auto-restarts has changed, irrespective of what # it was changed to. This ensure that this method is not immediately # deferred when enable-auto-restarts is initially set to False. if ((not check_deferred_events) or changed or deferred_events.is_restart_permitted()): deferred_events.clear_deferred_hook('configure_ovs') super().configure_ovs(sb_conn, mlockall_changed) else: deferred_events.set_deferred_hook('configure_ovs')
def test_get_deferred_hook(self): deferred_events.set_deferred_hook('config-changed') self.assertEqual(deferred_events.get_deferred_hooks(), ['config-changed'])