Esempio n. 1
0
    def set_bluusite_offline_runners(self, bluusite, timestamp=None):
        """
        Sets runners for offline related system alerts.
        Alert has to:
         1. set to be sent in 15 minutes
         2. set to be sent in 24 hours
         3. set to be sent in a week
         4. set to be sent in a month
        """
        alert = Alert.objects.get(alert_type=Alert.SYSTEM_SITE_OFFLINE)

        # delete old offline runners
        self.filter(bluusite=bluusite, alert=alert, is_active=True).delete()

        delta = timedelta(minutes=15)
        when = timestamp + delta
        self.create(bluusite=bluusite, alert=alert, when=when,
                    period=_('15 minutes'), since=timestamp)

        delta = timedelta(hours=24)
        when = timestamp + delta
        self.create(bluusite=bluusite, alert=alert, when=when,
                    period=_('24h'), since=timestamp)

        delta = timedelta(days=7)
        when = timestamp + delta
        self.create(bluusite=bluusite, alert=alert, when=when,
                    period=_('week'), since=timestamp)

        when = add_one_month(timestamp)
        self.create(bluusite=bluusite, alert=alert, when=when,
                    period=_('month'), since=timestamp)
Esempio n. 2
0
    def set_battery_runners(self, device, timestamp=None):
        """
        Sets runners for battery related system alerts.
        Alert has to:
         1. set to be sent in 24 hours
         2. set to be sent in a week
         3. set to be sent in a month
        """
        alert = Alert.objects.get(alert_type=Alert.SYSTEM_BATTERY)

        delta = timedelta(hours=24)
        when = timestamp + delta
        self.create(bluusite=device.bluusite, device=device, alert=alert,
                    when=when, period=_('24h'), since=timestamp)

        delta = timedelta(days=7)
        when = timestamp + delta
        self.create(bluusite=device.bluusite, device=device, alert=alert,
                    when=when, period=_('week'), since=timestamp)

        when = add_one_month(timestamp)
        self.create(bluusite=device.bluusite, device=device, alert=alert,
                    when=when, period=_('month'), since=timestamp)