Example #1
0
    def _watchdog_show_cancel(self):
        """Show watchdog cancellation in any way possible."""

        _log.warning('watchdog cancelled')
        try:
            from codebay.l2tpserver import gnomehelpers
            gnomehelpers.show_notification(constants.WEBUI_WATCHDOG_CANCELLED_TITLE,
                                           constants.WEBUI_WATCHDOG_CANCELLED_TEXT,
                                           timeout=constants.WEBUI_WATCHDOG_CANCELLED_TIMEOUT,
                                           critical=False)
        except:
            _log.exception("_watchdog_show_cancel() failed")
Example #2
0
    def _watchdog_show_warning(self):
        """Show watchdog warning in any way possible."""

        _log.warning('watchdog warning')
        try:
            from codebay.l2tpserver import gnomehelpers
            gnomehelpers.show_notification(constants.WEBUI_WATCHDOG_WARNING_TITLE,
                                           constants.WEBUI_WATCHDOG_WARNING_TEXT,
                                           timeout=constants.WEBUI_WATCHDOG_WARNING_TIMEOUT,
                                           critical=True)
        except:
            _log.exception("_watchdog_show_warning() failed")
Example #3
0
    def _periodic_reboot_show_warning(self):
        """Show periodic reboot warning in any way possible."""

        _log.warning('periodic reboot warning')
        try:
            from codebay.l2tpserver import gnomehelpers
            gnomehelpers.show_notification(constants.WEBUI_PERIODIC_REBOOT_PENDING_TITLE,
                                           constants.WEBUI_PERIODIC_REBOOT_PENDING_TEXT,
                                           timeout=constants.WEBUI_PERIODIC_REBOOT_PENDING_TIMEOUT,
                                           critical=False)
        except:
            _log.exception("_periodic_reboot_show_warning() failed")
Example #4
0
    def _watchdog_show_cancel(self):
        """Show watchdog cancellation in any way possible."""

        _log.warning('watchdog cancelled')
        try:
            from codebay.l2tpserver import gnomehelpers
            gnomehelpers.show_notification(
                constants.WEBUI_WATCHDOG_CANCELLED_TITLE,
                constants.WEBUI_WATCHDOG_CANCELLED_TEXT,
                timeout=constants.WEBUI_WATCHDOG_CANCELLED_TIMEOUT,
                critical=False)
        except:
            _log.exception("_watchdog_show_cancel() failed")
Example #5
0
    def _watchdog_show_warning(self):
        """Show watchdog warning in any way possible."""

        _log.warning('watchdog warning')
        try:
            from codebay.l2tpserver import gnomehelpers
            gnomehelpers.show_notification(
                constants.WEBUI_WATCHDOG_WARNING_TITLE,
                constants.WEBUI_WATCHDOG_WARNING_TEXT,
                timeout=constants.WEBUI_WATCHDOG_WARNING_TIMEOUT,
                critical=True)
        except:
            _log.exception("_watchdog_show_warning() failed")
Example #6
0
    def _periodic_reboot_show_warning(self):
        """Show periodic reboot warning in any way possible."""

        _log.warning('periodic reboot warning')
        try:
            from codebay.l2tpserver import gnomehelpers
            gnomehelpers.show_notification(
                constants.WEBUI_PERIODIC_REBOOT_PENDING_TITLE,
                constants.WEBUI_PERIODIC_REBOOT_PENDING_TEXT,
                timeout=constants.WEBUI_PERIODIC_REBOOT_PENDING_TIMEOUT,
                critical=False)
        except:
            _log.exception("_periodic_reboot_show_warning() failed")
Example #7
0
        def _runner_stopped_notification(res):
            _log.debug("_runner_stopped_notification")
            try:
                from codebay.l2tpserver import gnomehelpers

                gnomehelpers.show_notification(
                    constants.WEBUI_RUNNER_STOPPED_TITLE,
                    constants.WEBUI_RUNNER_STOPPED_TEXT,
                    timeout=constants.WEBUI_RUNNER_STOPPED_TIMEOUT,
                    critical=False,
                )
            except:
                _log.exception("_runner_stopped_notification() failed")
Example #8
0
def show_cron_watchdog_notify():
    _setup_logging()
    if helpers.is_live_cd():
        _log.info('live cd, skipping cron action')
        return
    _log.warning('trying to show cron watchdog notify')

    try:
        from codebay.l2tpserver import gnomehelpers
        gnomehelpers.show_notification(constants.CRON_WATCHDOG_WARNING_TITLE,
                                       constants.CRON_WATCHDOG_WARNING_TEXT,
                                       timeout=constants.CRON_WATCHDOG_WARNING_TIMEOUT,
                                       critical=True)
    except:
        _log.exception("show_cron_watchdog_notify() failed")
Example #9
0
    def _do_timesync(self, utc_time):
        # XXX: if time step is too large, we need to take some measures here to prevent twisted problems
        # (Twisted does not handle time jumps correctly; if time goes backwards, timers become frozen).
        # One relatively benign fix here would be to reschedule all critical timers, such as the watchdog.
        # A more brute force fix would be to restart the web UI.
        try:
            full_sync = timesync.update_system_time(
                utc_time,
                cap_backwards=constants.WEBUI_TIMESYNC_CAP_BACKWARDS,
                cap_forwards=constants.WEBUI_TIMESYNC_CAP_FORWARDS,
            )

            if full_sync:
                helpers.write_datetime_marker_file(constants.WEBUI_LAST_TIMESYNC_FILE)
            else:
                # probably capped, don't write marker because it would enable RRD with bogus system time
                _log.info("timesync not full (probably capped), not writing webui timesync file")

            # notify if time difference is still too large (jump was capped too heavily)
            now = datetime.datetime.utcnow()
            timediff = utc_time - now
            if timediff < datetime.timedelta(0, 0, 0):
                timediff = -timediff
            if (timediff > constants.WEBUI_TIMESYNC_NOTIFY_LIMIT) and (not self._timesync_notify_shown):
                try:
                    from codebay.l2tpserver import gnomehelpers

                    gnomehelpers.show_notification(
                        constants.WEBUI_TIMESYNC_NOTIFY_TITLE,
                        constants.WEBUI_TIMESYNC_NOTIFY_TEXT,
                        timeout=constants.WEBUI_TIMESYNC_NOTIFY_TIMEOUT,
                        critical=False,
                    )

                    # NB: it is important to do this after show_notification(); if, for instance,
                    # boot is in progress, the initial notification will fail and a notification
                    # will only be shown on reidentify.  Not ideal, but at least the notification
                    # will not be completely hidden.
                    self._timesync_notify_shown = True
                except:
                    _log.exception("_do_timesync(): failed to show notify of time jump")
        except:
            _log.exception("time sync failed")